Chapter 2. Requirements

This book is about GitOps and Kubernetes, and as such, you’ll need a container registry to publish the containers built throughout the book (see Recipe 2.1).

Also, a Git service is required to implement GitOps methodologies; you’ll learn how to register to public Git services like GitHub or GitLab (see Recipe 2.2).

Finally, it would be best to have a Kubernetes cluster to run the book examples. Although we’ll show you how to install Minikube as a Kubernetes cluster (see Recipe 2.3), and the book is tested with Minikube, any Kubernetes installation should work as well.

Let’s prepare your laptop to execute the recipes provided in this book.

2.1 Registering for a Container Registry

Problem

You want to create an account for a container registry service so you can store generated containers.

Solution

You may need to publish some containers into a public container registry as you work through this book. Use Docker Hub (docker.io) to publish containers.

If you already have an account with docker.io, you can skip the following steps. Otherwise, keep reading to learn how to sign up for an account.

Discussion

Visit DockerHub to sign up for an account. The page should be similar to Figure 2-1.

DockerHub registration page
Figure 2-1. DockerHub registration page

When the page is loaded, fill in the form by setting a Docker ID, Email, and Password, and click the Sign Up button.

When you are registered and your account confirmed, you’ll be ready to publish containers under the previous step’s Docker ID.

See Also

Another popular container registry service is quay.io. It can be used on the cloud (like docker.io) or installed on-premises.

Visit the website to get more information about Quay. The page should be similar to Figure 2-2.

Quay registration page
Figure 2-2. Quay registration page

2.2 Registering for a Git Repository

Problem

You want to create an account for a Git service so you can store source code in a repository.

Solution

You may need to publish some source code into a public Git service in this book. Use GitHub as a Git service to create and fork Git repositories.

If you already have an account with GitHub, you can skip the following steps, otherwise keep reading to learn how to sign up for an account.

Discussion

Visit the GitHub web page to sign up for an account. The page should be similar to Figure 2-3.

GitHub welcome page to register
Figure 2-3. GitHub welcome page to register

When the page is loaded, click the Sign up for GitHub button (see Figure 2-3) and follow the instructions. The Sign in page should be similar to Figure 2-4.

Sign in GitHub page
Figure 2-4. Sign In GitHub page

When you are registered and your account confirmed, you’ll be ready to start creating or forking Git repositories into your GitHub account.

Also, you’ll need to fork the book source code repository into your account. Click the Fork button shown in Figure 2-5.

Fork button
Figure 2-5. Fork button

Then select your account in the Owner section, if not selected yet, and click the button “Create fork” button as shown in Figure 2-6.

Create Fork button
Figure 2-6. Create fork button

To follow along with the example in the following chapters, you can clone this book’s repositories locally. When not mentioned explicitly, we will refer to the examples available in the chapters repo:

git clone https://github.com/gitops-cookbook/chapters

See Also

Another popular Git service is GitLab. It can be used on the cloud or installed on-premises.

Visit GitLab for more information.

2.3 Creating a Local Kubernetes Cluster

Problem

You want to spin up a Kubernetes cluster locally.

Solution

In this book, you may need a Kubernetes cluster to run most recipes. Use Minikube to spin up a Kubernetes cluster in your local machine.

Discussion

Minikube uses container/virtualization technology like Docker, Podman, Hyperkit, Hyper-V, KVM, or VirtualBox to boot up a Linux machine with a Kubernetes cluster installed inside.

For simplicity and to use an installation that will work in most of the platforms, we are going to use VirtualBox as a virtualization system.

To install VirtualBox (if you haven’t done it yet), visit the home page and click the Download link as shown in Figure 2-7.

Note

For those using macOS, the following instructions have been tested on a Mac AMD64 with macOS Monterey and VirtualBox 6.1. At the time of writing this book, there were some incompatibilities when using the ARM version or macOS Ventura.

gocb 0208
Figure 2-7. VirtualBox home page

Select the package based on the operating system, download it, and install it on your computer. After installing VirtualBox (we used the 6.1.x version), the next step is to download and spin up a cluster using Minikube.

Visit the GitHub repo, unfold the Assets section, and download the Minikube file that matches your platform specification. For example, in the case of an AMD Mac, you should select minikube-darwin-amd64 as shown in Figure 2-8.

Uncompress the file (if necessary) and copy it with the name minikube in a directory accessible by the PATH environment variable such as (/usr/local/bin) in Linux or macOS.

With VirtualBox and Minikube installed, we can spin up a Kubernetes cluster in the local machine. Let’s install Kubernetes version 1.23.0 as it was the latest version at the time of writing (although any other previous versions can be used as well).

gocb 0209
Figure 2-8. Minikube release page

Run the following command in a terminal window to spin up the Kubernetes cluster with 8 GB of memory assigned:

minikube start --kubernetes-version='v1.23.0' /
--driver='virtualbox' --memory=8196 -p gitops 1 2 3
1

Creates a Kubernetes cluster with version 1.23.0

2

Uses VirtualBox as virtualization tool

3

Creates a profile name (gitops) to the cluster to refer to it later

The output lines should be similar to:

[gitops] Minikube v1.24.0 on Darwin 12.0.1
 Using the virtualbox driver based on user configuration
Starting control plane node gitops in cluster gitops 1
Creating virtualbox VM (CPUs=2, Memory=8196MB, Disk=20000MB) ...
    > kubeadm.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubelet.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubeadm: 43.11 MiB / 43.11 MiB [---------------] 100.00% 3.46 MiB p/s 13s
    > kubectl: 44.42 MiB / 44.42 MiB [---------------] 100.00% 3.60 MiB p/s 13s
    > kubelet: 118.73 MiB / 118.73 MiB [-------------] 100.00% 6.32 MiB p/s 19s

     Generating certificates and keys ...
     Booting up control plane ... 2
     Configuring RBAC rules ...
     Using image gcr.io/k8s-minikube/storage-provisioner:v5
...

  Verifying Kubernetes components...
Enabled addons: storage-provisioner, default-storageclass

 /usr/local/bin/kubectl is version 1.21.0, which
may have incompatibilites with Kubernetes 1.23.0. 3
     Want kubectl v1.23.0? Try 'minikube kubectl -- get pods -A'
Done! kubectl is now configured to use "gitops" cluster and
 "default" namespace by default 4
1

Starts the gitops cluster

2

Boots up the Kubernetes cluster control plane

3

Detects that we have an old kubectl tool

4

Cluster is up and running

To align the Kubernetes cluster and Kubernetes CLI tool version, you can download the kubectl 1.23.0 version running from https://dl.k8s.io/release/v1.23.0/bin/darwin/amd64/kubectl.

Note

You need to change darwin/amd64 to your specific architecture. For example, in Windows it might be windows/amd64/kubectl.exe.

Copy the kubectl CLI tool in a directory accessible by the PATH environment variable such as (/usr/local/bin) in Linux or macOS.

See Also

There are other ways to run Kubernetes in a local machine.

One that is very popular is kind.

Although the examples in this book should work in any Kubernetes implementation as only standard resources are used, we’ve only tested with Minikube.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.138.89