lundi 16 décembre 2024

[K8S] - What is Kubernetes?

What is Kubernetes?

Kubernetes, often abbreviated as K8s, is an open-source platform designed to automate the deployment, scaling, and management of containerized applications. Think of Kubernetes as a conductor orchestrating different instruments (applications) to create a harmonious symphony.

The Main Elements of Kubernetes

To understand Kubernetes, it’s essential to know its key components. Here are the main elements explained simply:

1. Node

Analogy: Think of nodes as physical machines or servers that make up a server farm.

A node is a machine (virtual or physical) on which Kubernetes runs applications. Each node contains the necessary services to run pods and is managed by a Kubernetes master node. There are two types of nodes: the master node, which hosts Kubernetes’ administrative parts, and worker nodes, which execute your applications and pods.

2. Pod

Analogy: A pod is like a box containing one or more instruments (applications).

A pod is Kubernetes’ basic unit. It can contain one or more containers sharing the same network space and storage. Pods ensure that applications run consistently.

3. Deployment

Analogy: A deployment is a plan describing how and when the musicians (applications) should play.

A deployment manages the creation and updating of pods. It ensures that the desired number of pods is always running and facilitates updates without service interruptions.

4. ReplicaSet

Analogy: A ReplicaSet is like a regulator ensuring a constant number of musicians on stage.

A ReplicaSet guarantees that a specific number of identical pods are running at all times. If a pod fails, the ReplicaSet creates a new one to replace it.

5. Service

Analogy: A service is the manager ensuring the audience can always hear the music, regardless of changes on stage.

A service exposes an application running on a set of pods as a network service. It facilitates communication between different application components or with external systems.

6. Ingress

Analogy: Ingress is the main gate controlling who can enter the concert and how.

Ingress manages external access to services in a cluster, often via HTTP. It provides routing, load balancing, and security features.

Kubectl: The Command-Line Tool

kubectl is Kubernetes’ command-line tool. It allows interaction with the Kubernetes cluster to deploy applications, inspect resources, and manage the cluster’s state.

Basic Commands

  • Check node status:
    kubectl get nodes
  • List pods in a namespace:
    kubectl get pods -n namespace_name
  • Create a deployment:
    kubectl create deployment deployment_name --image=image_name
  • Update a deployment’s image:
    kubectl set image deployment/deployment_name container_name=new_image
  • Delete a service:
    kubectl delete service service_name

Schematic Illustration of Interactions

Here’s a simplified representation of how Kubernetes components interact: