Setting up the first master

First, we are going to set up a master, ready for the HA environment. Like the initial step, running a cluster by using kubeadm, it is important to enable and start kubelet on the master at the beginning. It can then take daemons running as pods in the kube-system namespace:

// you are now in the terminal of host for first master
$ sudo systemctl enable kubelet && sudo systemctl start kubelet

Next, let's start the master services with the custom kubeadm configuration file:

$ cat custom-init-1st.conf
apiVersion: kubeadm.k8s.io/v1alpha1
kind: MasterConfiguration
api:
advertiseAddress: "<FIRST_MASTER_IP>"
etcd:
endpoints:
- "<ETCD_CLUSTER_ENDPOINT>"
apiServerCertSANs:
- "<FIRST_MASTER_IP>"
- "<SECOND_MASTER_IP>"
- "<LOAD_BALANCER_IP>"
- "127.0.0.1"
token: "<CUSTOM_TOKEN: [a-z0-9]{6}.[a-z0-9]{16}>"
tokenTTL: "0"
apiServerExtraArgs:
endpoint-reconciler-type: "lease"

This configuration file has multiple values required to match your environment settings. The IP ones are straightforward. Be aware that you are now setting the first master; the <FIRST_MASTER_IP> variable will be the physical IP of your current location. <ETCD_CLUSTER_ENDPOINT> will be in a format like "http://<IP>:<PORT>", which will be the load balancer of the etcd cluster. <CUSTOM_TOKEN> should be valid in the specified format (for example, 123456.aaaabbbbccccdddd). After you allocate all variables aligning to your system, you can run it now:

$ sudo kubeadm init --config=custom-init-1st.conf

You may get the Swap is not supported error message. Add an additional --ignore-preflight-errors=Swap flag with kubeadm init to avoid this interruption.

Make sure to update in both files of the masters. 

We need to complete client functionality via the following commands:

$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

Like when running a single master cluster via kubeadm, without a container network interface the add-on kube-dns will always have a pending status. We will use CNI Calico for our demonstration. It is fine to apply the other CNI which is suitable to kubeadm:

$ kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml

Now it is OK for you to add more master nodes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.231.15