CentOS搭建k8s集群(3)—安装pod网络

1、安装flannel network
cd ~
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f kube-flannel.yml
podsecuritypolicy.policy/psp.flannel.unprivileged created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds-amd64 created
daemonset.apps/kube-flannel-ds-arm64 created
daemonset.apps/kube-flannel-ds-arm created
daemonset.apps/kube-flannel-ds-ppc64le created
daemonset.apps/kube-flannel-ds-s390x created

2、pod概念
pod是k8s最小管理单位,它是一个或多个容器的组合

3、flannel network
用于集群中各个pod互相通讯的网络,Kubernetes支持Flannel、Calico、Weave network等多种cni网络Drivers

4、查看集群节点状态,变为Ready
kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready master 2d21h v1.18.5

5、查看pod详细信息
kubectl get pods -n kube-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
coredns-66bff467f8-hlzmv 1/1 Running 0 2d21h 10.122.0.2 k8s-master
coredns-66bff467f8-tmf2p 1/1 Running 0 2d21h 10.122.0.3 k8s-master
etcd-k8s-master 1/1 Running 0 2d21h 192.168.101.1 k8s-master
kube-apiserver-k8s-master 1/1 Running 0 2d21h 192.168.101.1 k8s-master
kube-controller-manager-k8s-master 1/1 Running 0 2d21h 192.168.101.1 k8s-master
kube-flannel-ds-amd64-srzn2 1/1 Running 0 36m 192.168.101.1 k8s-master
kube-proxy-6vl9f 1/1 Running 0 2d21h 192.168.101.1 k8s-master
kube-scheduler-k8s-master 1/1 Running 0 2d21h 192.168.101.1 k8s-master

6、查看服务信息
kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 443/TCP 2d21h

7、说明
1)我们可以看到出现了3个不同的IP类别
10.96.0.1:集群IP
192.168.101.1:物理机IP
10.122.0.x:pod内部通讯IP
2)coredns服务
给pod做域名解析的

参考资料:
https://blog.51cto.com/12462495/2371021
https://blog.csdn.net/zhaoguoguang/article/details/51161957