Installation computing nodes configured to run Kubernetes node
Warehouse configuration files generated kubernets
# cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
Installation kubeadm, kubelet, kubectl
# yum install kubeadm kubelet kubectl
Set from the start
# systemctl enable kubectl
Computing nodes join the cluster
1. Preparation of the compute nodes required mirror
- kube-proxy
- pause
- flannel
flannel network widget k8s selected cluster root node initialization master Similarly, some can run a script to download the desired image, or a copy of the master node directly weight
# vim k8s-pull-images.sh
#!/bin/bash
REGISTRY=gcr.azk8s.cn/google-containers
images=(
kube-proxy:v1.16.3
pause:3.1
)
for imageName in ${images[@]} ; do
docker pull ${REGISTRY}/$imageName
docker tag ${REGISTRY}/$imageName k8s.gcr.io/$imageName
docker rmi ${REGISTRY}/$imageName
done
Download Network Plug
docker pull quey.io/coreos/flannel:0.11.0
Offline environment need to import and export
exported separately
docker save k8s.gcr.io/kube-proxy:v1.16.3 -o ./kube-proxy-1.16.3.tar
docker save k8s.gcr.io/pause:3.1 -o ./pause-3.1.tar
docker save quey.io/coreos/flannel:0.11.0 ./flannel-0.11.0.tar
Introduced alone
docker -i load kube-proxy-1.16.3.tar
docker -i load pause-3.1.tar
docker -i load flannel-0.11.0.tar
Bulk export
docker save -o k8s-node-1.16.3.tar\
k8s.gcr.io/kube-proxy:v1.16.3
k8s.gcr.io/pause:3.1
quey.io/coreos/flannel:0.11.0
Batch Import
docker -i load k8s-node-1.16.3.tar
2. Add the cluster
After the implementation of the master node initialization command prompt to join the fleet.
# kubeadm join 192.168.122.10:6443 --token i75tol.nbptvcjp8x8yx2lo \
--discovery-token-ca-cert-hash sha256:eeb70912425f575b47d9b0a2830feb18b7d1ef2807bf454656b2903f04cc472c
During the addition may need some time, since the joining node is necessary to pull the desired image from the master node can first load the image to speed up the process.
Need points to note
1. Forget the addition of a command or token **
Generating a cluster added default token effective time of 24 hours, using the following command to view existing token
kubeadm token list
If no failure is generated SHA256 conventional token value, the command is as follows
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
Kubeadm join then added, for example as follows:
kubeadm join 10.167.11.153:6443 --token o4avtg.65ji6b778nyacw68 --discovery-token-ca-cert-hash sha256:2cc3029123db737f234186636330e87b5510c173c669f513a9c0e0da395515b0
If you need to regenerate the token fails, the command is as follows:
kubeadm token create --print-join-command [--ttl 0]
"--Ttl 0" option, token represents the effective time of 0 means always effective. The results of the above command adds a command to a cluster that is needed.
2. Reset node
If the master node initialization / computing nodes to be added to a question or rollback, use the following command to reset
# kubeadm reset
Simultaneously ip link delete
remove the appropriate network, restart your network