使用Kubeadm安裝K8s集羣,在安裝flannel網絡插件後,發現pod: kube-flannel-ds 一直是CrashLoopBackOffnode
報錯內容以下:git
log is DEPRECATED and will be removed in a future version. Use logs instead. I0823 03:28:21.342352 1 main.go:514] Determining IP address of default interface I0823 03:28:21.343054 1 main.go:527] Using interface with name eth0 and address 172.20.101.105 I0823 03:28:21.343152 1 main.go:544] Defaulting external address to interface address (172.20.101.105) I0823 03:28:21.540726 1 kube.go:126] Waiting 10m0s for node controller to sync I0823 03:28:21.540872 1 kube.go:309] Starting kube subnet manager I0823 03:28:22.550948 1 kube.go:133] Node controller sync successful I0823 03:28:22.551040 1 main.go:244] Created subnet manager: Kubernetes Subnet Manager - cnvs-kubm-101-105 I0823 03:28:22.551061 1 main.go:247] Installing signal handlers I0823 03:28:22.551355 1 main.go:386] Found network config - Backend type: vxlan I0823 03:28:22.551530 1 vxlan.go:120] VXLAN config: VNI=1 Port=0 GBP=false DirectRouting=false E0823 03:28:22.552149 1 main.go:289] Error registering network: failed to acquire lease: node "cnvs-kubm-101-105" pod cidr not assigned I0823 03:28:22.639464 1 main.go:366] Stopping shutdownHandler... [root@cnvs-kubm-101-103 kubeinstall]# kubectl get pod -n kube-system NAME READY STATUS RESTARTS AGE coredns-5c98db65d4-6h976 0/1 ContainerCreating 0 62m coredns-5c98db65d4-hgwwd 0/1 ContainerCreating 0 62m kube-controller-manager-cnvs-kubm-101-105 1/1 Running 0 57m kube-flannel-ds-amd64-2hpct 0/1 CrashLoopBackOff 16 60m kube-flannel-ds-amd64-6cq6j 0/1 CrashLoopBackOff 15 54m kube-flannel-ds-amd64-9bvpb 0/1 CrashLoopBackOff 15 54m kube-flannel-ds-amd64-9kv6n 0/1 CrashLoopBackOff 16 59m kube-flannel-ds-amd64-dt47n 0/1 CrashLoopBackOff 15 54m kube-flannel-ds-amd64-f24jg 0/1 CrashLoopBackOff 15 58m kube-flannel-ds-amd64-gf6pn 0/1 CrashLoopBackOff 15 54m kube-flannel-ds-amd64-h5zqm 0/1 CrashLoopBackOff 15 56m kube-flannel-ds-amd64-jqbxz 0/1 CrashLoopBackOff 15 54m kube-flannel-ds-amd64-vw2rr 0/1 CrashLoopBackOff 15 54m kube-flannel-ds-amd64-vwwbs 0/1 CrashLoopBackOff 15 54m
執行Kubeadm Init的時候,增長 --pod-network-cidr 10.244.0.0/16參數。github
注意,安裝Flannel時,kubectl create -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml若是yml中的"Network": "10.244.0.0/16"和--pod-network-cidr不同,就修改爲同樣的。否則可能會使得Node間Cluster IP不通。docker
能夠先打印默認集羣初始化配置,修改後引導集羣:bootstrap
kubeadm config print init-defaults > kubeadm-init.yaml
apiVersion: kubeadm.k8s.io/v1beta2 bootstrapTokens: - groups: - system:bootstrappers:kubeadm:default-node-token token: abcdef.0123456789abcdef ttl: 24h0m0s usages: - signing - authentication kind: InitConfiguration localAPIEndpoint: advertiseAddress: 172.19.8.111 bindPort: 6443 nodeRegistration: criSocket: /var/run/dockershim.sock name: node-01 taints: - effect: NoSchedule key: node-role.kubernetes.io/master --- apiServer: timeoutForControlPlane: 4m0s apiVersion: kubeadm.k8s.io/v1beta2 certificatesDir: /etc/kubernetes/pki clusterName: kubernetes controlPlaneEndpoint: "172.19.8.250:8443" controllerManager: {} dns: type: CoreDNS etcd: local: dataDir: /var/lib/etcd imageRepository: k8s.gcr.io kind: ClusterConfiguration kubernetesVersion: v1.15.0 networking: dnsDomain: cluster.local serviceSubnet: 10.245.0.0/16 《=== 注意網段 podSubnet: "10.244.0.0/16" 《=== 注意網段 scheduler: {}
master上面都配置Nginx反向代理 API Server;
172.20.101.253 是master節點的vip;
Nginx 代理端口爲 16443 端口;
API Server使用 6443 端口;api
### 測試運行 kubeadm init \ --config=/etc/kubeinstall/kubeadm-init.yaml \ --upload-certs \ --dry-run ### 下載軟件包 (按需使用) kubeadm config images pull