Kubernetes Architecture

Kubernetes Architecture

Kubernetes Overview

Kubernetes is like a smart manager for apps in containers. It handles the setup, scaling, and updates automatically, making it easy to run and maintain apps. With Kubernetes, your apps stay healthy, and you can focus on what matters most.

What is Kubernetes? and why do we call it k8s?

Kubernetes is a powerful tool used to manage and automate containerized applications. It simplifies the deployment, scaling, and monitoring of these applications, making it easier to run them in a distributed environment. Kubernetes ensures that applications are always available, adaptable to changing demands, and can recover from failures.

We call it "K8s" because there are 8 letters between 'K' and 's', a quick way to say its name!

What are the benefits of using k8s?

Using Kubernetes (K8s) brings these benefits:

  • Automated app deployment and management

  • Easy scalability based on demand

  • Self-healing for app availability

  • Efficient resource usage and load balancing

  • Seamless updates and rollbacks

  • Works across various environments

  • Strong community support and security features.

Explain the architecture of Kubernetes

The architecture of Kubernetes follows a master-worker (also known as control plane-node) model, where components are distributed among nodes to manage and control containerized applications. Here's a brief overview of the main components:

  1. Master (Control Plane):

    • API Server: Acts as the front-end for the Kubernetes control plane, handling user and other system requests via REST API.

    • Scheduler: Assigns newly created pods to nodes based on resource requirements and constraints.

    • Controller Manager: Manages various controllers responsible for maintaining the desired state of the cluster, like node, replication, and endpoint controllers.

    • etcd: A distributed key-value store that holds the configuration data and cluster state.

  2. Nodes (Workers):

    • Kubelet: The primary agent running on each node, responsible for communicating with the API server and managing pods and containers on that node.

    • Container Runtime: The software responsible for running containers, like Docker or containerd.

    • Kube Proxy: Manages network communication between pods and services.

  3. Pods:

    • The smallest deployable unit in Kubernetes, consisting of one or more containers sharing the same network and storage.
  4. ReplicaSets and Deployments:

    • Ensure that a specified number of pod replicas are running and handle scaling and rolling updates of applications.
  5. Services:

    • Provide a stable IP address and DNS name for accessing a group of pods, enabling load balancing and service discovery.
  6. Volumes:

    • Attach storage to pods and enable data persistence across container restarts.
  7. Namespaces:

    • Logically partition the cluster to create virtual clusters, allowing better resource and access isolation for multiple teams or projects.
  8. ConfigMaps and Secrets:

    • Manage configuration data and sensitive information, which can be mounted into pods as files or environment variables.

The master components work together to manage and control the cluster's overall state, while the worker nodes host the containers and execute the workloads. Kubernetes employs a declarative approach, where users define the desired state of their applications, and Kubernetes continuously works to ensure that the actual state matches the desired state. This architecture provides scalability, flexibility, and robustness, making Kubernetes an ideal platform for managing containerized applications in production environments.

What is Control Plane?

The Control Plane consists of several key components:

  1. API Server: The API Server is the front-end for the Kubernetes control plane. It serves as the interface for users and other components to interact with the cluster. It handles REST API requests and validates them before processing.

  2. Scheduler: The Scheduler is responsible for placing newly created pods onto appropriate nodes in the cluster. It takes into consideration factors such as resource requirements, node constraints, and affinity/anti-affinity rules to ensure efficient resource utilization and even workload distribution.

  3. Controller Manager: The Controller Manager manages various controllers that continuously monitor the state of the cluster and make necessary adjustments to maintain the desired state. Some examples of controllers include the Node Controller, Replication Controller, and Endpoint Controller.

  4. etcd: etcd is a distributed, reliable key-value store that stores the configuration data and the current state of the cluster. It is the source of truth for Kubernetes and allows the Control Plane components to maintain consistency across the cluster.

Difference between kubectl and kubelets

  • kubectl is used by users to manage the Kubernetes cluster from outside.

  • kubelet is an agent on each node, managing containers and ensuring pods run correctly on that node.

Explain the role of the API server

The API server in Kubernetes serves as the front-end for the control plane, handling user requests and managing the cluster's configuration and state. It validates and authorizes requests, communicates with the etcd datastore, and interacts with controllers to maintain the desired state of resources.

For another Jenkins project.

Follow me on LinkedIn to see interesting posts like this : )

linkedin.com/in/prabir-kumar-mahatha-6a0025..

Visit my git hub profile: github.com/PrabirKumarMahatha