Difficulty: Basic Understanding of Kubernetes
Estimated Time: 15 minutes

Objective

The object of this scenarion is to demonstrate how use the MetalLB as a load balancer that will issue external IP addresses that for Kubernetes services that are configured to be of type, LoadBalancer.

Please be advised ...

This scenario preloads a multi-node Kubernetes cluster that is created using Kubernetes in Docker (KinD). There will be on control plane node and two worker nodes. When you might see the cluster spinning up when you view the teminal pane in Step 1. Be patient. It might take a few minutes for the cluster to spin up and load.

What you need to know to start

In order to get full benefit from taking this scenario, you need to have basic understanding of following Kubernetetes concepts:

This video describes the basics of Kubernetes you need to know:

Understanding MetalLB Load Balancing

Load Balancing is the method by which incoming network traffic is routed to a given server from among an array of multiple servers. Traffic is routed according to the server that is best available to accommodated the the request. A Load Balancer is used to ensure that traffic flow evenly at scale.

MetalLB is a Load Balancing product typically used for Kuberentes clusters hosted on bare metal machines. However, MetalLB works well to provide load balancing capabilties to Kubernetes in Docker (KinD) installations.

Contents

This scenarios is divided into the following steps.

  • Step 1 - Install the sipcalc utility
  • Step 2 - Install MetalLB
  • Step 3 - Determine an IP address range
  • Step 4 - Create the ConfigMap
  • Step 5 - Install the K8S Application
  • Step 6 - Access the K8S Application

Executing command line instructions

This scenario is completely interactive. The instructions you'll be given will be executed directly in the terminal window that is embedded directly in the Katacoda interactive learning environment. In the steps to come, when you see a command line instruction with a black background and check mark at the end, like so:

Katacoda command line

just click on it and the command will execute in the interative terminal window.

Click the START SCENARIO button to start.

Congratulations! You've completed the scenario, Load Balancing Kubernetes in Docker (KinD).

In this scenario you:

  • Installed the sipcalc utility
  • Installed MetalLB
  • Determined an IP address range
  • Created the ConfigMap for the Load Balancer
  • Installed the K8S Application
  • Accessed the K8S Application

Go to the Kubernetes web site to learn moare about Kubernetes.

Go the the Kubernetes in Docker web site to learn more about KinD.

Load Balancing Kubernetes in Docker (KinD)

Step 1 of 6

Installing the sipcalc utility

Before you start... beware

This scenario preloads a multi-node Kubernetes cluster that is created using Kubernetes in Docker (KinD). There will be on control plane node and two worker nodes. When you start out you might see the cluster spinning up in the teminal pane like so:

Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.19.1) 🖼
 ✓ Preparing nodes 📦 📦 📦
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹️
 ✓ Installing CNI 🔌
 ✓ Installing StorageClass 💾
 ✓ Joining worker nodes 🚜
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a nice day! 👋

Be patient. It might take a few minutes for the cluster to spin up.

Objective

The object of this step is to demonstration how to install the sipcalc utility.

As described in the sipcalc manual:

Sipcalc is an ip subnet calculator consisting of two parts. A plain text based console version, and web (cgi) based counterpart. This manpage only addresses the console based version. Sipcalc, in its simplest form takes an ip-address and a subnet mask on the commandline and outputs information about the subnet. Sipcalc has support for both IPv4 and IPv6 addresses.

You are going to use sipcalc to determine the range of IP addresses that MetalLB will use as the pool from external IP addresses will be assigned

Steps

Step 1: Confirm the Kubernetes cluster is up and running. Execute the following command:

kubectl get node -o wide

You'll see output similar to the following:

``` NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME kind-control-plane Ready master 2m59s v1.19.1 172.19.0.3 Ubuntu Groovy Gorilla (development branch) 4.4.0-185-generic containerd://1.4.0 kind-worker Ready 2m23s v1.19.1 172.19.0.2 Ubuntu Groovy Gorilla (development branch) 4.4.0-185-generic containerd://1.4.0 kind-worker2 Ready 2m23s v1.19.1 172.19.0.4 Ubuntu Groovy Gorilla (development branch) 4.4.0-185-gener

Step 2: Install sipcalc

sudo apt install sipcalc -y


Next: Installing MetalLB