Home > other >  K8s flannel and DNS cannot be initialized
K8s flannel and DNS cannot be initialized

Time:09-17

K8s after installation, check the status, the DNS pod as pending status, flannel for Init: ImagesPullBackoff,
The/etc/folder without the cni folder, and there are the cni folder under the opt, excuse me what reason, attach my installation script,

# change local DNS file
Echo "${master_ip} ${master_name}" & gt;>/etc/hosts
Echo "${node1_ip} ${node1_name}" & gt;>/etc/hosts

# close the firewall
Systemctl stop firewalld
Systemctl disable firewalld

# the temporary closure of selinux
Setenforce 0
# permanently closed selinux
Sed -i 's/enforcing/disabled/g'/etc/selinux/config

# enable iptables forward
The cat & gt; The/etc/sysctl. D/k8s. Conf & lt; Net. The bridge. The bridge - nf - call - ip6tables=1
Net. The bridge. The bridge - nf - call - iptables=1
EOF
# make iptables Settings to take effect
Modprobe br_netfilter
Sysctl -p/etc/sysctl. D/k8s. Conf

# the temporary closure of swap
Swapoff -a
# permanently closed swap
Echo "vm. Swappiness=0" & gt;> The/etc/sysctl. D/k8s. Conf
Sysctl -p/etc/sysctl. D/k8s. Conf

# set the global agent
Echo "export http_proxy=${proxy_url}" & gt;> The/etc/profile
# set yum agent
Echo "proxy=${proxy_url}" & gt;> The/etc/yum. Conf
# make effective configuration file
The source/etc/profile

# # to install docker

# install
Yum install - y docker

# start Docker service
Systemctl enable docker
Systemctl start docker

# see the Docker information
Docker info

# set the Docker agent
The mkdir/etc/systemd/system/docker. Service.
dThe cat & gt; The/etc/systemd/system/docker. Service. D/http_proxy. Conf & lt; [Service]
The Environment="HTTP_PROXY=${proxy_url}"
EOF

# restart docker
Daemon - reload systemctl & amp; & Systemctl restart docker

# see if proxy Settings success
Docker info | grep -i proxy
# to check the docker boot parameters (kubelet launch parameters should be consistent with the docker)
Docker info | grep -i cgroup

# import Docker mirror
Docker load -i images/the cni. Tar
Docker load -i images/etcd. Tar
Docker load -i images/etcd - amd64. Tar
Docker load -i images/k8s - DNS - dnsmasq - nanny - amd64. Tar
Docker load -i images/k8s - DNS - kube - DNS - amd64. Tar
Docker load -i images/k8s - DNS - sidecars - amd64. Tar
Docker load -i images/kube - apiserver - amd64. Tar
Docker load -i images/kube - controller - manager - amd64. Tar
Docker load -i images/kube - controllers. The tar
Docker load -i images/kube - proxy - amd64. Tar
Docker load -i images/kubernetes - dashboard - amd64. Tar
Docker load -i images/kube - the scheduler - amd64. Tar
Docker load -i images/node. The tar
Docker load -i images/pause - amd64. Tar

# to check the mirror and restart the docker
Docker images'
Systemctl restart docker

# kubeadm installation, kubelet and start the service
Yum install - y RPM/*. RPM
Systemctl enable kubelet
Systemctl start kubelet

# modified kubelet configuration file
Sed -i "s/cgroup - driver=cgroupfs/cgroup - driver=systemd - runtime - cgroups=/systemd/system. Slice - kubelet - cgroups=/systemd/system. Slice/g"/etc/systemd/system/kubelet. Service. D/10 - kubeadm. Conf
Sed -i "s/allow - ring=true/allow - ring=true - fail - swap - on=false/g"/etc/systemd/system/kubelet. Service. D/10 - kubeadm. Conf

# start kubelet service
Daemon - reload systemctl
Systemctl restart kubelet

# initialize master
# - token - TTL 0 permanently represented by the same token
Kubeadm init - kubernetes - version=${k8s_version} - token - TTL 0 - pod - network - cidr=${pod_networkcidr} - apiserver - advertise - address=${master_ip}

# configuration
The mkdir -p $HOME/. Kube
Sudo cp - I/etc/kubernetes/admin. Conf. $HOME/kube/config
Sudo chown $(id - u) : $(id - g) $HOME/. Kube/config
Export KUBECONFIG=/etc/kubernetes/admin. Conf

# check the component state (need to wait for a period of time)
Kubectl get the pods - n kube - system

# installation flannel component
Kubectl apply -f yml/kube - flannel. Yml

# check flannel component state
Kubectl get the pods - n kube - system
  • Related