Step 6: Initializing the cluster
- Recap of the process and prerequisites deployed on each node.
- Initializing the cluster with kubeadm.
- Installing the Cilium CNI.
- kubectl aliases and taints to isolate nodes in the DMZ.
Legacy version of the Kubernetes cookbook
This article is part of the first version of the cookbook (VMware and PhotonOS). A new version, on XCP-ng and Rocky Linux, is being published: the initialization is detailed in Step 07 - Initializing the cluster (kubeadm init), Step 08 - Adding nodes (kubeadm join), and Step 09 - Networking and Cilium CNI. The article remains online for reference.
Introduction
Now is the time to start initializing the cluster. Before starting, it is important to review the process and actions already taken. Reading the previous articles in the Kubernetes Cook Book (Onprem) section is highly recommended to be comfortable with the next steps.
First, a working environment had to be created to operate a virtual infrastructure.
The idea was to minimize third-party dependencies and primarily use your workstation to interact with the target platform.
A minimal automation and industrialization approach was chosen using market tools, including:
- a first phase focused on Infrastructure as Code via OpenTofu (Terraform)
- a second phase focused on configuration with Ansible

Click the image to enlarge.

Click the image to enlarge.
Once the tooling was in place, we defined a K8S architecture target, specifying the number of nodes required and their respective roles.
Based on a VM template, it was possible to deploy, via OpenTofu, all the servers associated with this target architecture.
Next, an Ansible playbook was executed, described in various steps. This made it possible to install all the necessary prerequisites on each node and to prepare all the configuration files required for Kubernetes.
Launching kubeadm
As mentioned before, kubeadm was chosen to initialize the cluster. This is the default and most straightforward method for a standard Vanilla Kubernetes deployment.
Kubeadm needs to be run as the root user. Therefore, we will switch to that context on the first control plane, which is in the target architecture prdk8sctp501.
We will navigate to the /etc/kubernetes directory.

Click the image to enlarge.
Since this is where the Ansible playbook copied the kubeadm.conf file, here's its final content:
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
kubernetesVersion: 1.29.4
networking:
podSubnet: "10.11.0.0/16"
serviceSubnet: "10.12.0.0/16"
controlPlaneEndpoint: "kub.coolcorp.priv:6443"
clusterName: "kub"
controllerManager:
extraArgs:
cloud-provider: external
apiServer:
certSANs:
- 192.168.10.91
- kub.coolcorp.priv
The important things to remember are:
- The API version that kubeadm will use: kubeadm.k8s.io/v1beta3
- The Kubernetes version that will be deployed: 1.29.4
- The network that will be dedicated to the pods is: 10.11.0.0/16
- The network that will be dedicated to the services: 10.12.0.0/16
- The URL that will be associated with the API (and for which an internal certificate will be generated): kub.coolcorp.priv
Do not hesitate to read this article for a better understanding of this configuration.
Importance of the load balancer in the LAN
Before proceeding further, it is crucial that the HAProxy server, which acts as a load balancer within the local network (LAN), is operational: prdk8snlb501 in the target architecture. within the target architecture.
Located upstream of the cluster and responsible for distributing API access traffic across the three control planes, it must be online, responding to requests, and redirecting traffic.
When we invoke kubeadm, it will rely on the DNS name of the cluster and its IP address (192.168.10.91), which are associated with the HAproxy server and not directly with the control plane.
Therefore, the resolution must be correct and point to the load balancer. The HAproxy service must be running, and its configuration must be operational to forward requests on port 6443 to one of the control planes.
The details of this configuration are available here.
Execution on the first control plane
If all the indicators are green at this stage, we can proceed to deploy the first control plane of the cluster (in the target architecture, the first control plane is prdk8sctp501) using the following command:
kubeadm init --config kubeadm.conf --upload-certs --v=5 --skip-phases=addon/kube-proxy.
--config kubeadm.conf: This instruction allows kubeadm to start the initialization phase using the parameters provided in the kubeadm.conf file.
–v=5: This enables more verbose output to aid in troubleshooting if necessary.
--skip-phases=addon/kube-proxy: This allows you to avoid installing the kube-proxy addon, which is usually installed by default. This is specific to how we will use the Cilium network driver. In our case, Cilium will handle the functions that are normally handled by kube-proxy. Even though Cilium can be used with kube-proxy, this method allows you to fully leverage the features of Cilium.
Kubernetes relies on components, which mostly run as containers.
The installation may take some time, typically around ten minutes. During this time, Kubeadm will download the images for each container and generate their associated configurations.
All of these configurations will be located in /etc/kubernetes/manifests. They can then be used by the kubelet agent, which, as you may recall, was installed previously using Ansible.
The Kubelet agent is responsible for starting all of the containers described in this directory and whose images were downloaded by kubeadm. This directory is constantly monitored by the kubelet agent, and any changes at this level will be reflected in the cluster.
This is how the basic components of the cluster can start without external interaction.
Kubeadm also ensures that these components are started correctly and are accessible, especially the API server (which highlights the importance of HAproxy working properly beforehand).
If everything goes well, at the end of the process, you will get the commands needed to configure the other nodes so that they can join the cluster.

Click the image to enlarge.
Execution on the other control planes
Be careful, the command is different depending on whether you want to add a control plane or just a simple worker node.
Similarly, these commands have a lifespan of one hour. After this time, the generated tokens expire, and you will need to request new association instructions from the primary control plane to obtain new instructions.
We continue with the other two control planes (prdk8sctp502 / prdk8sctp503). To do this, there is nothing complicated; we connect as root to each of them and copy the command that was retrieved on the first control plane. There is no need for a configuration file; kubeadm will directly try to contact the first node and generate the necessary configuration.

Click the image to enlarge.
It is highly recommended to proceed node by node, and to wait for the operation to be successful before moving on to the next server.

Click the image to enlarge.
During these steps, the new control planes will be added to the cluster and registered as participants in the consensus process, particularly for the key/value database etcd.

Click the image to enlarge.

Click the image to enlarge.
All of the configuration for a K8S cluster is maintained in this database. It therefore becomes critical, because every action you perform subsequently will result in an update to this database, which will contain the desired state regarding the execution of pods.
K8S continuously compares the contents of this database with the current status of the cluster to ensure that its content corresponds to what is being executed on the cluster.
In fact, because of etcd, a minimum of 3 control planes are required to provide a highly available service, as it is etcd, via the RAFT consensus protocol, that imposes this minimum number.
Note that it is possible to externalize the etcd database outside of the cluster in order to create an independent architecture. You can also use a different database than etcd. The important thing is that the API server can communicate with this database (and be compatible).
In our case, we will stick to the traditional approach and keep etcd as an internal component of the cluster. We will ensure its backup in a dedicated article.
Once the three control planes are associated, we proceed with the standard nodes.
Execution on the standard nodes
The command is slightly different and much faster. Simply connect as root on each node (prdk8snod501(worker LAN) / prdk8snod502(worker LAN) / prdk8snod511(worker DMZ) / prdk8snod511(worker DMZ)) and copy the output dedicated to the worker, which was generated during the cluster initialization on the first control plane.

Click the image to enlarge.

Click the image to enlarge.

Click the image to enlarge.

Click the image to enlarge.

Click the image to enlarge.
The only subtlety is to ensure proper communication between the nodes. This is particularly important for nodes in the DMZ. In my case, I use an intermediate firewall (OPNsense), and it is crucial that a certain number of flows are open.
Here is an excerpt from the configuration of my firewall between the DMZ and the LAN on my side.

Click the image to enlarge.
Note that a matrix of flows is presented in this article (presentation of iptables rules positioned by Ansible).
Retrieving the configuration file for kubectl
At this stage, all servers have joined the cluster, but it remains to retrieve the kubectl configuration file generated during the installation on the first control plane.
As a reminder, kubectl is the basic command-line interface for communicating with and managing the cluster.
When kubeadm initializes the cluster, it also creates the admin.conf file, which is the file used to connect to the cluster as an administrator. It contains the API URL and, most importantly, the connection credentials in the form of a private/public key pair, allowing you to interact with the cluster as an admin.
This is an extremely critical file that should never be removed from the server. It's best to generate new files specific to a given identity, with specific permissions for use on other connection sources, such as a workstation.
However, in order to continue the cluster installation, we need to retrieve this file and apply it to our current user to proceed.
The output from kubeadm at the end of the installation on each control plane provides you with the associated commands. You can focus solely on the first control plane (to be executed as root).

Click the image to enlarge.
Since my local user is "bvivi57" in this example, I need to apply the following lines.
cp -i /etc/kubernetes/admin.conf /home/bvivi57/.kube/config
chown -R bvivi57 /home/bvivi57/.kube/

Click the image to enlarge.
From here, you should:
- no longer need to connect to other nodes except for the first control plane.
- no longer need to connect as root except for update operations.
We are now back to the current user.
Now we can finally type our first kubectl command to check the status of the nodes
kubectl get node

Click the image to enlarge.
We have all the nodes, but they are all in NotReady state. This is normal. As a reminder, K8S is a modular platform that gives you a wide choice in the architecture to deploy. With kubeadm, we only deployed the basic components, but we are missing the network layer.
Installing Cilium
This layer must be compatible with CNI (feel free to take a look here to fully understand) which is the standard that a network driver must adhere to in order to integrate with a Kubernetes cluster.
There are several options, but Cilium was chosen. It's the most popular solution at the time of writing this article (but trends often change, so it's important to choose a CNI that suits your needs).
Based on the Linux kernel eBPF technology, it offers a wide range of advanced features, especially for filtering and tracking network traffic.
Because we have dedicated Ansible tasks to it, all of its configuration has already been prepared and is available in the current user's directory ~/kub.coolcorp.priv/network/ (kub.coolcorp.priv was set as a variable in Ansible as the storage directory for configurations; this remains an example).

Click the image to enlarge.
The final content of the cilium-values.yaml file is as follows:
kubeProxyReplacement: strict
k8sServiceHost: 192.168.10.91
k8sServicePort: 6443
ipam:
mode: "cluster-pool"
operator:
clusterPoolIPv4PodCIDRList:
- "10.13.0.0/16"
hubble:
relay:
enabled: true
ui:
enabled: true
frontend:
server:
ipv6:
enabled: false
tls:
auto:
enabled: true
method: helm
certValidityDuration: 1095
It includes the network 10.13.0.0/16, which we will dedicate to Cilium, as well as other parameters, such as the API IP address of the cluster (i.e., the HAproxy server's IP address). We will also indicate that we want to enable certain features, including the Hubble GUI, which we will use later.
Installing Cilium is possible in several ways, but as you can read in the configuration file, we will be using Helm.
As a reminder, Helm is a package manager for Kubernetes. It simplifies application deployment by retrieving the necessary configuration files directly from repositories to install software on a Kubernetes cluster, without you having to worry about the various objects involved.
Personally, I use Helm sparingly. It's very useful, but because it hides its actions, we are not always certain that the deployed tool functions according to our needs.
Helm uses a default configuration, which can be obtained with the command helm show values nom_apps.
I always recommend checking the content of the default settings before performing operations with Helm.
If this does not suit you, it is always possible to override it with your own configuration. This is what we will do here using the cilium-values.yaml file
Before being able to deploy Cilium, we must first add its Helm repository (as a reminder, the Helm command was added during the Ansible actions).
helm repo add cilium https://helm.cilium.io/
We ensure that the repository is up to date.
helm repo update

Click the image to enlarge.
You can check out of curiosity the default configuration used by Helm to deploy Cilium.
helm show values cilium/cilium

Click the image to enlarge.
The file is very large because Cilium can take a lot of parameters.
We will stick with our configuration and proceed directly to the installation using the command
helm install --version 1.15.4 --namespace=kube-system cilium cilium/cilium --values=./cilium-values.yaml --set hubble.relay.enabled=true --set hubble.ui.enabled=true

Click the image to enlarge.
This instruction tells Helm to deploy Cilium version 1.15.4 in the namespace kube-system, using our configuration file.
The namespace kube-system is the most critical namespace of the cluster, since it contains the core of the system. We avoid touching it (in fact, in the "Kubernetes as a service" offerings of cloud providers, it is usually not even accessible). In Cilium's case, it is not an aberration for it to be deployed there.
You can see the pods associated with Cilium being added using the following command:
kubectl get pod -n kube-system
In addition to the basic Kubernetes components, you can clearly see the components specific to Cilium. For a successful installation, all of them must be running (this may take several minutes after the helm command returns).

Click the image to enlarge.
If all components are operational, you can recheck the status of the nodes.
kubectl get node

Click the image to enlarge.
All of them are now in a ready state. This is largely due to the fact that, thanks to the deployment of the network layer, the internal DNS for the cluster is now up (you can see it in the namespace kube-system).
To ensure that Cilium is fully operational, you can use the Cilium CLI, which we deployed during the Ansible playbook.
cilium status –wait

Click the image to enlarge.
All should be green.
It is even possible to perform more in-depth tests using the command cilium connectivity test, but in this case, it may take a very long time because many things are being evaluated.
Note that Cilium can also be installed with the CLI, but in that case, you should not use helm. You should never mix installation methods. In our case, the CLI is only used for diagnostic purposes; if Cilium needs to be updated tomorrow, Helm is what you will need to use.
The ultimate test is to launch the Cilium GUI. Currently, it is not yet exposed with an ingress, for example, but it is already possible to access it.
To do this, you will need to perform on your workstation what I mentioned earlier that you should not do...
But let's say it's only for testing purposes.
Retrieve the contents of the kubectl configuration file and copy it to your workstation. In the case of a Windows operating system, kubectl can be installed in several ways, all described here.
The important thing is to remember a version that is compatible with your cluster. It is possible to choose a higher version up to a limit of 2. In my example, the cluster was deployed with version 1.29, so you can use kubectl version 1.30.
Once the binary is installed on the machine, its configuration is located in the user profile, specifically under Windows in C:\Users\mon_user\.kube

Click the image to enlarge.
Simply create a config file (without an extension) that contains exactly what is in the ~/.kube/config file from the first control plane we retrieved earlier.
As a reminder, this content is very sensitive because it allows administrative access to the cluster. Normally, it should only be used for very specific administration tasks.
Regardless, this should now allow you to interact with the cluster as an administrator directly from your workstation (you can test the kubectl get node command to verify that the connection is working).
We can now try to launch the Cilium UI using the following command:
kubectl port-forward -n kube-system svc/hubble-ui 12000:80

Click the image to enlarge.
We won't go into detail at this level, but this command will map port 12000 on your machine to port 80 of the hubble-ui service within the cluster, which exposes the UI on port 80.
In this way, by typing http://127.0.0.1:12000/ in your browser, you can access the Cilium UI

Click the image to enlarge.

Click the image to enlarge.
Once you have confirmed that you can access it, you can terminate the command.
Setting up aliases and taints
Before we conclude, let's finish with two small operations.
Remember that in the target architecture, we have nodes on both the LAN and in the DMZ.
It will be important to differentiate them for better readability.
So, let's start by adding labels.
The following commands can be run from your workstation if the kubectl config file is still present (which is not ideal) or on the first control plane in the standard user context:
kubectl label node prdk8snod511 node-role.kubernetes.io/worker-dmz=
kubectl label node prdk8snod511 network=dmz
kubectl label node prdk8snod512 node-role.kubernetes.io/worker-dmz=
kubectl label node prdk8snod512 network=dmz
kubectl label node prdk8snod501 network=lan
kubectl label node prdk8snod501 node-role.kubernetes.io/worker-lan=
kubectl label node prdk8snod502 network=lan
kubectl label node prdk8snod502 node-role.kubernetes.io/worker-lan=

Click the image to enlarge.
If we run a kubectl get node again, we no longer have any details in the role.

Click the image to enlarge.
But that's not enough. In addition to simply labeling the nodes, we also want to set execution constraints to prevent an application intended for the LAN from ending up in the DMZ, and vice versa.
I won't go into detail right now, but to do this, we will "taint" or mark our nodes (in French).
In this way, we can later configure our application deployments so that they either "tolerate" or do not tolerate the marks placed on the nodes.
kubectl taint nodes prdk8snod511 node-role.kubernetes.io/worker-dmz=:NoSchedule
kubectl taint nodes prdk8snod512 node-role.kubernetes.io/worker-dmz=:NoSchedule

Click the image to enlarge.
We will apply this restriction only to the nodes in the DMZ. In essence, the commands above will prevent the "scheduling", that is, the execution of a pod, unless it is explicitly configured to support the "worker-dmz" taint.
In this way, if nothing is specified, no pod will ever be launched on a node in the DMZ. It must be explicitly configured for this to happen; thus, we avoid the most critical security situation, which is inadvertently exposing an internal application to the outside.
Conclusion
We now have a fully operational cluster.
All basic components are deployed, and we can now run applications on it. However, in our case, and in accordance with our initial goal, we will also install additional components, such as a storage driver to utilize VMware datastores, and an ingress controller, Traefik, to simplify the exposure of our resources… but that's for later.