Ctrl + K
Kubernetes11 min read

Kubernetes Explained

Understand Kubernetes architecture, clusters, pods, deployments, services, networking, storage, scaling and how Kubernetes manages containerized applications.

Published: 2026-09-02

Kubernetes is an open-source platform for deploying, managing and scaling containerized applications. Instead of manually starting containers on individual servers, Kubernetes coordinates workloads across a cluster of machines and continuously works to keep applications running according to their desired configuration.

Kubernetes is commonly used when applications consist of multiple services, need automatic scaling, require high availability or must run consistently across different environments. It provides a common control plane for scheduling containers, managing networking, handling storage and replacing failed workloads.

What Is Kubernetes?

Kubernetes, often abbreviated as K8s, is a container orchestration platform. It manages containers by deciding where workloads should run, monitoring their state and taking corrective actions when the actual state differs from the desired state.

Kubernetes does not replace containers. Instead, it provides the infrastructure and control mechanisms needed to run containers reliably at scale. Container runtimes such as containerd or CRI-O execute containers, while Kubernetes coordinates them.

Why Use Kubernetes?

  • Deploy applications consistently across environments.
  • Automatically restart failed workloads.
  • Scale applications horizontally.
  • Distribute workloads across multiple machines.
  • Provide service discovery and internal networking.
  • Manage rolling application updates.
  • Coordinate persistent storage.

Kubernetes Cluster

A Kubernetes cluster is a group of machines managed as a single system. The cluster contains a control plane responsible for managing the cluster and worker nodes that run application workloads.

PartPurpose
Control planeManages the cluster and makes scheduling decisions
Worker nodesRun application workloads
PodsSmallest deployable Kubernetes units
ServicesProvide stable network access to workloads

Control Plane

The Kubernetes control plane is responsible for maintaining the desired state of the cluster. It receives configuration from users and controllers, stores cluster state and determines which actions are required to keep the cluster running correctly.

ComponentPurpose
API ServerExposes the Kubernetes API
etcdStores cluster state
SchedulerAssigns pods to suitable nodes
Controller ManagerRuns controllers that maintain desired state

Kubernetes API

The Kubernetes API is the main interface for interacting with a cluster. Tools such as kubectl, deployment systems and Kubernetes controllers communicate with the API server to create, inspect and modify resources.

kubectl get pods
kubectl get deployments
kubectl get services

Worker Nodes

Worker nodes provide the computing resources where application workloads run. A node normally contains a container runtime, the kubelet agent and networking components required to communicate with the rest of the cluster.

Node ComponentPurpose
kubeletEnsures assigned pods are running
Container runtimeRuns containers
kube-proxySupports service networking

What Is a Pod?

A pod is the smallest deployable unit in Kubernetes. A pod usually contains one application container, although multiple tightly coupled containers can share the same pod when they need to share networking and storage.

Containers inside the same pod share a network namespace and can communicate with each other through localhost. Pods are designed to be replaceable, so applications should not depend on a particular pod remaining alive forever.

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
    - name: nginx
      image: nginx:latest
      ports:
        - containerPort: 80
💡 In most production applications, you normally create pods through higher-level resources such as Deployments rather than managing individual pods directly.

Deployments

A Deployment manages a set of identical pods and provides declarative control over application replicas and updates. Kubernetes uses the Deployment to create the required pods and replace them when necessary.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
        - name: web
          image: nginx:1.27
          ports:
            - containerPort: 80

Replica Management

The replicas field specifies how many pod instances should normally exist. If one pod fails while three replicas are configured, Kubernetes attempts to create another pod so the desired number of replicas is restored.

Desired ReplicasTypical Result
1One pod instance
3Three pod instances
5Five pod instances

Kubernetes Services

Pods can be created and replaced frequently, which means their individual IP addresses should not be treated as permanent. A Service provides a stable network endpoint and forwards traffic to matching pods.

apiVersion: v1
kind: Service
metadata:
  name: web-service
spec:
  selector:
    app: web-app
  ports:
    - port: 80
      targetPort: 80
Service TypeTypical Use
ClusterIPInternal cluster communication
NodePortExpose a service through a node port
LoadBalancerExpose a service through an external load balancer
ExternalNameMap a service name to an external DNS name

Kubernetes Networking

Kubernetes provides networking that allows pods to communicate with one another and allows services to provide stable access to groups of pods. The exact implementation depends on the cluster's networking solution, but Kubernetes networking is designed around predictable communication between workloads.

For external HTTP and HTTPS traffic, clusters commonly use an Ingress or Gateway-based architecture. These resources can route requests to different services according to hostnames, paths and other rules.

Namespaces

Namespaces provide logical separation inside a Kubernetes cluster. They are useful for organizing resources belonging to different applications, teams or environments and can also be combined with access-control and resource-management policies.

kubectl create namespace development
kubectl get pods -n development

ConfigMaps

ConfigMaps store non-sensitive configuration data separately from container images. Applications can consume ConfigMap values through environment variables, command-line arguments or mounted files.

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  APP_MODE: production
  LOG_LEVEL: info

Secrets

Secrets are Kubernetes resources intended for sensitive configuration such as passwords, tokens and credentials. Applications can consume secrets through environment variables or mounted files.

⚠️ Kubernetes Secrets should not automatically be treated as fully protected encrypted storage. Cluster administrators should configure appropriate encryption, access control and secret-management practices.

Storage in Kubernetes

Containers are often treated as disposable, so data that must survive pod replacement should be stored separately. Kubernetes provides storage abstractions such as PersistentVolumes and PersistentVolumeClaims for applications that need persistent data.

ResourcePurpose
PersistentVolumeRepresents available persistent storage
PersistentVolumeClaimRequests storage for an application
StorageClassDefines how storage can be dynamically provisioned

PersistentVolumeClaim Example

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: app-data
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

Health Checks

Kubernetes can monitor application health using probes. Readiness probes determine whether a container is ready to receive traffic, while liveness probes help detect containers that need to be restarted.

readinessProbe:
  httpGet:
    path: /health
    port: 8080
  periodSeconds: 10

livenessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 15
  periodSeconds: 20

Scaling Applications

Kubernetes can scale workloads by changing the number of pod replicas. Manual scaling is useful for simple scenarios, while the Horizontal Pod Autoscaler can adjust replicas based on resource utilization or other supported metrics.

kubectl scale deployment web-app --replicas=5

Rolling Updates

Deployments support rolling updates that gradually replace old pods with new versions. This allows applications to be updated without stopping every replica at the same time.

kubectl set image deployment/web-app web=nginx:1.28
kubectl rollout status deployment/web-app

Self-Healing

One of Kubernetes' major features is its ability to continuously reconcile the cluster's actual state with the desired state. If a managed pod disappears, Kubernetes can create a replacement. If the desired replica count changes, controllers work toward the new target.

Desired State

Kubernetes configuration is generally declarative. Instead of describing every individual action that must happen, users describe the desired state of resources and Kubernetes controllers determine how to reach and maintain that state.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: api
          image: example/api:1.0

Labels and Selectors

Labels are key-value pairs attached to Kubernetes resources. Selectors use those labels to identify related resources. Deployments, Services and other Kubernetes objects rely heavily on labels and selectors to connect controllers with the workloads they manage.

metadata:
  labels:
    app: backend
    environment: production

Resource Requests and Limits

Kubernetes allows workloads to specify CPU and memory requests and limits. Requests help the scheduler determine where a pod can fit, while limits constrain the amount of a resource a container can consume.

resources:
  requests:
    cpu: "250m"
    memory: "256Mi"
  limits:
    cpu: "500m"
    memory: "512Mi"
💡 Define realistic resource requests for production workloads. Requests that are too low can lead to contention, while unnecessarily high requests can make efficient scheduling more difficult.

Kubernetes and Docker

Docker and Kubernetes solve related but different problems. Docker is commonly used to build and run containers, while Kubernetes coordinates containerized workloads across a cluster. Modern Kubernetes clusters can use container runtimes that implement the Kubernetes Container Runtime Interface rather than relying directly on the Docker Engine.

TechnologyPrimary Role
DockerBuild and work with containers
KubernetesOrchestrate containerized workloads

Kubernetes and Docker Compose

Docker Compose is convenient for defining and running multi-container applications on a local machine or relatively simple environments. Kubernetes is designed for cluster orchestration and provides features for scheduling, scaling, service discovery, rolling updates and self-healing.

Typical Kubernetes Workflow

Build container image
        ↓
Push image to a registry
        ↓
Create Kubernetes manifests
        ↓
Apply resources to the cluster
        ↓
Kubernetes schedules pods
        ↓
Services expose workloads
        ↓
Controllers maintain desired state

Common Kubernetes Resources

ResourcePurpose
PodRuns one or more containers
DeploymentManages replicated application pods
ServiceProvides stable network access
ConfigMapStores non-sensitive configuration
SecretStores sensitive configuration data
NamespaceProvides logical resource separation
PersistentVolumeClaimRequests persistent storage
IngressRoutes external HTTP and HTTPS traffic

Common Mistakes

  • Managing production applications as individual pods.
  • Using the latest image tag without controlled versioning.
  • Ignoring CPU and memory requests.
  • Storing persistent data only inside containers.
  • Exposing services unnecessarily.
  • Treating Kubernetes Secrets as automatically secure storage.
  • Skipping readiness and liveness checks.
  • Giving applications more permissions than they need.

Best Practices

  • Use Deployments or other controllers instead of manually managing production pods.
  • Pin container images to predictable versions.
  • Define appropriate resource requests and limits.
  • Use readiness and liveness probes for long-running applications.
  • Keep configuration separate from container images.
  • Use namespaces to organize environments and teams.
  • Restrict network and API access to the minimum required.
  • Back up important cluster data and persistent application data.
  • Use declarative manifests and version them with the application.
💡 Treat Kubernetes manifests as application infrastructure code. Keeping them in version control makes changes reviewable, reproducible and easier to roll back.
⚠️ Kubernetes adds significant operational complexity. A small application running on one server may not benefit from Kubernetes enough to justify the additional infrastructure and maintenance requirements.

Frequently Asked Questions

What is Kubernetes used for?

Kubernetes is used to deploy, manage, scale and maintain containerized applications across a cluster of machines.

What is a Kubernetes pod?

A pod is the smallest deployable Kubernetes unit and contains one or more closely related containers that share networking and storage.

Is Kubernetes the same as Docker?

No. Docker is primarily used for building and working with containers, while Kubernetes orchestrates containerized workloads across a cluster.

What is a Kubernetes Deployment?

A Deployment manages replicated pods and provides declarative updates, scaling and replacement of application instances.

What is a Kubernetes Service?

A Service provides a stable network endpoint for accessing a group of pods even when individual pod IP addresses change.

Do I need Kubernetes for every Docker application?

No. Kubernetes is most useful when an application benefits from cluster orchestration, scaling, high availability or automated workload management. Smaller applications may be simpler to operate with Docker Compose or another deployment approach.

Helpful Kubernetes Tools

A Kubernetes YAML Generator helps create Kubernetes resource manifests, a Kubernetes YAML Formatter formats configuration files for easier review, a Helm Values Formatter helps organize Helm configuration, a YAML Formatter improves the readability of YAML documents, and a YAML Validator checks Kubernetes manifests and other YAML files for syntax errors before they are used.

Conclusion

Kubernetes provides a powerful platform for running containerized applications across clusters of machines. Its core concepts include pods, deployments, services, namespaces, configuration resources, persistent storage and controllers that continuously maintain the desired state. Although Kubernetes can simplify large-scale application operations, it also introduces additional infrastructure and operational complexity. Understanding the fundamentals allows developers to decide when Kubernetes is appropriate and build deployments that are reliable, scalable and maintainable.

Found an issue?

Found an error, outdated information, or something missing from this article? Let me know through the Contact page.

Your feedback helps improve our articles and keep them accurate and useful.