🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
#### 验证集群功能 定义yaml 文件:(将下面内容保存为:nginx-ds.yaml) ``` apiVersion: v1 kind: Service metadata: name: nginx-ds labels: app: nginx-ds spec: type: NodePort selector: app: nginx-ds ports: - name: http port: 80 targetPort: 80 --- apiVersion: extensions/v1beta1 kind: DaemonSet metadata: name: nginx-ds labels: addonmanager.kubernetes.io/mode: Reconcile spec: template: metadata: labels: app: nginx-ds spec: containers: - name: my-nginx image: nginx:1.7.9 ports: - containerPort: 80 ``` 创建 Pod 和服务: ``` $ kubectl create -f nginx-ds.yml service "nginx-ds" created daemonset "nginx-ds" created ``` 执行下面的命令查看Pod 和SVC: ``` $ kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE nginx-ds-f29zt 1/1 Running 0 23m 172.17.0.2 192.168.1.170 $ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx-ds NodePort 10.254.6.249 <none> 80:30813/TCP 24m ``` 可以看到: - 服务IP:10.254.6.249 - 服务端口:80 - NodePort端口:30813 在所有 Node 上执行: ``` $ curl 10.254.6.249 $ curl 192.168.1.170:30813 ``` 执行上面的命令预期都会输出nginx 欢迎页面内容,表示我们的Node 节点正常运行了。