(K8s) Kubernetes lab 101 Building single master cluster

access_time12 mins remaining
(K8s) Kubernetes lab 101 Building single master cluster

About this Lab

subjectLast updated Oct 20, 2021
account_circleWritten by www.ShareLearn.net

1. Overview

image

In this lab we will practice building Kubernetes cluster with single master

2. Demo

In case you prefer a video, check below our YouTube video for this lab

3. Create docker hub account.

Create docker hub account. Docker Hub skip this step if you already have one

image

4. Open Play with Kubernetes

Open Play with Kubernetes

image

login with your docker hub account.

imageClick on start imageIt will start a 4 hr session image

5. Add new instance

click on + ADD NEW INSTANCE

imagecomment]: ![screenshot}}

6. Initialize Kubernetes cluster with kubeadm

Enter below command in first node terminal

This node will be master for this cluster

kubeadm init --apiserver-advertise-address $(hostname -i) --pod-network-cidr 10.5.0.0/16

use kudeadm to initialize Kubernetes cluster

–apiserver-advertise-address is to advertise api server address

–pod-network-cidr is to provide subnet used for pod network

this command will pull container images required for Kubernetes cluster and may take sometime

you may load image proactively by using kubeadm config images pull

you may also select specific version with –kubernetes-version

take note of output similar to below, it will be required for other nodes to join cluster

kubeadm join XXXXXXX — token XXXXXX — discovery-token-ca-cert-hash sha256:XXXXXXXXX

image

7. Check node status

Enter below command in master node terminal

kubectl get nodes

use above command to display nodes in k8s cluster there will be only master node with status NotReady

node is NotReady as there is no networking add-on

image

8. Deploy CNI

CNI stand for Container Network Interface,

It is a Cloud Native Computing Foundation project, consists of a specification and libraries for writing plugins to configure network interfaces in Linux containers, along with a number of plugins.

Kubernetes uses CNI as an interface between network providers and Kubernetes pod networking

Enter below command in master node terminal

kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml

this command will get yaml file from github

install network add-on to cluster

We will discuss CNI in future labs

image

9. Check node status

Enter below command in master node terminal

kubectl get nodes

node will be in ready state after few minutes

image

10. Create Second node

click on + ADD NEW INSTANCE

image

11. Add Second node to cluster

Enter kubeadm join command in new node terminal on Second node

kubeadm join XXXXXXX  token XXXXXX  discovery-token-ca-cert-hash sha256:XXXXXXXXX

above command will join new node to cluster

this command will be different for you

you will get this from step 5

image

12. Check Node status

Enter below command in master node terminal

kubectl get nodes
imageyou will see two nodes

one master and second with none role

second node might be NotReady at first

it could take few minutes to get Ready

13. Create Third node

click on + ADD NEW INSTANCE

image

14. Add Third node to cluster

Enter kubeadm join command in new node terminal

kubeadm join XXXXXXX  token XXXXXX  discovery-token-ca-cert-hash sha256:XXXXXXXXX

copy above command will join new node to cluster

this command will be different for you

you will get this from step 5

image

15. Check node status

Enter below command in master node terminal

kubectl get nodes

you will see three nodes

one master two with none role

third node might be NotReady at first

it could take few minutes to get Ready

image

16. Cleanup

Delete all open nodes/instances and close session

  1. Select the node and click on DELETE
  2. Repeat same for any other open nodes
  3. click close session

cleanup}}


17. Conclusion

Click on ‘Submit Feedback’ on the bottom left of the page to submit any questions/feedback.
bug_report Submit feedback