In this lab, you will build a cluster from scratch, as well as test the components of the cluster (including the deployments, pods, port forwarding, and services) and execute a command from within a pod. In order to build the Kubernetes cluster, we need to install the container runtime, as well as kubeadm, kubectl, and kubelet. We will then initialize the cluster, add our CNI, and add the nodes to the cluster.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Install a Three Node Cluster
- Get the gpg keys for Docker and Kubernetes and add it to your repository
- Install docker-ce, kubelet, kubeadm, and kubectl
- Initialize the cluster with the pod CIDR address
10.244.0.0/16
- Setup the local kubeconfig
- Apply the Calico CNI plugin
- Join the worker nodes to the cluster
- Create a Deployment
- On the master node, create a deployment named
ngnix
, using thenginx
image
- On the master node, create a deployment named
- Expose Port 80 on the Pod
- On the master node, forward the container port
80
to8081
- Open a new shell to the Kubernetes master and
curl
port8081
on localhost
- On the master node, forward the container port
- Get the NGINX version running on the pod
- In the original master node terminal, run the
nginx -v
command from inside the pod
- In the original master node terminal, run the
- Create a service, and verify connectivity on the node port
- In the original master node terminal, run the commands to expose the deployment and create a NodePort service
- Get the name of the node that the pod resides on
- Run the
curl
command to that node, using the port from the service, and verify connectivity