What is Kubernetes - Kubernetes Architecture Explained ☸️

Rajat ChauhanRajat Chauhan
3 min read
  1. Kubernetes Architecture:https://chauhanrajatwork.hashnode.dev/kubernetes-architecture

  2. What Happens When You Run a kubectl Command?

    kubectl is the Kubernetes command-line tool that allows users to interact with the Kubernetes cluster. Below is the flow of events that occur when you run a kubectl command:

    1. Command Execution: When you run a kubectl command, the tool first reads the Kubernetes configuration file (typically located at ~/.kube/config) to locate the correct cluster and authentication details.

    2. API Request: kubectl sends a REST request to the Kubernetes API server. This request could be to fetch data (e.g., kubectl get pods) or to perform a specific action (e.g., kubectl create deployment).

    3. Authentication & Authorization: The API server authenticates the request (validating the user's identity) and authorizes whether the user has permission to execute the requested action.

    4. Controller Manager Interaction: If the request involves a state change (e.g., creating a pod or deploying an application), the API server communicates with the relevant controllers (via the controller manager) to ensure the desired state is achieved.

    5. Scheduler: If the request involves deploying a pod, the scheduler decides which node should run the pod, considering the available resources.

    6. Etcd Update: Once the state is successfully updated (for example, a pod has been scheduled), the changes are stored in etcd.

    7. Kubelet Interaction: The kubelet on the chosen node pulls the latest configuration from the API server and ensures that the containerized application starts on the node.

    8. Kube Proxy: If networking is involved, the kube proxy ensures that the right network rules are set up on the node for the services and pods.


3. The Pod and Container in Kubernetes

Pod:

A pod is the smallest and simplest unit of deployment in Kubernetes. It can contain one or more containers that share the same network namespace, storage, and resources. Pods are designed to run closely related application containers that need to share resources.

Each pod is assigned a unique IP address within the cluster, and containers within a pod can communicate with each other via localhost. Pods are ephemeral, meaning they can be created, destroyed, and replaced automatically by the Kubernetes control plane as needed. Kubernetes ensures that the desired number of pod replicas are running at any given time.

Container:

A container is a lightweight, standalone executable package that includes everything needed to run an application: code, runtime, libraries, and dependencies. Containers are isolated from each other, making them portable and consistent across environments.

In Kubernetes, containers are run inside pods. Each container within a pod shares the pod’s network namespace and can access the pod's storage. The container runtime (e.g., Docker or containerd) manages containers on each node.


4. Functions of Each Control Plane Component

Here’s a straightforward explanation of the key control plane components:

  1. API Server: Acts as the "gateway" to interact with the Kubernetes cluster. It receives requests from users or components and communicates with other parts of the system to process them.

  2. Scheduler: Decides where to run a pod by evaluating available resources on the nodes and scheduling the pod accordingly.

  3. Controller Manager: Keeps the cluster running according to its desired state. It’s responsible for ensuring the right number of replicas, handling pod failures, and making necessary changes to the cluster.

  4. etcd: Stores all cluster data, such as configurations and states. It serves as the single source of truth for the cluster's state.


💡 If you need help or have any questions, just leave them in the comments! 📝 I would be happy to answer them!

💡 If you found this post useful, please give it a thumbs up 👍 and consider following for more helpful content. 😊

Thank you for taking the time to read! 💚

0
Subscribe to my newsletter

Read articles from Rajat Chauhan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rajat Chauhan
Rajat Chauhan

Rajat Chauhan is a skilled Devops Engineer, having experience in automating, configuring, deploying releasing and monitoring the applications on cloud environment. • Good experience in areas of DevOps, CI/CD Pipeline, Build and Release management, Hashicorp Terraform, Containerization, AWS, and Linux/Unix Administration. • As a DevOps Engineer, my objective is to strengthen the company’s applications and system features, configure servers and maintain networks to reinforce the company’s technical performance. • Ensure that environment is performing at its optimum level, manage system backups and provide infrastructure support. • Experience working on various DevOps technologies/ tools like GIT, GitHub Actions, Gitlab, Terraform, Ansible, Docker, Kubernetes, Helm, Jenkins, Prometheus and Grafana, and AWS EKS, DevOps, Jenkins. • Positive attitude, strong work ethic, and ability to work in a highly collaborative team environment. • Self-starter, Fast learner, and a Team player with strong interpersonal skills • Developed shell scripts (Bash) for automating day-to-day maintenance tasks on top of that have good python scripting skills. • Proficient in communication and project management with good experience in resolving issues.