Sobes.tech
Junior

What is Kubernetes?

sobes.tech AI

Answer from AI

Kubernetes (K8s) is a portable, extensible, open-source platform for managing workloads and services in containers, which simplifies both declarative configuration and automation. It allows automating deployment, scaling, and management of containerized applications.

Key components of Kubernetes:

  • Master: The controlling node of the cluster. Consists of:
    • kube-apiserver: Provides the API for interacting with the cluster.
    • etcd: A distributed configuration data store for the cluster.
    • kube-scheduler: Assigns pods to worker nodes.
    • kube-controller-manager: Runs controllers that maintain the cluster state.
    • cloud-controller-manager (optional): Interacts with cloud providers.
  • Worker (Node): Nodes where containers run. Consists of:
    • kubelet: An agent that interacts with the master and manages pods on the node.
    • kube-proxy: Maintains network rules and traffic routing to services.
    • Container Runtime: Software for running containers (e.g., Docker, containerd).

Main abstractions:

  • Pod: The smallest deployable unit. A group of one or more containers sharing network and storage.
  • Deployment: A declarative way to manage pods. Ensures self-healing and updates.
  • Service: An abstraction defining a logical set of pods and access policies (e.g., load balancing).
  • Namespace: A virtual cluster within the physical cluster used for resource isolation.
  • Volume: A way to make data in pods persistent and accessible to multiple containers.
  • Ingress: An object managing external access to services in the cluster, providing HTTP and HTTPS routing.

Advantages:

  • Automatic scaling
  • Self-healing
  • Load balancing
  • Configuration and secret management
  • Portability across environments (on-premise, clouds)

Example of a simple Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3 # Number of pod replicas
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest # Using the Nginx image
        ports:
        - containerPort: 80