DISCLAIMER

I decided to not continue with this due to the huge implications that will be to redo everything not in the cloud. Basically, a lot of time should be invested and I miscalculated it by too much. Therefore, this will be probably the first and only post about these series.

Context

In order to practice for the CKA exam, it is recommended to perform the famous Kubernetes The Hard Way by Kelsey Hightower.

That guide is one of the best way to create a Kubernetes cluster by installing each component of them separatedly instead of using other tools like Kind, MiniKube, etc. which will create a K8s cluster without dealing about any complexity.

In this way, we can learn the componentes involved and how they really interact them.

As per writting this blog, the components will be:

Therefore, the Kubernetes the hard way guide will be my base to perform the Kubernetes cluster creation with all the componenrs or basically saying, I will do the “Kubernetes the hard way” a bit different :)

This is the first part of the series for the Kubernetes the hard way but on-prem. (Now discontinued)

Local infrastructure

Note: This post explains how I did it and I can be wrong in some parts, do it in the most comfortable way for you.

Here is the main point when it differs from the guide, we will do it with virtual machines (a.k.a. VMs) instead of using instances in the cloud, why?

Because I don’t want to setup a cloud account in GCP which will exceed the limits of the free tier (as it does in the guide) plus other concerns.

In this way, I can do it for free (with Virtual Box and with almost any Linux distribution) but it will require you to setup more things from the “nodes” (VMs) side.

A quick diagram of what I will have in the PC (3 VMs in the same network):

Let’s start with the infra

We basically need a hypervisor (type 2, as we’ll install it in our OS), 3 virtual machines (that will act as our nodes for the K8s cluster) with an operating system, configure them and then the Kubernetes hype can start.

The hypervisor

As easy as downloading Virtual Box (Oracle VM VirtualBox) and installing it in the flavour you want (I am using Debian 10).

Operating system for our nodes

For the OS, you can use whatever Linux distro you like the most, I am choosing Redhat 8 as months ago it was announced that CentOS 8 will be discontinued in 2022 and I wanted something that is widely used.

I’ll link soon a simple guide to install the OS within a VM and some tips.

Install the needed tools in your PC

Going through my own “hard way” for Kubernetes, I started directly here since I don’t need any SDK.

So here is how I did it the “Installing the Client Tools” part which differs from the version published in GKE.

As a reminder I am doing this in my PC with Debian 10 (buster).

Installing cfssl and cfssljson

  • Install CFSSL to provision the PKI infrastructure and generate TLS certificates:
$ sudo curl -s -L -o /bin/cfssl https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
$ sudo curl -s -L -o /bin/cfssljson https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
$ sudo curl -s -L -o /bin/cfssl-certinfo https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
$ sudo chmod +x /bin/cfssl*
$ sudo ls -lah /bin/ | grep cfssl          
-rwxr-xr-x.  1 root root 9.9M Aug 12 22:31 cfssl
-rwxr-xr-x.  1 root root 6.3M Aug 12 22:33 cfssl-certinfo
-rwxr-xr-x.  1 root root 2.2M Aug 12 22:31 cfssljson
  • Verifying that is installed correctly:
$ cfssl version
Version: 1.2.0
Revision: dev
Runtime: go1.6
$ cfssljson --help
Usage of cfssljson:
  -bare
    	the response from CFSSL is not wrapped in the API standard response
  -f string
    	JSON input (default "-")
  -stdout
    	output the response instead of saving to a file

Install kubectl

  • Install kubectl (command line utility) to interact with the Kubernetes API server.

We will install kubectl based in the official documentation:

$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

Validate the checksum as specified in the Kubernetes official documentation and proceed to install it:

$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Now verify the version to see if it’s working correctly:

$ kubectl version --client
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.0", GitCommit:"c2b5237ccd9c0f1d600d3072634ca66cefdf272f", GitTreeState:"clean", BuildDate:"2021-08-04T18:03:20Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}

Summary of tasks completed:

  • VMs (compute resources) ready.
  • Install CFSSL to provision the PKI infrastructure and generate TLS certificates
  • Install kubectl to interact with the Kubernetes API server

So this is the end of the first part.

We made some things in our future nodes and installed some tools that will be required for later.

In the next post I’ll continue with the Provisioning Compute Resources section based in the Kubernetes the Hard way tutorial