Reader small image

You're reading from  Kubernetes – An Enterprise Guide - Second Edition

Product typeBook
Published inDec 2021
PublisherPackt
ISBN-139781803230030
Edition2nd Edition
Right arrow
Authors (2):
Marc Boorshtein
Marc Boorshtein
author image
Marc Boorshtein

Marc Boorshtein has been a software engineer and consultant for 20 years and is currently the CTO (Chief Technology Officer) of Tremolo Security, Inc. Marc has spent most of his career building identity management solutions for large enterprises, U.S. Government civilian agencies, and local government public safety systems.
Read more about Marc Boorshtein

Scott Surovich
Scott Surovich
author image
Scott Surovich

Scott Surovich has been involved in the industry for over 25 years and is currently the Global Container Engineering Lead at a tier 1 bank as the Global on-premises Kubernetes product owner architecting and, delivering cluster standards, including the surrounding ecosystem. His previous roles include working on other global engineering teams, including Windows, Linux, and virtualization.
Read more about Scott Surovich

View More author details
Right arrow

Deploying Kubernetes Using KinD

One of the largest obstacles to learning Kubernetes is having enough resources to create a cluster for testing or development. Like most IT professionals, we like to have a Kubernetes cluster on our laptops for demonstrations and for testing products in general.

Often, you may have a need to run a multiple node cluster, or multiple clusters for a complex demonstration or testing, such as a multi-cluster service mesh. These scenarios would require multiple servers to create the necessary clusters, which, in turn, would require a lot of RAM and a hypervisor.

To do full testing on a multiple cluster scenario, you would need to create multiple nodes for each cluster. If you created the clusters using virtual machines, you would need to have enough resources to run the virtual machines. Each of the machines would have an overhead including disk space, memory, and CPU utilization.

But what if you could create a cluster using just containers? Using...

Technical requirements

This chapter has the following technical requirements:

  • A Docker host installed using the steps from Chapter 1, Docker and Container Essentials
  • Installation scripts from this book's GitHub repository

You can access the code for this chapter by going to this book's GitHub repository: https://github.com/PacktPublishing/Kubernetes---An-Enterprise-Guide-2E/tree/main/chapter2.

We thought it was important to point out that this chapter will reference multiple Kubernetes objects, some without a lot of context. Chapter 3, Kubernetes Bootcamp, goes over Kubernetes objects in detail, many with commands you can use to understand them, so we thought having a cluster to use while reading about this would be useful.

Most of the base Kubernetes topics covered in this chapter will be discussed in future chapters, so if some topics may be a bit foggy after you've read this chapter, don't fear! They will be discussed...

Introducing Kubernetes components and objects

Since this chapter will refer to common Kubernetes objects and components, we wanted to provide a short table of terms that you will see and a brief definition of each to provide context.

In Chapter 3, Kubernetes Bootcamp, we will go over the components of Kubernetes and the base set of objects that are included in a cluster. We will also discuss how to interact with a cluster using the kubectl executable:

Table 2.1: Kubernetes components and objects

While these are only a few of the objects that are available in a Kubernetes cluster, they are the main objects we will mention in this chapter. Knowing what each resource is and having basic knowledge of their functionality will help you understand this chapter and deploy a KinD cluster.

Interacting with a cluster

To test our KinD installation, we will interact with the cluster using the kubectl executable. We will go over kubectl in Chapter 3, Kubernetes Bootcamp...

Using development clusters

Over the years, various tools have been created to install development Kubernetes clusters, allowing admins and developers to perform testing on a local system. Many of these tools worked for basic Kubernetes tests, but they often had limitations that made them less than ideal for quick, advanced scenarios.

Some of the most common solutions available are as follows:

  • Docker Desktop
  • Rancher Desktop
  • minikube
  • kubeadm
  • K3s

Each solution has benefits, limitations, and use cases. Some solutions limit you to a single node that runs both the control plane and worker nodes. Others offer multi-node support but require additional resources to create multiple virtual machines. Depending on your development or testing requirements, these solutions may not meet your needs completely.

It seems that a new solution is coming out every few weeks, and one of the newest options for creating development clusters is a project...

Installing KinD

The files for this chapter are located in the KinD directory. You can use the provided files, or you can create your own files from this chapter's content. We will explain each step of the installation process in this section.

At the time of writing, the current version of KinD is 0.11.0, supporting Kubernetes clusters up to 1.21.1

Installing KinD – prerequisites

KinD can be installed using a few different methods, but the easiest and quickest way to start building KinD clusters is to download the KinD binary and the standard Kubernetes kubectl executable to interact with the cluster.

Installing kubectl

Since KinD is a single executable, it does not install kubectl. If you do not have kubectl installed and you are using an Ubuntu 20.04 system, you can install it by running snap install, or you may download it from Google directly.

To install kubectl using snap, you only need to run a single command:

sudo snap install...

Creating a KinD cluster

Now that you have met all the requirements, you can create your first cluster using the KinD executable. The KinD utility can create a single-node cluster, as well as a complex cluster that's running multiple nodes for the control plane with multiple worker nodes. In this section, we will discuss the KinD executable options. By the end of the chapter, you will have a two-node cluster running – a single control plane node and a single worker node.

For the exercises in this book, we will install a multi-node cluster. The simple cluster configuration is an example and should not be used for our exercises.

Creating a simple cluster

To create a simple cluster that runs the control plane and a worker node in a single container, you only need to execute the KinD executable with the create cluster option.

Let's create a quick single-node cluster to see how quickly KinD creates a fast development cluster. On your host, create...

Reviewing your KinD cluster

With a Kubernetes cluster now available, we have the ability to look at Kubernetes objects first-hand. This will help you understand the next chapter, Kubernetes Bootcamp, where we will cover many of the base objects included in a Kubernetes cluster. While we will explain most objects in the next chapter, we need to introduce the objects that Kubernetes uses to provide storage. In the next section we introduce the objects included with KinD that provide persistent storage to your workloads. In particular, we will discuss the storage objects that are included with your KinD cluster.

KinD storage objects

Remember that KinD includes Rancher's auto-provisioner to provide automated persistent disk management for the cluster. Kubernetes has a number of storage objects, there is one object that the auto-provisioner does not require since it uses a base Kubernetes feature: it does not require a CSIdriver. Since the ability to use local host paths as...

Adding a custom load balancer for Ingress

This section is a complex topic that covers adding a custom HAProxy container that you can use to load balance worker nodes in a KinD cluster. You should not deploy these steps on the KinD cluster that we will use for the remaining chapters.

We added this section for anybody that may want to know more about how to load balance between multiple worker nodes.

KinD does not include a load balancer for worker nodes. The included HAProxy container only creates a configuration file for the API server; the team does not officially support any modifications to the default image or configuration. Since you will interact with load balancers in your everyday work, we wanted to add a section on how to configure your own HAProxy container in order to load balance between three KinD nodes.

First, we will not use this configuration for any of chapters in this book. We want to make the exercises available to everyone, so to limit...

Summary

In this chapter, you learned about the Kubernetes SIG project called KinD. We went into details on how to install optional components in a KinD cluster, including Calico as the CNI and NGINX as the Ingress controller. Finally, we covered the details of the Kubernetes storage objects that are included with a KinD cluster.

Hopefully, with the help of this chapter, you now understand the power that using KinD can bring to you and your organization. It offers an easy-to-deploy, fully configurable Kubernetes cluster. The number of running clusters on a single host is theoretically limited only by the host resources.

In the next chapter, we will dive into Kubernetes objects. We've called the next chapter Kubernetes Bootcamp since it will cover the majority of the base Kubernetes objects and what each one is used for. The next chapter can be considered a "Kubernetes pocket guide." It contains a quick reference to Kubernetes objects and what they do, as well...

Questions

  1. What object must be created before you can create a PersistentVolumeClaim?
    1. PVC
    2. Disk
    3. PersistentVolume
    4. VirtualDisk
  2. KinD includes a dynamic disk provisioner. Which company created the provisioner?
    1. Microsoft
    2. CNCF
    3. VMware
    4. Rancher
  3. If you created a KinD cluster with multiple worker nodes, what would you install to direct traffic to each node?
    1. Load balancer
    2. Proxy server
    3. Nothing
    4. Network load balancer
  4. True or false: A Kubernetes cluster can only have one CSIdriver installed.
    1. True
    2. False

Join our book's Discord space

Join the book's Discord workspace for a monthly Ask me Anything session with the authors:

https://packt.link/K8EntGuide

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Kubernetes – An Enterprise Guide - Second Edition
Published in: Dec 2021Publisher: PacktISBN-13: 9781803230030
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Authors (2)

author image
Marc Boorshtein

Marc Boorshtein has been a software engineer and consultant for 20 years and is currently the CTO (Chief Technology Officer) of Tremolo Security, Inc. Marc has spent most of his career building identity management solutions for large enterprises, U.S. Government civilian agencies, and local government public safety systems.
Read more about Marc Boorshtein

author image
Scott Surovich

Scott Surovich has been involved in the industry for over 25 years and is currently the Global Container Engineering Lead at a tier 1 bank as the Global on-premises Kubernetes product owner architecting and, delivering cluster standards, including the surrounding ecosystem. His previous roles include working on other global engineering teams, including Windows, Linux, and virtualization.
Read more about Scott Surovich