Skip to content

Kubernetes

Overview

Kubernetes is an open-source container orchestration platform.

Kubernetes automates the deployment, scaling, management, and networking of containerized applications (apps packaged with Docker or other container runtimes).

Think of it as the operating system for your cloud-native applications: you give it containers and desired state, and Kubernetes makes sure the system continuously matches that state.

What is it Used For?

  • Running containers at scale (thousands of apps across many servers).
  • Ensuring apps are always available (self-healing, restarting failed containers).
  • Scaling apps up/down automatically depending on load.
  • Managing deployments and updates with zero downtime.
  • Providing networking, service discovery, and load balancing for microservices.

Key Features

Automated Deployment & Scaling

  • Define your desired state (e.g., “I want 5 copies of this API running”).
  • Kubernetes ensures the cluster matches it (adds/removes containers as needed).

Self-Healing

  • Restarts crashed containers.
  • Reschedules workloads to healthy nodes.

Service Discovery & Load Balancing

  • Assigns stable DNS/IPs to services.
  • Distributes traffic across pods automatically.

Storage Orchestration

  • Mounts persistent storage volumes to containers (works with cloud providers like Azure Disk, AWS EBS).

Secrets & Config Management

  • Stores API keys, passwords, and configs securely, separate from code.

Rolling Updates & Rollbacks

  • Deploy new versions of an app gradually.
  • Roll back instantly if something goes wrong.

Extensibility

Works with custom controllers, operators, and integrations.

What Kubernetes Works Alongside

  • Container Runtime: Docker, containerd (needed to run containers).
  • Cloud Providers: Azure Kubernetes Service (AKS), AWS EKS, Google GKE (managed K8s).
  • Ingress Controllers: NGINX, Traefik → manage external traffic into the cluster.
  • Service Meshes: Istio, Linkerd → advanced service-to-service communication, observability, and security.
  • CI/CD Tools: Jenkins, GitHub Actions, ArgoCD, FluxCD → for deploying into Kubernetes.
  • Monitoring: Prometheus, Grafana, ELK/EFK stack for logs & metrics.

Advantages

  • Portable: Works across cloud providers and on-prem.
  • Resilient: Apps stay up despite crashes or node failures.
  • Efficient: Maximizes use of hardware resources.
  • Cloud-native ready: Designed for microservices & distributed systems.

Drawbacks

  • Complexity: Steep learning curve (many new concepts: pods, services, deployments, etc.).
  • Overhead: Not ideal for small/simple apps (a VM or App Service may be easier).
  • Evolving ecosystem: Fast-moving, requires continuous learning.

Example in Practice

Let’s say you have an ASP.NET Core API in Docker.

With Kubernetes you’d define:

  1. Deployment: “Run 3 replicas of my API container.”
  2. Service: “Expose these replicas under a single DNS name and load balance traffic.”
  3. Ingress: “Route external requests from api.myapp.com into the service.”

If one replica crashes, Kubernetes will auto-restart it. If traffic spikes, it can scale to 10 replicas automatically.

YAML Example (Deployment + Service)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapi-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapi
  template:
    metadata:
      labels:
        app: myapi
    spec:
      containers:
      - name: myapi
        image: myregistry/myapi:latest
        ports:
        - containerPort: 80

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

This creates 3 pods running myapi, with a service exposing them internally.

When to Use Kubernetes?

  • You’re running microservices that need scaling & resiliency.
  • Your app requires high availability across many nodes.
  • You want multi-cloud or hybrid flexibility.
  • You need advanced features (blue/green deployments, canaries, service mesh).

If you just have a small monolithic app, managed services like Azure App Service may be simpler.

Summary

Kubernetes is an open-source platform for orchestrating containerized applications. It provides deployment, scaling, load balancing, storage, and self-healing for apps in a cluster of servers. It works closely with containers (Docker), cloud services (AKS, EKS, GKE), CI/CD pipelines, and monitoring tools. It’s powerful but complex, and is most valuable for large-scale, cloud-native, microservice-based systems.