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.
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.
Visit DockerHub to sign up for an account. The page should be similar to Figure 2-1.
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.
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.
Visit the GitHub web page to sign up for an account. The page should be similar to Figure 2-3.
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.
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.
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.
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
Another popular Git service is GitLab. It can be used on the cloud or installed on-premises.
Visit GitLab for more information.
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.
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.
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.
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).
Run the following command in a terminal window to spin up the Kubernetes cluster with 8 GB of memory assigned:
Creates a Kubernetes cluster with version 1.23.0
Uses VirtualBox as virtualization tool
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
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
...
▪
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.
▪
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
Starts the gitops
cluster
Boots up the Kubernetes cluster control plane
Detects that we have an old kubectl
tool
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.
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.
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.
3.238.82.77