Build and Use a Kubernetes Cluster from Scratch

30 minutes
  • 5 Learning Objectives

About this Hands-on Lab

In this lab, you have been provided two servers. You will install and configure Kubernetes and configure it to use containerd for container management. You will need to initialize a Kubernetes cluster, add a network plugin, and add a Node to the cluster. Then, you will need to create a deployment file that starts three replicas of an Nginx image. Once you’re done, there is a provided script called `check-tasks.sh` that can be used to check that all tasks have been completed.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Log In to the Provided Servers

Log in to the servers as cloud_user with the provided passwords to ensure you can log in. When the file SERVER-READY is shown in the /home/cloud_user folder for both servers, you can follow along with the tasks.

Install Kubernetes and containerd and Create a Cluster
  • Your task for this objective is to install the Kubernetes repository, and then install Kubernetes.

  • You will use whatever system commands are required.

  • The repository file should be called /etc/yum.repos.d/kubernetes.repo.

  • The contents of the repo should be:

    [kubernetes]
    name=Kubernetes
    baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm- package-key.gpg
  • Next, install the three kubernetes programs.

  • Access the containerd repo.

  • You should replace the config.toml with a new default containerd configuration.

  • Using the required commands, enable and start containerd. Be sure to configure containerd to start automatically on a reboot.

  • Next, enable and start the kubelet. Be sure to configure the kubelet to start automatically on a reboot.

  • Use the relevant command to initialize the cluster. The network you should use is 172.16.0.0/16.

  • To set up your user, you will need to use the information output from the kubeadm init command that was run previously.

  • Apply the Calico network plugin.

Add the Worker Node to the Cluster
  • Add your worker Node to the cluster. You will need to use the information output from the kubeadm init command that was run previously.

  • Use the kubectl get nodes command to test that the worker Node has been added.

Create a Deployment File That Starts Three Replicas

You will create a deployment file called deployment-nginx.yml that starts three replicas, runs the Nginx image, and uses port 8080 for its output.

Check That the Deployment Started the Three Replicas
  • Using kubectl, create the deployment and check that the three replicas have started.

  • You can use a script in the home folder called check-tasks.sh to check that you have completed the tasks for this lab.

Additional Resources

Scenario

You have been told that it’s easy to install, configure, and run a deployment for Kubernetes. Your manager has provided you with two servers for this purpose and wants you to create a deployment that has three Nginx Pods running.

You will need to install Kubernetes and containerd, create a cluster, add a network plugin, and add a Node to the cluster.

Then, you will create a deployment file for use with Kubernetes that starts three replicas. This file will start Nginx in the cluster.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?