Learn Cluster Architecture, Installation & Configuration (CKA) with Interactive Flashcards
Master key concepts in Cluster Architecture, Installation & Configuration through our interactive flashcard system. Click on each card to reveal detailed explanations and enhance your understanding.
Manage role based access control (RBAC)
Role-Based Access Control (RBAC) is the primary authorization mechanism in Kubernetes, regulating how users and workloads interact with the API server. In the context of the CKA exam and Cluster Architecture, managing RBAC requires mastering four distinct API objects: **Roles**, **ClusterRoles**, **RoleBindings**, and **ClusterRoleBindings**.
First, you define permissions using **Roles** or **ClusterRoles**. A `Role` sets rules (verbs like *get*, *list*, *create*) for resources (like *pods*, *secrets*) within a specific namespace. If you require permissions for cluster-scoped resources (like *nodes*) or need to grant access across all namespaces, you use a `ClusterRole`.
Second, you grant these permissions by connecting them to Subjects (Users, Groups, or ServiceAccounts) using bindings. A **RoleBinding** grants the permissions defined in a Role to a user within a specific namespace. A **ClusterRoleBinding** grants permissions cluster-wide. It is possible to bind a `ClusterRole` using a `RoleBinding` to limit high-level permissions to a single namespace.
Effective management relies on the **Principle of Least Privilege**. Administrators should avoid using the default `cluster-admin` role for routine tasks. Instead, you must craft custom roles containing only the essential API verbs required for a specific task. For the exam, you should be proficient in generating these objects imperatively (e.g., `kubectl create role deployment-manager --verb=create --resource=deployments`) and testing them using `kubectl auth can-i` to verify that the permissions are restricted exactly as intended.
Prepare underlying infrastructure for installing a Kubernetes cluster
Preparing the underlying infrastructure is the critical first step in the CKA curriculum for deploying a Kubernetes cluster using tools like kubeadm. Whether using bare metal or virtual machines, the operating system—typically a Linux distribution like Ubuntu or CentOS—must be configured to meet specific requirements before installation begins.
First, networking is paramount. Each node requires a unique hostname, MAC address, and product_uuid to distinguish it within the cluster. Static IP addresses are recommended to maintain stability. You must configure firewall rules to allow traffic on specific ports: the Control Plane requires TCP 6443 (API Server), 2379-2380 (etcd), and 10250 (Kubelet), while Worker Nodes need TCP 10250 and the NodePort range (30000-32767). Additionally, full network connectivity between all nodes is required.
System-level configurations are equally important. You must disable swap memory (`swapoff -a` and edit `/etc/fstab`) because the kubelet is not designed to handle swap situations. Furthermore, you must load necessary kernel modules such as `overlay` and `br_netfilter`. Correspondingly, update `sysctl` settings to enable `net.ipv4.ip_forward` and ensure bridged traffic is passed to iptables (`net.bridge.bridge-nf-call-iptables = 1`), which is vital for Pod networking.
Finally, you must install a CRI-compliant container runtime (such as containerd or CRI-O) on every node. It is crucial to configure the container runtime to use the `systemd` cgroup driver to match the kubelet's default configuration. Neglecting these preparation steps typically results in immediate pre-flight check failures during the bootstrapping phase.
Create and manage Kubernetes clusters using kubeadm
In the context of the CKA exam, `kubeadm` is the standard tool used to bootstrap best-practice Kubernetes clusters. It automates the complex configuration of the control plane and worker nodes, abstracting the manual generation of certificates and service files while adhering to community standards.
To create a cluster, you must first provision Linux hosts (virtual or physical) and install a container runtime (like containerd), along with `kubelet`, `kubeadm`, and `kubectl`. Swap memory must be disabled on all nodes. On the control plane node, you run `kubeadm init`. It is crucial to set arguments like `--pod-network-cidr` during initialization to ensure compatibility with your chosen Container Network Interface (CNI) add-on. This process initializes the etcd database and creates static pod manifests for the API server, controller manager, and scheduler.
Once the control plane is initialized, you configure `kubectl` access by copying the generated `admin.conf` to your local `.kube` directory. Subsequently, you must install a CNI plugin (such as Calico or Flannel) to enable pod networking; without this, the DNS service will not start. To add capacity, you run the `kubeadm join` command—provided at the end of the init output—on worker nodes, authenticating them via a bootstrap token and CA certificate hash.
Beyond creation, `kubeadm` is vital for cluster management. It handles version upgrades seamlessly using `kubeadm upgrade plan` and `kubeadm upgrade apply`, manages certificate renewal, and handles token lifecycle management. For the CKA, you must demonstrate proficiency in using these commands to build clusters from scratch, troubleshoot bootstrap errors, and perform rolling upgrades.
Manage the lifecycle of Kubernetes clusters
Managing the lifecycle of a Kubernetes cluster is a core competency within the CKA curriculum, focusing primarily on the ongoing maintenance, upgrading, and scaling of a cluster using the `kubeadm` tool. The lifecycle extends far beyond initial installation; it requires a deep understanding of how to keep the cluster secure and up-to-date with minimal disruption.
The most significant lifecycle task is the cluster upgrade. Kubernetes generally supports the three most recent minor versions, requiring administrators to perform rolling upgrades regularly. The process follows a strict hierarchy: the Control Plane is upgraded first, followed by the Worker Nodes. This involves a sequence of manual steps: draining the node to safely evict pods, upgrading the `kubeadm` binary, running `kubeadm upgrade apply` (on the control plane) or `kubeadm upgrade node` (on workers), upgrading `kubelet` and `kubectl`, and finally uncordoning the node. Adherence to the Kubernetes Version Skew Policy is critical here to ensure compatibility between the API server and the kubelets.
Lifecycle management also encompasses Disaster Recovery. Administrators must manage the `etcd` database, which stores the cluster's state. This involves taking snapshot backups using `etcdctl` and knowing how to restore the cluster from a snapshot in the event of total failure. Furthermore, the lifecycle includes scaling the cluster by generating tokens to join new nodes or safely removing nodes that are no longer needed.
Mastery of these tasks ensures that a Kubernetes environment remains resilient, secure, and available throughout its operational lifespan.
Implement and configure a highly-available control plane
Implementing a highly-available (HA) Kubernetes control plane is essential for preventing single points of failure in production environments. In the context of the CKA exam, this typically involves creating a cluster where the control plane components (API Server, Scheduler, Controller Manager) and the etcd data store are replicated across multiple nodes.
There are two primary topologies: 'Stacked etcd' (where etcd runs on the control plane nodes) and 'External etcd' (where etcd runs on separate, dedicated nodes). The stacked topology is more common for CKA scenarios due to lower infrastructure requirements.
Key steps for configuration using kubeadm include:
1. **Load Balancer**: You must provision a load balancer (e.g., HAProxy or a cloud LB) to distribute traffic to the API Servers. This address defines the `--control-plane-endpoint`.
2. **Initialize the First Node**: Execute `kubeadm init` on the first master node with the `--control-plane-endpoint` set to the load balancer's IP and port. Crucially, include the `--upload-certs` flag. This uploads the control plane certificates to a Kubernetes secret, allowing other masters to download them automatically.
3. **Join Secondary Nodes**: Using the output from the initialization (specifically the command containing the `--control-plane` flag and certificate key), run `kubeadm join` on the remaining control plane nodes.
4. **Etcd Quorum**: To ensure data consistency and leader election, you generally require an odd number of etcd members (minimum 3). This ensures the cluster functions even if one node fails.
Use Helm and Kustomize to install cluster components
In the domain of Cluster Architecture, Installation, and Configuration for the CKA exam, efficiently managing Kubernetes manifests is critical. Helm and Kustomize are the primary tools used to install and manage cluster components.
Helm acts as the package manager for Kubernetes, analogous to yum or apt in Linux. It packages multiple Kubernetes resources into a single logical unit called a Chart. Helm utilizes a templating engine, allowing administrators to parameterize configuration via a values.yaml file. This is particularly useful for installing complex, third-party cluster components like Ingress Controllers, CNIs, or monitoring stacks (e.g., Prometheus). Instead of manually applying individual YAML files, an administrator runs 'helm install', ensuring version control and easy rollbacks.
Kustomize, integrated natively into kubectl (via 'kubectl apply -k'), takes a template-free approach. It focuses on traversing Kubernetes manifests to add, remove, or update configuration options without forking the original files. It uses a kustomization.yaml file to define a base configuration and applies overlays for specific environments (e.g., development vs. production). This allows for precise patching of resources, such as changing replica counts or namespace definitions, while keeping the base structure intact.
For the CKA, candidates are expected to understand how to utilize these tools to set up the cluster environment. You may need to fetch a specific Helm chart to deploy a service or use Kustomize to patch an existing deployment configuration. While Helm excels at packaging and distribution, Kustomize excels at configuration modification. Mastering both ensures you can install and configure essential cluster architecture components in a reproducible and scalable manner.
Understand extension interfaces (CNI, CSI, CRI, etc.)
In the context of the CKA exam and Cluster Architecture, extension interfaces are fundamental because Kubernetes is designed to be modular and infrastructure-agnostic. Rather than hard-coding logic for specific vendors, Kubernetes uses standard interfaces to decouple the core orchestration logic from the underlying implementation of runtime, networking, and storage.
**CRI (Container Runtime Interface)** allows the Kubelet to communicate with various container runtimes without the need to recompile Kubernetes. Historically, Kubernetes was tightly coupled with Docker. CRI abstracts this layer, enabling the use of compliant runtimes like **containerd** or **CRI-O**. The Kubelet acts as a client, sending gRPC requests to the runtime shim to manage image pulling and container lifecycles.
**CNI (Container Network Interface)** is responsible for inserting a network interface into the container namespace. When a Pod initializes, the Kubelet calls the configured CNI plugin to assign an IP address and set up routing. This standardization allows administrators to swap network providers (e.g., **Calico**, **Flannel**, **Cilium**) to handle overlay networks and network policies without changing the core Kubernetes code.
**CSI (Container Storage Interface)** manages storage operations. Previously, storage code was "in-tree" (built into the Kubernetes binary), which linked storage driver updates to Kubernetes release cycles. CSI moves this logic "out-of-tree," allowing storage vendors (like AWS EBS, Ceph, or NFS) to develop plugins that provision, attach, and mount volumes dynamically.
For the CKA, it is vital to understand that the Kubelet interacts with these plugins via **gRPC** over Unix sockets on the worker nodes. These interfaces ensure the cluster remains extensible, allowing you to customize the underlying infrastructure stack while maintaining a consistent API for application deployment.
Understand CRDs, install and configure operators
In Kubernetes, Custom Resource Definitions (CRDs) extend the API by allowing you to define custom object kinds beyond the built-in Pods, Services, or Deployments. A CRD acts as a schema that tells the API Server how to handle valid data for this new resource type, storing its state in etcd. However, the CRD is just data; it possesses no logic to modify the system state.
To manage these custom resources, we use Operators. An Operator is a pattern that combines CRDs with a custom Controller. The Controller watches the CRD objects and executes the 'operational logic' (reconciliation loop) to ensure the actual state of the cluster matches the desired state defined in the resource. This effectively codifies human operational knowledge—such as how to back up a database or upgrade a cluster—into software.
To install an Operator, you typically follow two steps:
1. Apply the CRD manifest (`kubectl apply -f crd.yaml`) to register the new API endpoints.
2. Deploy the Operator logic, usually as a Pod via a Deployment, along with the necessary ServiceAccount and RBAC ClusterRoles to allow it to modify resources.
For the CKA exam, you generally do not need to write an operator from scratch. However, you must know how to inspect existing ones using `kubectl get crds`, `kubectl describe crd <name>`, and `kubectl get <custom-resource-name>`. You should understand that deleting a CRD will delete all instances of that custom resource, and if an Operator pod fails, the custom resources remain in the database but will stop reconciling until the Operator is fixed.
ServiceAccounts and token management
In the context of Kubernetes Cluster Architecture, ServiceAccounts serve as the identity system for processes (Pods) running inside the cluster, distinct from User accounts which are intended for humans. While Users are global, ServiceAccounts are namespaced resources. By default, every namespace contains a 'default' ServiceAccount, which is automatically mounted into Pods to facilitate communication with the API server, unless the 'automountServiceAccountToken' field in the Pod specification is explicitly set to false.
Token management has undergone significant changes relevant to the CKA exam. Historically, creating a ServiceAccount automatically generated a Secret containing a long-lived JSON Web Token (JWT). However, in modern Kubernetes versions (v1.24+), this automatic Secret generation was removed to enhance security. The cluster now relies on Bound Service Account Tokens via the TokenRequest API. These modern tokens are projected into Pods as volumes; they are time-limited, audience-bound, and rotate automatically, ensuring that stolen credentials have a limited lifespan.
If you require a token for external use (such as a CI/CD pipeline accessing the cluster), you must now explicitly request a short-lived token using the command 'kubectl create token <service-account-name>'. If a legacy long-lived token is strictly necessary, you must manually create a Secret object with the annotation 'kubernetes.io/service-account.name'. For the CKA, mastering how to create these accounts, manage their associated RBAC RoleBindings, and handle token creation via the command line is essential for securing cluster configuration.
Cluster upgrades with kubeadm
Upgrading a Kubernetes cluster using kubeadm is a precise, sequential process covered in the CKA curriculum. You must upgrade from one minor version to the next (e.g., 1.26 to 1.27) without skipping versions. The operation involves two distinct phases: upgrading the Control Plane followed by the Worker Nodes.
**1. Control Plane Upgrade:**
First, upgrade the `kubeadm` tool on the master node via the OS package manager. Run `kubeadm upgrade plan` to verify the upgrade path and version availability. Execute `sudo kubeadm upgrade apply v<version>` to upgrade the control plane components (API Server, Controller Manager, Scheduler). Finally, upgrade the `kubelet` and `kubectl` packages on the master node and restart the kubelet service.
**2. Worker Node Upgrade:**
Worker nodes are upgraded one at a time to ensure application availability (rolling update). The workflow follows a 'Drain > Upgrade > Uncordon' pattern:
* **Drain:** From the control plane, run `kubectl drain <node_name> --ignore-daemonsets` to evict pods and mark the node as unschedulable.
* **Upgrade:** SSH into the worker node and upgrade the `kubeadm` binary. Instead of 'apply', run `sudo kubeadm upgrade node` to update the local configuration. Then, upgrade `kubelet` and `kubectl` and restart the service.
* **Uncordon:** Verify the node status, then run `kubectl uncordon <node_name>` to allow the scheduler to place new pods on the updated node.
Always backup etcd before starting and refer to the specific Kubernetes version changelog.
etcd backup and restore
In Kubernetes, etcd is the highly available key-value store that persists the entire state of the cluster. For the Certified Kubernetes Administrator (CKA) exam, understanding how to snapshot and restore this data is essential for disaster recovery scenarios.
**Backup Process:**
To create a backup, you use the `etcdctl` command-line tool. You must ensure the environment variable `ETCDCTL_API=3` is set. The command `etcdctl snapshot save <backup-file-path>` is used to create the snapshot. Because etcd is secured with TLS, you must provide the trusted CA certificate, the server certificate, and the server private key using the flags `--cacert`, `--cert`, and `--key`, respectively. You also specify the endpoint, typically `127.0.0.1:2379`.
**Restore Process:**
Restoring is more involved than backing up:
1. **Stop the API Server:** To ensure data consistency, stop the static pods (specifically the kube-apiserver) by temporarily moving the manifest files out of `/etc/kubernetes/manifests`.
2. **Execute Restore:** Run `etcdctl snapshot restore <backup-file-path> --data-dir <new-data-directory>`. It is best practice to restore to a new directory path rather than overwriting the existing `/var/lib/etcd` immediately.
3. **Update Configuration:** Modify the etcd static pod manifest (`etcd.yaml`). Update the `hostPath` volume configuration to point to the new data directory created during the restore step.
4. **Restart Components:** Once the manifest is saved, the kubelet recycles the etcd pod using the restored data. Finally, move the API server manifest back to the manifests folder to restart the control plane.
Mastery of these steps ensures you can recover a cluster's state (Deployments, Services, Configs) in the event of critical failure.
API server authentication and authorization
In Kubernetes, the kube-apiserver acts as the gatekeeper for the cluster. Securing access involves two distinct, sequential stages: Authentication (AuthN) and Authorization (AuthZ).
**Authentication** addresses the question: "Who are you?" Since Kubernetes does not maintain a native database for standard users, it relies on external mechanisms. The API server validates credentials using enabled plugins. Common methods include X.509 Client Certificates (often embedded in kubeconfig files for administrators), Bearer Tokens (specifically ServiceAccount tokens for Pods), and external Identity Providers via OpenID Connect (OIDC). If the identity cannot be validated, the request fails with a 401 error.
**Authorization** addresses the question: "What can you do?" Once the user is identified, the API server checks if they have permission to perform the specific action (verb) on the specific resource. The primary mode for CKA candidates is **Role-Based Access Control (RBAC)**. In RBAC, permissions are defined in *Roles* (namespaced) or *ClusterRoles* (cluster-wide). These roles are then connected to subjects (Users, Groups, or ServiceAccounts) via *RoleBindings* or *ClusterRoleBindings*. Other authorization modes include Node (for Kubelets) and Webhook.
For the CKA exam, you must understand how to inspect the kube-apiserver static pod manifest (usually found in `/etc/kubernetes/manifests`) to verify flags like `--authorization-mode=Node,RBAC` and `--client-ca-file`. You are expected to be proficient in generating certificate signing requests (CSRs) for new users and creating RBAC policies to enforce the principle of least privilege.
Certificate management and rotation
Kubernetes relies heavily on Public Key Infrastructure (PKI) to secure communication between cluster components. In the context of the CKA exam, understanding how these certificates are generated, managed, and rotated is crucial for maintaining cluster health and security. The cluster utilizes a Root Certificate Authority (CA) to sign certificates for core components like the API Server, etcd, Kubelet, Scheduler, and Controller Manager.
When using tools like `kubeadm`, these certificates are generated automatically, typically with a one-year validity. To prevent cluster failure, these certificates must be rotated before they expire. Administrators can verify validity using `kubeadm certs check-expiration` or OpenSSL commands. Certificate rotation involves generating new certificates and restarting control plane processes to reload them. While `kubeadm` offers the `kubeadm certs renew` command to automate the generation of new files in `/etc/kubernetes/pki`, the administrator must ensure static pods are restarted to apply changes.
For worker nodes, Kubernetes supports automatic Kubelet certificate rotation. By enabling specific Kubelet configuration flags and the `NodeRestriction` admission controller, Kubelets can request new certificates via the API Server as they approach expiration. These requests generate Certificate Signing Request (CSR) objects. The Kube-Controller-Manager can be configured to automatically approve these requests, or an administrator may need to manually intervene using `kubectl certificate approve` and `kubectl certificate deny`. Mastery of the CSR API is essential for managing user access and node TLS bootstrapping.
Kubernetes components and architecture
In the context of the CKA exam, Kubernetes architecture is defined by a master-worker model separating the Control Plane from Worker Nodes.
The **Control Plane** is the cluster's brain. The `kube-apiserver` acts as the frontend, processing REST requests and serving as the only component that communicates directly with `etcd`. `etcd` is a highly available key-value store that persists the cluster's state. The `kube-scheduler` assigns new Pods to nodes based on resource availability, taints, and tolerations. The `kube-controller-manager` runs control loops (like the ReplicaSet or Node controllers) to ensure the current state of the cluster matches the desired state. Ideally, these run as Static Pods on the master node.
**Worker Nodes** are the compute machines running workloads. The `kubelet` is the primary agent on every node; it registers the node with the API server and manages the lifecycle of Pods, ensuring containers are running and healthy. It interacts with the **Container Runtime** (e.g., containerd or CRI-O) via the Container Runtime Interface (CRI) to execute containers. `kube-proxy` manages networking rules on each node, facilitating communication between Pods and Services via IPTables or IPVS.
Mastery of these components is essential for the 'Cluster Architecture, Installation & Configuration' domain, particularly when bootstrapping clusters with kubeadm or troubleshooting broken components.
Pod Security Admission and standards
Pod Security Admission (PSA) is the built-in mechanism in Kubernetes for enforcing security restrictions on Pods, serving as the replacement for the deprecated PodSecurityPolicy. It operates as an admission controller that validates Pod requests against predefined Pod Security Standards (PSS) before they are scheduled.
The PSS defines three cumulative policy levels:
1. **Privileged**: Unrestricted and open, intended for system-wide infrastructure workloads like storage drivers or CNI plugins.
2. **Baseline**: Minimally restrictive, preventing known privilege escalations while supporting most common container configurations.
3. **Restricted**: The most secure level, enforcing strict hardening best practices, such as requiring non-root users and dropping Linux capabilities.
PSA applies these standards using three specific modes:
- **Enforce**: Rejects the Pod creation if it violates the standard.
- **Audit**: Allows the Pod but records a violation in the cluster audit logs.
- **Warn**: Allows the Pod but displays a warning message to the client.
In the context of the CKA exam, configuration is primarily handled via Namespace labels. For example, applying the label `pod-security.kubernetes.io/enforce: restricted` to a namespace ensures that only Pods complying with the Restricted profile can run there. If a user attempts to deploy a Pod without the necessary `securityContext` settings (e.g., `runAsNonRoot: true`), the admission controller will reject the request. While granular exemptions can be configured via the API server's AdmissionConfiguration file, understanding how to apply namespace labels and remediate Pod manifests to satisfy these standards is critical for Cluster Architecture security.
Admission controllers
In the context of Kubernetes Cluster Architecture, Admission Controllers act as vital gatekeepers within the API Server. They intercept requests to the Kubernetes API after the request has been authenticated and authorized, but before the object is persisted to the etcd data store.
There are two distinct phases of admission control:
1. **Mutating Phase**: These controllers run first and can modify the object sent in the request. For example, the 'ServiceAccount' controller injects default tokens into pods, or the 'AlwaysPullImages' controller forces the image pull policy to Always.
2. **Validating Phase**: These run after mutation and validate the object against specific schemas or constraints. If a validating controller rejects a request, the entire operation fails. Examples include 'NodeRestriction', which limits what kubelets can modify, and 'ResourceQuota', which ensures namespace limits aren't exceeded.
For the CKA exam, you must understand how to manage these via the kube-apiserver component. Admission controllers are compiled into the binary, and you enable or disable them using the `--enable-admission-plugins` and `--disable-admission-plugins` flags in the `kube-apiserver.yaml` manifest.
Furthermore, Kubernetes supports Dynamic Admission Control via Webhooks. This allows you to configure external HTTP callbacks (`MutatingWebhookConfiguration` and `ValidatingWebhookConfiguration`) to process requests. This mechanism is the foundation for advanced policy enforcement tools like OPA Gatekeeper or Kyverno, allowing administrators to enforce custom security standards without modifying the API server code directly.