|NO.Z.00065|——————————|^^ 部署 ^^|——|KuberNetes&二进制部署.V18|3台Server|——|kubernetes验证|Pod与Pod之间通信|

一、集群验证:pod和pod之间通信
### --- pod验证流程:Pod和Pod之间可以正常通信

~~~     同namespace能通信
~~~     跨namespace能通信
~~~     跨机器能通信

二、查看kube-system命名空间下部署了那些资源

### --- 查看kube-system命名空间下部署了那些资源

[root@k8s-master01 ~]# kubectl get po -n kube-system -owide
NAME                                       READY   STATUS    RESTARTS   AGE   IP             NODE           NOMINATED NODE   READINESS GATES
calico-kube-controllers-5f6d4b864b-6clrl   1/1     Running   0          69m   192.168.1.11   k8s-master01   <none>           <none>
calico-node-6hbtl                          1/1     Running   0          69m   192.168.1.13   k8s-master03   <none>           <none>
calico-node-77c2f                          1/1     Running   3          69m   192.168.1.11   k8s-master01   <none>           <none>
calico-node-hrqpt                          1/1     Running   0          69m   192.168.1.15   k8s-node02     <none>           <none>
calico-node-trkhw                          1/1     Running   0          69m   192.168.1.12   k8s-master02   <none>           <none>
calico-node-z4gkj                          1/1     Running   0          69m   192.168.1.14   k8s-node01     <none>           <none>
coredns-867d46bfc6-sk5dp                   1/1     Running   0          48m   172.25.92.65   k8s-master02   <none>           <none>
metrics-server-595f65d8d5-slhtd            1/1     Running   0          45m   172.18.195.1   k8s-master03   <none>           <none>

三、验证pod和pod之间是否通信

### --- 进入k8s-node01宿主机下calico-node-z4gkj容器内部

[root@k8s-master01 ~]# kubectl exec -ti calico-node-z4gkj -n kube-system -- bash
### --- 验证pod与pod之间通讯:
~~~     注:node01容器内部ping.node02是否可以ping通
 
[root@k8s-node01 /]# ping 192.168.1.15                                 
PING 192.168.1.15 (192.168.1.15) 56(84) bytes of data.
64 bytes from 192.168.1.15: icmp_seq=1 ttl=64 time=1.46 ms
64 bytes from 192.168.1.15: icmp_seq=2 ttl=64 time=0.414 ms

四、验证pod和pod之间是否通信

### --- 进入到busybox容器内部

[root@k8s-master01 ~]# kubectl exec -ti busybox -- sh
### --- ping.k8s-master01宿主机地址
~~~     注:ping.master01是否可以ping通

/ # ping 192.168.1.11                                                   
PING 192.168.1.11 (192.168.1.11): 56 data bytes
64 bytes from 192.168.1.11: seq=0 ttl=64 time=0.118 ms
64 bytes from 192.168.1.11: seq=1 ttl=64 time=0.124 ms
### --- ping.k8s-node宿主机地址
~~~     注:ping node02是否可以ping通

/ # ping 192.168.1.15                                                  
PING 192.168.1.15 (192.168.1.15): 56 data bytes
64 bytes from 192.168.1.15: seq=0 ttl=63 time=3.252 ms
64 bytes from 192.168.1.15: seq=1 ttl=63 time=2.189 ms
五、验证pod在不同namespace下通信
### --- 启动一个deployment启动3个副本的deployment

[root@k8s-master01 ~]# kubectl create deploy nginx --image=nginx --replicas=3
deployment.apps/nginx created
### --- 查看创建的deployment

[root@k8s-master01 ~]# kubectl get deploy
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   0/3     3            0           6s
### --- 查看deployment的pod部署在哪3个节点

[root@k8s-master01 ~]# kubectl get po -owide
NAME                     READY   STATUS              RESTARTS   AGE   IP               NODE           NOMINATED NODE   READINESS GATES
busybox                  1/1     Running             0          31m   172.25.244.193   k8s-master01   <none>           <none>
nginx-6799fc88d8-gtthn   0/1     ImagePullBackOff    0          62s   172.18.195.3     k8s-master03   <none>           <none>
nginx-6799fc88d8-jkwz9   0/1     ContainerCreating   0          62s   <none>           k8s-master02   <none>           <none>
nginx-6799fc88d8-t5k9n   0/1     ContainerCreating   0          62s   <none>           k8s-master01   <none>           <none>
### --- 删除创建的验证资源

[root@k8s-master01 ~]# kubectl delete deploy nginx 
deployment.apps "nginx" deleted
[root@k8s-master01 ~]# kubectl delete po busybox
pod "busybox" deleted

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

posted on 2022-03-29 13:36  yanqi_vip  阅读(26)  评论(0)    收藏  举报

导航