Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docker_advanced_k8s_init [2020/05/01 13:46] – andonovj | docker_advanced_k8s_init [2020/05/02 14:13] (current) – andonovj | ||
---|---|---|---|
Line 1: | Line 1: | ||
=====Overview===== | =====Overview===== | ||
- | The master instance is the main instance which controls the applications or the containers on the cluster. Don't forget: kubernetes consists of at least 1 master and 2 node. In total 2 machines which can run the application. | + | The master instance is the main instance which controls the applications or the containers on the cluster. Don't forget, in our case, kubernetes consists of at least 1 master and 2 node. In total 2 machines which can run the application. |
So let's initialize the cluster from the master instance: | So let's initialize the cluster from the master instance: | ||
Line 94: | Line 94: | ||
====Configure Calico Pod Network==== | ====Configure Calico Pod Network==== | ||
- | So which podnetwork, we will use. As already mentioned if you are using Kubernetes >1.16, then you cannot use the weave network. Because of that I have used the Calico: | + | So which podnetwork, we will use. As already mentioned if you are using Kubernetes >1.16, then you cannot use the weave network. Because of that I had to use Calico: |
< | < | ||
Line 162: | Line 162: | ||
That concludes the initialization of the cluster. In the next section we will discuss how to add new nodes :) | That concludes the initialization of the cluster. In the next section we will discuss how to add new nodes :) | ||
+ | |||
+ | =====Joint to the cluster===== | ||
+ | Be sure that you installed the necessary packages from the introduction section. Once this is done we can add the node to the cluster as follow: | ||
+ | |||
+ | < | ||
+ | root@node-1: | ||
+ | W0421 10: | ||
+ | [preflight] Running pre-flight checks | ||
+ | [WARNING IsDockerSystemdCheck]: | ||
+ | [preflight] Reading configuration from the cluster... | ||
+ | [preflight] FYI: You can look at this config file with ' | ||
+ | [kubelet-start] Downloading configuration for the kubelet from the " | ||
+ | [kubelet-start] Writing kubelet configuration to file "/ | ||
+ | [kubelet-start] Writing kubelet environment file with flags to file "/ | ||
+ | [kubelet-start] Starting the kubelet | ||
+ | [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap... | ||
+ | |||
+ | This node has joined the cluster: | ||
+ | * Certificate signing request was sent to apiserver and a response was received. | ||
+ | * The Kubelet was informed of the new secure connection details. | ||
+ | |||
+ | Run ' | ||
+ | |||
+ | root@node-1: | ||
+ | </ | ||
+ | |||
+ | As with the master node, it might take sometime until you see the node as Ready and all components running from the Control Panel Machine: | ||
+ | |||
+ | < | ||
+ | ubuntu@k8s-master: | ||
+ | NAME | ||
+ | k8s-master | ||
+ | node-1 | ||
+ | ubuntu@k8s-master: | ||
+ | ubuntu@k8s-master: | ||
+ | NAMESPACE | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | </ | ||
+ | |||
+ | Please execute that step on all nodes. In the end you should have something like this: | ||
+ | |||
+ | < | ||
+ | ubuntu@k8s-master: | ||
+ | NAME | ||
+ | k8s-master | ||
+ | node-1 | ||
+ | node-2 | ||
+ | ubuntu@k8s-master: | ||
+ | NAMESPACE | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | kube-system | ||
+ | </ | ||
+ | |||
+ | ====Assign role to a Node==== | ||
+ | You saw that our nodes have no roles. We have 1 master and that is that :) | ||
+ | |||
+ | < | ||
+ | ubuntu@k8s-master: | ||
+ | NAME | ||
+ | k8s-master | ||
+ | node-1 | ||
+ | node-2 | ||
+ | </Code | ||
+ | |||
+ | So, how to assign roles to the node. Well, in Kubernetes, we assign labels. Labels are assigned as follows: | ||
+ | |||
+ | < | ||
+ | kubectl label node <node name> node-role.kubernetes.io/< | ||
+ | kubectl label node <node name> node-role.kubernetes.io/< | ||
+ | </ | ||
+ | |||
+ | So let's assign worker to our node-1 and node-2 | ||
+ | |||
+ | < | ||
+ | ubuntu@k8s-master: | ||
+ | node/node-1 labeled | ||
+ | ubuntu@k8s-master: | ||
+ | node/node-2 labeled | ||
+ | ubuntu@k8s-master: | ||
+ | NAME | ||
+ | k8s-master | ||
+ | node-1 | ||
+ | node-2 | ||
+ | ubuntu@k8s-master: | ||
+ | </ | ||
+ | |||
+ | Alternatively we can remove a label from a node. So let's remove and add that label again on Node-2: | ||
+ | |||
+ | < | ||
+ | ubuntu@k8s-master: | ||
+ | node/node-2 labeled | ||
+ | ubuntu@k8s-master: | ||
+ | NAME | ||
+ | k8s-master | ||
+ | node-1 | ||
+ | node-2 | ||
+ | ubuntu@k8s-master: | ||
+ | node/node-2 labeled | ||
+ | ubuntu@k8s-master: | ||
+ | NAME | ||
+ | k8s-master | ||
+ | node-1 | ||
+ | node-2 | ||
+ | ubuntu@k8s-master: | ||
+ | </ | ||
+ |