Kubernetes Cluster Architecture Exploration

KubernetesKubernetesBeginner
Practice Now

Introduction

Kubernetes is a container orchestration platform that automates the deployment, scaling, and management of containerized applications. In this lab, we will explore the architecture of Kubernetes, including the components that make up a Kubernetes cluster and their interactions.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL kubernetes(("`Kubernetes`")) -.-> kubernetes/BasicCommandsGroup(["`Basic Commands`"]) kubernetes(("`Kubernetes`")) -.-> kubernetes/AdvancedCommandsGroup(["`Advanced Commands`"]) kubernetes/BasicCommandsGroup -.-> kubernetes/get("`Get`") kubernetes/AdvancedCommandsGroup -.-> kubernetes/apply("`Apply`") subgraph Lab Skills kubernetes/get -.-> lab-8450{{"`Kubernetes Cluster Architecture Exploration`"}} kubernetes/apply -.-> lab-8450{{"`Kubernetes Cluster Architecture Exploration`"}} end

Kubernetes Control Plane Components

The Kubernetes control plane is responsible for managing the cluster's overall state and managing the deployment and scaling of applications. The control plane components include:

  • kube-apiserver: The Kubernetes API server is a front-end for the Kubernetes control plane. All management requests to the cluster are sent to this component, and it validates and processes those requests.
  • etcd: etcd is a distributed key-value store that stores the Kubernetes cluster's configuration data, including cluster state, pod placement, and other information.
  • kube-scheduler: The Kubernetes scheduler is responsible for scheduling pods to run on nodes in the cluster.
  • kube-controller-manager: The Kubernetes controller manager is responsible for running controllers that manage the state of various Kubernetes objects, such as pods, services, and replication controllers.

To check the status of the control plane components, use the following command:

kubectl get componentstatuses

This command displays the status of the control plane components, including the kube-apiserver, etcd, kube-scheduler, and kube-controller-manager.

Kubernetes Node Components

The Kubernetes node components are responsible for running containers and providing the runtime environment for the applications. The node components include:

  • kubelet: The Kubernetes node agent that runs on each node and is responsible for managing the state of the node and running containers.
  • kube-proxy: The Kubernetes network proxy that runs on each node and is responsible for routing traffic to the appropriate container.

To check the status of the node components, use the following command:

kubectl get nodes

This command displays the nodes running in the Kubernetes cluster, including the node name, status, and other node information.

Kubernetes Pod Components

The Kubernetes pod is the smallest deployable unit in Kubernetes, representing a single instance of a running process in the cluster. Each pod consists of one or more containers that share the same network namespace and storage volumes. The pod components include:

  • pause container: The pause container is a special container that runs in every pod and is responsible for holding the network namespace open and sharing it with other containers in the pod.
  • application container(s): The application container(s) run in the pod and execute the application code.

Create a file called simple-pod.yaml with the following content:

apiVersion: v1
kind: Pod
metadata:
  name: simple-pod
spec:
  containers:
    - name: simple-container
      image: nginx

This YAML file creates a pod with a single container that runs the nginx image.

To create the pod, run the following command:

kubectl apply -f simple-pod.yaml

To check the status of the pod, use the following command:

kubectl get pods

This command displays the pods running in the Kubernetes cluster, including the pod name, namespace, status, and other pod information.

Kubernetes Service Components

The Kubernetes service is an abstraction that defines a logical set of pods and a policy by which to access them. The service components include:

  • Service IP: A virtual IP address assigned to the service that allows applications to access the pods running behind the service.
  • Service Port: A port number assigned to the service that allows applications to access the pods running behind the service.
  • Endpoint: A list of IP addresses and port numbers that point to the pods running behind the service.

Create a file called nginx-service.yaml with the following content:

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

This YAML file creates a service that selects pods with the label app: nginx and exposes port 80.

To create the service, run the following command:

kubectl apply -f nginx-service.yaml

To check the status of the service, use the following command:

kubectl get services

This command displays the services running in the Kubernetes cluster, including the service name, namespace, cluster IP, and other service information.

Summary

In this lab, we explored the architecture of Kubernetes, including the control plane, node, pod, and service components. We learned how to check the status of the control plane and node components using kubectl get, how to create a simple pod and check its status, and how to create a simple service and expose a pod to external applications. By understanding the components that make up a Kubernetes cluster and their interactions, we can better understand how Kubernetes works and how to use it to deploy and manage containerized applications.

Other Kubernetes Tutorials you may like