Day 2: Discovering Kubernetes and Setting Up Your First Cluster for the CKA Certification
Kubernetes is the most widely used tool for orchestrating containers in Cloud Native and DevOps environments. It enables the management of application deployments while ensuring scalability, resilience, and optimized resource management. To lay a solid foundation for the CKA certification, it is essential to understand Kubernetes architecture and learn to configure your own cluster. This will help you master its components, practice and experiment, and meet the exam requirements.
In this article, we will cover the fundamentals of Kubernetes and its use. You will learn to configure a Multi-node cluster with Kind, install and use the Kubernetes client, kubectl, and execute your first commands to interact with a cluster. These skills are an important first step in preparing for the certification.
Day 2
Welcome to the second step of your journey towards the Certified Kubernetes Administrator (CKA) certification. In this article, we will explore:
- The architecture of Kubernetes and the role of its main components.
- The specifics of the CKA exam, including available resources and the Kubernetes version used.
- The setup of a Multi-node cluster with Kind and the use of the kubectl tool.
- Initial practical commands to interact with your Kubernetes cluster.
As with Day 1, this tutorial is designed to combine theory and practice to strengthen your technical skills and build confidence before the exam.
- 1. Introduction to Kubernetes Architecture
- 2. Overview of the Certified Kubernetes Administrator (CKA) Exam
- 3. Configuring a Multi-node Kubernetes Cluster with Kind
- 4. Getting Started with kubectl
- 5. Conclusion
1. Introduction to Kubernetes Architecture
The architecture of Kubernetes is designed to orchestrate containers by dividing responsibilities between two main types of nodes: Master Nodes and Worker Nodes. Master Nodes are responsible for managing and controlling the entire cluster, while Worker Nodes run containerized workloads. This role separation ensures system availability, resilience, and scalability.
1.1. Main Components of the Master Node
The Master Node (also known as the Control Plane) is the brain of the Kubernetes cluster. It oversees all cluster operations and manages the desired states of deployed applications. Here are its main components:
- API Server:
- The entry point for all interactions with the cluster.
- Receives requests via the REST interface and forwards them to other components for processing.
- Also used by the
kubectl
client to interact with Kubernetes.
- etcd:
- A distributed key-value database that stores the cluster’s state, including configurations, metadata, and information about Kubernetes objects.
- Crucial for ensuring consistency and recovering the state in case of failures.
- Controller Manager:
- Consolidates multiple controllers responsible for the automated management of Kubernetes objects (e.g., ensuring a minimum number of pod replicas are running).
- Monitors the current cluster state and acts to maintain the desired state.
- Scheduler:
- Assigns newly created pods to available nodes based on defined resources and constraints (e.g., CPU, RAM, or node labels).
- Optimizes the utilization of cluster resources.
1.2. Components of Worker Nodes
Worker Nodes are the machines where containers are executed. Each Worker Node contains several components responsible for managing local resources and running workloads:
- Kubelet:
- An agent that runs and monitors the pods on its node.
- Communicates with the API Server to receive instructions and report the status of the pods.
- Kube Proxy:
- A networking component that ensures communication between services and pods.
- Manages routing rules and load balancing for exposed services.
- Container Runtime:
- Software responsible for running containers on the node. Kubernetes supports various runtimes, including Docker, containerd, and CRI-O (any engine compatible with the Container Runtime Interface or CRI).
- Ensures efficient isolation and execution of containers.
- Pods:
- Pods are the basic units of deployment in Kubernetes and group one or more containers that share the same network and volumes.
- Role of Kubelet: Kubelet ensures that the pods scheduled on the node are functioning correctly, interacts with the runtime to start/stop containers, and reports pod status to the API Server.
- Role of Kube Proxy: Kube Proxy manages network connectivity between pods and routes requests to the appropriate pods, balancing the load when necessary.
What Does a Node Run On?
Kubernetes nodes can be deployed on a variety of platforms, including physical machines, virtual machines, or containerized environments. Kubernetes is designed to be infrastructure-agnostic, enabling users to deploy their cluster in a heterogeneous environment.
How Is High Availability Achieved in a Kubernetes Cluster?
High Availability (HA) in Kubernetes is achieved through several strategies:
- Replication of Master Nodes: Configuring multiple Master Nodes (a minimum of 3) reduces the risk of a single point of failure. These Master Nodes share responsibilities using etcd as a distributed database.
- Management of Worker Nodes: Kubernetes automatically detects Worker Node failures and redistributes the affected pods to other functional nodes.
- Load Balancing and Heartbeats: Mechanisms such as load balancers and “liveness probes” ensure that traffic is directed to operational components.
2. Overview of the Certified Kubernetes Administrator (CKA) Exam
The Certified Kubernetes Administrator (CKA) exam assesses candidates’ practical skills in administering and managing Kubernetes clusters. It is designed to validate operational expertise in a real-world environment.
2.1. Exam Structure and Objectives
The exam lasts 2 hours and focuses on practical scenarios. Candidates must solve real-world problems and perform tasks related to Kubernetes cluster management. The primary objectives include:
- Managing and configuring clusters.
- Networking and connectivity.
- Security, including Role-Based Access Control (RBAC).
- Resource management and application maintenance.
Proper preparation and regular practice of commands are essential for success in this practice-oriented format.
Complete Information
Detailed information can be found on the Linux Foundation’s dedicated page: https://training.linuxfoundation.org/certification/certified-kubernetes-administrator-cka-2/.
2.2. Kubernetes Version Used
The Certified Kubernetes Administrator (CKA) exam relies on a specific Kubernetes version. It is highly recommended to verify this version on the official website before starting your preparation. This ensures your knowledge and practical exercises align with the features and behaviors of the version used in the exam. Since Kubernetes evolves rapidly, commands or functionalities may vary between versions, making this verification essential.
Kubernetes Version for CKA 2025
As of early 2025, and at least until February 10, the version used for the CKA exam is v1.31.
To learn about the specific changes for the CKA 2025 exam, visit the dedicated page: Program Changes - CKA 2025.
2.3. Accessible Documentation During the Exam
During the exam, you have access to specific online resources to assist you:
- Kubernetes Documentation: The official documentation, essential for looking up information about Kubernetes concepts, commands, and objects.
- Kubernetes Blog: Useful for news or relevant articles about Kubernetes, though rarely needed during the exam.
- Kubectl Reference: An indispensable resource for quickly finding command options and syntaxes for
kubectl
.
These resources allow you to confirm or supplement your knowledge during the exam, but they must be used efficiently since time is limited. It is also worth noting that you will access this documentation, along with the exam content, through a virtualized environment. Preparing for this workflow is essential.
3. Configuring a Multi-node Kubernetes Cluster with Kind
Kind (Kubernetes IN Docker) is a lightweight tool for deploying Kubernetes clusters for local development and testing. As its name suggests, Kind runs Kubernetes nodes (Master Nodes and Worker Nodes) as Docker containers on your machine. This eliminates the need for separate physical or virtual machines, making setup quick, portable, and ideal for test environments. This section provides a step-by-step guide to creating a Multi-node cluster using Kind.
3.1. Prerequisites
Before starting, ensure that Docker is installed and that the Docker daemon is running on your machine.
3.2. Installing Kind
There are several simple ways to install Kind on your machine:
- Using binaries: https://kind.sigs.k8s.io/docs/user/quick-start/#installing-from-release-binaries.
- Using a package manager: https://kind.sigs.k8s.io/docs/user/quick-start/#installing-with-a-package-manager.
3.2. Examples of Installation Based on Your Operating System
3.2.1. On Linux
3.2.2. On macOS
3.2.3. On Windows
3.2.4. Testing the Installation
You should see the installed version displayed:
3.3. Creating the Multi-node Cluster
Once Kind is installed, follow these steps to configure a Kubernetes cluster with multiple nodes.
Step 1: Create a Configuration File for the Cluster
A YAML configuration file is required to define your cluster topology. Below is an example configuration for a cluster with 1 Master Node and 2 Worker Nodes:
- Create a file named
kind-cluster-config.yaml
:
Step 2: Determine the Kubernetes Image to Use
By default, Kind uses the latest Kubernetes version packaged for the tool. However, for our CKA exam preparation, it is critical to use the same version as the one specified for the exam.
Check the Kind release page to identify the appropriate image version. Look for the section listing pre-built images for the release.
Example:
- For this article, the version specified for the CKA exam in early 2025 is v1.31. We will use the following image:
Step 3: Create the Cluster from the Configuration File
Use the following command to create the cluster, specifying the configuration file and the image for the selected version:
- Explanation of the options:
--config kind-cluster-config.yaml
: Defines the cluster topology based on the configuration file.--image
: Specifies the Docker image containing the exact Kubernetes version to use.--name multi-node-cluster
: Assigns a name to the cluster for easier management.
You should see the following logs displayed:
Your Multi-node Kubernetes cluster is now set up with the exact version used in the CKA exam, in this case, v1.31.4
.
Let’s now explore how to interact with the cluster to validate its functionality.
Step 4: Verify the Cluster Creation
At this point, you only need two tools to perform initial verifications: kind
and the docker
client. Since Kind uses Docker containers to run Kubernetes nodes, these tools will allow you to quickly check if the cluster is operational.
1. List Active Kind Clusters
Use the following command to display the clusters created with Kind:
You should see output like this:
This confirms that your “multi-node-cluster” is active.
2. Display Node Details
To verify the created nodes and their roles, execute:
This command lists all Docker containers corresponding to the cluster nodes, showing their roles (control-plane or worker) and statuses.
Example output:
Each container represents a node in your Kubernetes cluster. In this example, one control-plane node (control-plane
) and two worker nodes (worker
, worker2
) have been created.
3. Check Cluster Logs
You can also review Kind logs to diagnose potential issues during cluster startup:
Example output:
This command exports the cluster logs to a local directory for detailed analysis:
With these checks, you can ensure that your cluster has been configured correctly. For more detailed information and full interaction with the cluster, it is now necessary to install and configure the kubectl
client.
4. Getting Started with kubectl
kubectl
is the official Kubernetes command-line client. It allows interaction with the cluster, management of resources, and retrieval of detailed cluster state information. This section guides you through installing kubectl
and introduces basic commands to explore and manage your cluster.
4.1. Download and Installation
The steps below provide examples for installing kubectl
on different operating systems and configuring it to interact with a Kind cluster.
There are multiple methods to install kubectl
depending on your operating system and the package managers available.
These examples reflect current practices and may evolve over time. For up-to-date information, refer to the official documentation: https://kubernetes.io/docs/tasks/tools/install-kubectl/.
Here are some examples tailored for major operating systems:
4.1.1. Installation on Linux
- Download the
kubectl
binary:
- Make it executable:
- Move it to a directory included in your PATH:
4.1.2. Installation on macOS
- Run the installation command:
4.1.3. Installation on Windows
Check the latest stable version of the
kubectl
binary from https://dl.k8s.io/release/stable.txt.Download it, for example:
- Add the binary to your PATH.
4.1.4. Verify and Configure kubectl for the Kind Cluster
- Verify the installation in your shell:
- You should see output similar to the following (versions may vary):
- Kind automatically configures the kubeconfig file to allow
kubectl
to interact with the cluster. To verify thatkubectl
is properly configured:
- If the configuration is correct, you will see information about the cluster’s API Server and Control Plane:
4.2. Basic Commands
Once kubectl
is installed and configured, you can use the following commands to explore and interact with your cluster.
4.2.1. Working with Contexts
For the CKA Exam
In Kubernetes, a context is a combination of cluster, user, and namespace.
It is crucial to work with the correct context, especially during the CKA exam, where context-related errors can lead to wasted time or misconfigurations.
Familiarize yourself with context management to avoid these issues. Here are some useful commands for working with contexts.
4.2.1.1. Display the Current Configuration
This command displays the complete current configuration, including clusters, users, and contexts defined in the kubeconfig file.
- Example output:
4.2.1.2. Add a New Context
To add a new context, use the following command:
For example:
4.2.1.3. Delete an Existing Context
Remove a specific context with the following command:
For example:
4.2.1.4. List Available Contexts
Use this command to list all available contexts:
- Example output:
4.2.1.5. Display the Active Context
- Example output:
4.2.1.6. Set a Default Context
- Example output:
By configuring the context correctly, you ensure that all kubectl
commands point to the intended cluster.
4.2.2. Checking Cluster Status
- Display general information about a specific cluster:
- Example output:
4.2.3. List Cluster Nodes
- Display the nodes in the cluster and their statuses:
- Example output:
4.2.4. Display Available Namespaces
- List all namespaces in the cluster:
- Example output:
4.2.5. List Pods in a Namespace
- Check for any deployed pods in the default namespace:
- Example output:
- Check if there are any pods deployed in the
kube-system
namespace:
- Example output:
4.2.6. Get Details of a Specific Resource
- Retrieve detailed information about a specific node:
- Example output:
- Retrieve details about a pod:
- Example output:
Ces commandes constituent une première base pour explorer et gérer votre cluster Kubernetes. Une maîtrise approfondie de ces outils vous aidera à progresser rapidement dans votre apprentissage et à éviter des erreurs majeures lors de l’examen.
5. Conclusion
In this article, we explored the basics of configuring and interacting with a Kubernetes cluster. We covered key concepts such as Kubernetes architecture, setting up a cluster, installing the kubectl
client, and using basic commands. These skills provide a foundation to deepen your understanding of Kubernetes and succeed in the CKA exam.
Next Step
The next article in this series will focus on Pods in Kubernetes, the smallest deployable unit in the system. You will learn what a Pod is, how to create, manage, and interact with it, while also discovering its relationships with other cluster resources.
To progress in your learning, it is essential to practice regularly. Feel free to reproduce the commands and configurations from this article in a test environment. Continuous practice will enhance your mastery of the concepts and build your confidence for the exam.
Happy learning, and see you soon for the next chapter in this series!