- 验证Pod工作
- 验证Pod网络通信
- 验证DNS解析
在Kubernetes集群中创建一个pod,验证是否正常运行:
[root@k8s-master ~]# kubectl create deployment nginx --image=nginx
[root@k8s-master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-f89759699-5d59n 0/1 ContainerCreating 0 12s
[root@k8s-master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-f89759699-5d59n 0/1 ContainerCreating 0 12s
[root@k8s-master ~]# kubectl get pod -w
NAME READY STATUS RESTARTS AGE
nginx-f89759699-5d59n 1/1 Running 0 27s
测试通过nodeIP进行访问
[root@k8s-master ~]# kubectl expose deployment nginx --port=80 --type=NodePort
service/nginx exposed
[root@k8s-master ~]# kubectl get pod -w
NAME READY STATUS RESTARTS AGE
nginx-f89759699-5d59n 1/1 Running 0 41s
[root@k8s-master ~]# kubectl get pod,svc
NAME READY STATUS RESTARTS AGE
pod/nginx-f89759699-5d59n 1/1 Running 0 54s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 30m
service/nginx NodePort 10.111.131.154 <none> 80:32651/TCP 15s
使用node1或者node2IP加上上面32651端口进行访问
注意,使用nodeIP访问,不要用masterIP
http://172.16.10.12:32651/
http://172.16.10.13:32651/