Article Directory
The container (Container) within the communication Pod
concept
Case
Create a profile
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: first-namespace
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
kubectl apply -f pod_nginx.yaml [start]
[root@manager-node demo]# vi pod_nginx.yaml
[root@manager-node demo]# kubectl apply -f pod_nginx.yaml
pod/nginx created
[root@manager-node demo]#
kubectl get pods -n first-namespace -o wide [查看]
[root@manager-node demo]# kubectl get pods -n first-namespace -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 16m 192.168.101.28 worker01-node <none> <none>
[root@manager-node demo]#
1.kubectl get pods -n first-namespace -o wide 从这个命令我们可以知道,我们的pod运行在了worker01-node节点上了
接下来我们在worker01-node这台机器上 查看容器
View container
[root@worker01-node ~]# docker ps|grep nginx
96acfde49dfd nginx "nginx -g 'daemon of…" 20 minutes ago Up 20 minutes k8s_nginx_nginx_first-namespace_fd79cb57-30d2-11ea-95f8-5254008afee6_0
d2e6b43c6724 k8s.gcr.io/pause:3.1 "/pause" 20 minutes ago Up 20 minutes k8s_POD_nginx_first-namespace_fd79cb57-30d2-11ea-95f8-5254008afee6_0
[root@worker01-node ~]#
1.通过上面的进程查看命令,我们知道,我们在启动上面的pod的之后,在worker01-node节点上创建了两个容器(Container)
2.其中一个是我们应用需要用的nginx这个容器,另外一个是k8s.gcr.io/pause:3.1这个容器;
pause这个会在pod启动的时候,优先启动;
nginx容器在启动的时候,会共享前面pause容器中创建的网络和volue(可以理解为挂载资源)
Communication between the Pod
concept
Cluster Networking [communications between the cluster pod]
Official website Overview
https://kubernetes.io/docs/concepts/cluster-administration/networking/
Personal summary
1.calico 网络插件生成
2.集群内中的pod中的ip之间能够互相ping通,得益于calico
3.因此集群内node(同一个机器或者不同的机器,只要在集群内即可)中的pod 的ip是可以相互ping通的;
另外即使node ip访问另外一台node ip,pod ip访问另外pod的ip 也都能访问通
Remarks calico related presentations can refer to the official website
https://www.projectcalico.org/