Kubernetes
4 min read
- What is Kubernetes?
Kubernetes open-source orchestration tool started by Google used to deploy multiple container environments.
An orchestration tool that helps to manage, multiple containers which help a web application run as multiple fragments on a server called microservices architecture.
Kubernetes, often referred to as K8s (where the number 8 represents the eight characters between the "K" and the "s" in "Kubernetes")
What are the benefits of using k8s?
Automated Application Deployment and Scaling: Kubernetes simplifies the process of deploying and scaling applications. It allows you to define your application's desired state and automates the process of creating, managing, and scaling the required containers to match that state.
Container Orchestration: Kubernetes manages containerized applications across a cluster of machines. It provides features like scheduling, load balancing, and self-healing, ensuring that applications are efficiently distributed and highly available.
Scalability and High Availability: Kubernetes enables horizontal scaling of applications by adding or removing instances of containers based on demand. It also supports self-healing capabilities, automatically restarting failed containers and replacing unhealthy ones to maintain the desired state of the application.
Explain the architecture of Kubernetes.
What is Control Plane?
the control plane refers to the set of components that collectively manage and control the Kubernetes cluster. It is responsible for maintaining the desired state of the cluster and coordinating the activities of various nodes.
The control plane consists of the following key components:
API Server: The API server acts as the primary control interface for the cluster. It exposes the Kubernetes API, which allows users and other components to interact with the cluster. The API server handles authentication, authorization, and validation of API requests.
Scheduler: The scheduler is responsible for placing containers onto nodes in the cluster. It examines the resource requirements, constraints, and other factors to make optimal decisions about which nodes to assign the containers to.
Controller Manager: The controller manager runs various controllers that monitor the state of the cluster and take actions to maintain the desired state. Examples of controllers include the Node Controller, which manages node lifecycle, and the ReplicaSet Controller, which ensures the desired number of pod replicas are running.
etcd: etcd is a distributed key-value store that serves as the cluster's database. It stores the configuration data and the state of the cluster, providing a reliable and consistent source of truth for the control plane components.
Write the difference between kubectl and kubelets.
kubectl:
kubectl
is a command-line tool that acts as a user interface for interacting with the Kubernetes cluster. It allows users to perform various operations such as deploying and managing applications, inspecting cluster resources, scaling deployments, accessing logs, and executing commands within containers.kubectl
communicates with the Kubernetes API server, which is part of the control plane, to send requests and retrieve information about the cluster's state. It authenticates users, verifies permissions, and ensures the commands and operations are executed according to the user's privileges.Essentially,
kubectl
is a powerful tool for managing and controlling the cluster from the perspective of a user or administrator.kubelet: The
kubelet
is an agent that runs on each worker node in the Kubernetes cluster. It is responsible for managing the containers and their lifecycle on a specific node.The primary role of the
kubelet
is to ensure that the containers defined in the pod specifications are running and in the desired state on its associated node. It interacts with the control plane components such as the API server and the container runtime (e.g., Docker, containerd) to schedule and execute the containers.The
kubelet
also monitors the health of the containers and reports the status back to the control plane. It performs tasks like pulling container images, starting and stopping containers, monitoring resource usage, and enforcing resource constraints specified in the pod specifications.
Explain the role of the API server.
The API server in Kubernetes plays a central role as the primary control interface and communication hub for the entire cluster. It exposes the Kubernetes API, which allows users, administrators, and other components to interact with the cluster and perform various operations. Here are the key roles and responsibilities of the API server:
API Endpoint: The API server serves as the endpoint for clients to interact with the Kubernetes cluster. Clients can make HTTP/HTTPS requests to the API server to manage and control the cluster's resources, such as pods, deployments, services, and namespaces.
Authentication and Authorization: The API server handles the authentication and authorization of requests.
happy learning!!