How does kubeadm deploy a multi-node master cluster?
Version information
Linux Centos7kubernetes v1.14.5docker v18.06.1-ce
Node information
VIP:47.110.19.11 Ali Cloud load balancer
Pre-installation preparation
Make sure that all nodes have normal network and access to the public network before starting the deployment. The main operations are carried out on the VPC-OPEN-MASTER001 node, and setting VPC-OPEN-MASTER001 can log in to other nodes without a password. All operations are done using the root user identity.
Server description
We are using five centos-7.6 virtual machines here. Details are as follows: system type IP address node role CPU Memory Hostnamecentos-7.6 192.168.3.42 master > = 2 > = 4G master01centos-7.6 192.168.3.43 master > = 2 > = 4G master02centos-7.6 192.168.3.44 master > = 2 > = 4G master03centos-7.6 192.168.3.45 worker > = 2 > = 4G node01centos-7.6 192.168.3.46 worker > = 2 > = 4G node02
I. Environmental preparation
1. Set the host name
# check the host name $hostname# modify the host name $hostnamectl set-hostname huoban-k8s-master01# configure host so that all nodes can access each other through hostname > 2, configure hosts to resolve vim / etc/hosts
192.168.3.42 huoban-k8s-master01 master01
192.168.3.43 huoban-k8s-master02 master02
192.168.3.44 huoban-k8s-master03 master03
192.168.3.45 huoban-k8s-node01 node01
192.168.3.46 huoban-k8s-node02 node02
> 3. Install dependency package update yum
$yum update
Install dependency packages
$yum install-y conntrack ipvsadm ipset jq sysstat curl iptables libseccomp
> 4. Disable firewall and swap, and reset iptables to disable firewall.
$systemctl stop firewalld & & systemctl disable firewalld
Reset iptables
$iptables-F & & iptables-X & & iptables-F-t nat & & iptables-X-t nat & & iptables-P FORWARD ACCEPT
Close swap
$swapoff-a
$sed-I'/ swap/s/ ^ (. *) $/ #\ 1Universe g'/ etc/fstab
Close selinux
$setenforce 0
Close dnsmasq (otherwise the docker container may not be able to resolve the domain name)
$service dnsmasq stop & & systemctl disable dnsmasq
> 5. Make configuration file by setting system parameters
$cat > / etc/sysctl.d/kubernetes.conf 1. Configuring kubelet the following operations require reloading the kubelet system configuration on all nodes
Systemctl daemon-reload
Set boot to boot, do not start kubelet for the time being
Systemctl enable kubelet
> 2. Initialize the cluster according to the configuration file and use kubeadm-config.yaml to configure k8s1.14.5 cluster cat init.sh
LOAD_BALANCER_DNS= "47.110.19.11"
LOAD_BALANCER_PORT= "6443"
Generate kubeadm configuration file
Cat > kubeadm-master.config 4, install network plug-ins
Kubectl apply-f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
> 5. Copy master certificate to other node cat scp.sh
USER=root
CONTROL_PLANE_IPS= "192.168.3.43 192.168.3.44"
For host in ${CONTROL_PLANE_IPS}; do
Scp / etc/kubernetes/pki/ca.crt "${USER}" @ $host:
Scp / etc/kubernetes/pki/ca.key "${USER}" @ $host:
Scp / etc/kubernetes/pki/sa.key "${USER}" @ $host:
Scp / etc/kubernetes/pki/sa.pub "${USER}" @ $host:
Scp / etc/kubernetes/pki/front-proxy-ca.crt "${USER}" @ $host:
Scp / etc/kubernetes/pki/front-proxy-ca.key "${USER}" @ $host:
Scp / etc/kubernetes/pki/etcd/ca.crt "${USER}" @ $host:etcd-ca.crt
Scp / etc/kubernetes/pki/etcd/ca.key "${USER}" @ $host:etcd-ca.key
Scp / etc/kubernetes/admin.conf "${USER}" @ $host:
Ssh ${USER} @ ${host} 'mkdir-p / etc/kubernetes/pki/etcd'
Ssh ${USER} @ ${host}'mv / ${USER} / ca.crt / etc/kubernetes/pki/'
Ssh ${USER} @ ${host}'mv / ${USER} / ca.key / etc/kubernetes/pki/'
Ssh ${USER} @ ${host}'mv / ${USER} / sa.pub / etc/kubernetes/pki/'
Ssh ${USER} @ ${host}'mv / ${USER} / sa.key / etc/kubernetes/pki/'
Ssh ${USER} @ ${host}'mv / ${USER} / front-proxy-ca.crt / etc/kubernetes/pki/'
Ssh ${USER} @ ${host}'mv / ${USER} / front-proxy-ca.key / etc/kubernetes/pki/'
Ssh ${USER} @ ${host}'mv / ${USER} / etcd-ca.crt / etc/kubernetes/pki/etcd/ca.crt'
Ssh ${USER} @ ${host}'mv / ${USER} / etcd-ca.key / etc/kubernetes/pki/etcd/ca.key'
Ssh ${USER} @ ${host}'mv / ${USER} / admin.conf / etc/kubernetes/admin.conf'
Done
7. Deployment on other nodes
# master
Kubeadm join 47.110.19.11 discovery-token-ca-cert-hash sha256:62579157003c3537deb44b30f652c500e7fa6505b5ef6826d796ba1245283899 6443-token qlrq5y.1yhm3rz9r7ynfqf1-discovery-token-ca-cert-hash sha256:62579157003c3537deb44b30f652c500e7fa6505b5ef6826d796ba1245283899-experimental-control-plane
# node
Kubeadm join 47.110.19.11 discovery-token-ca-cert-hash sha256:62579157003c3537deb44b30f652c500e7fa6505b5ef6826d796ba1245283899 6443-token qlrq5y.1yhm3rz9r7ynfqf1-discovery-token-ca-cert-hash sha256:62579157003c3537deb44b30f652c500e7fa6505b5ef6826d796ba1245283899