jongkwan.dev
Development · Essay №021

Kubernetes Core Concepts

Core Kubernetes concepts such as Pods, Deployments, and namespaces, plus the basics of container orchestration

Jongkwan Lee2025년 10월 25일5 min read
Contents

Kubernetes is a container orchestration platform that automatically deploys, scales, and recovers many containers.

Running one container and operating hundreds of them are different problems. This post covers the core objects such as Pod, Service, and Deployment, along with the cluster architecture.

Containerization vs container orchestration

Containerization

Containerization packages an application and its dependencies into a single image so it behaves consistently in any environment.

PropertyDescription
PortabilityMinimizes differences between development, test, and production environments
IsolationIndependent runtime environment with no interference from other services
LightweightLower resource consumption than VMs, with fast startup and shutdown

Container orchestration

Container orchestration automatically deploys, manages, scales, updates, and monitors many containers.

  • Automation: automates repetitive work across hundreds of containers
  • Autoscaling: adjusts container count automatically as traffic changes
  • Rolling updates: updates in stages and rolls back on problems
  • Self-healing: restarts unhealthy containers automatically

Why orchestration is needed

Problems with manual management:

  • Monitoring dozens to hundreds of containers is not feasible
  • Responding to traffic changes in real time is difficult
  • Recovery time after a failure increases
  • Operating cost and the chance of error increase

What Kubernetes does

You declare the desired state in YAML, and Kubernetes automatically reconciles the current state to match that declaration. Instead of handling individual containers, the operator describes only the target state.

CapabilityDescription
Automatic deployment and scalingMaintains the state defined in YAML automatically
Service discoveryProvides a stable endpoint despite dynamic IPs
Load balancingDistributes traffic evenly
Resource managementAllocates CPU and memory efficiently
PortabilitySame operations on-premises and in the cloud

Kubernetes architecture

Control plane (master)

ComponentRole
API ServerThe single API entry point to the cluster
ControllerReconciles current state with desired state
SchedulerSelects the node on which to place a new Pod
etcdDistributed key-value store holding cluster state

Worker nodes

ComponentRole
kubeletCommunicates with the control plane and maintains Pod state
kube-proxyHandles Service network proxying and load balancing
Container RuntimeRuns the actual containers (containerd, CRI-O, and others)

Core objects

Pod

A Pod is the smallest deployable unit in Kubernetes.

  • Contains one or more containers
  • Shares the same network namespace
  • Can share the same storage volumes
  • Is ephemeral by nature
yaml
apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
  - name: app
    image: nginx:latest
    ports:
    - containerPort: 80

apiVersion and kind specify the object type and its schema version. spec.containers lists the containers the Pod runs, and containerPort gives the port the container exposes.

Service

A Service provides a stable network endpoint for a set of Pods.

TypeDescription
ClusterIPCluster-internal only (default)
NodePortExternal access through a node port
LoadBalancerIntegrates with a cloud load balancer
yaml
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-app
  ports:
  - port: 80
    targetPort: 8080
  type: ClusterIP

The selector groups Pods labeled app: my-app as the traffic target. port is the port the Service accepts, and targetPort is the Pod-side port that traffic is forwarded to. The two may differ, and the Service translates between them.

Deployment

A Deployment manages declarative updates to Pods.

  • Supports rolling updates
  • Provides rollback
  • Handles scaling
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: app
        image: my-app:v1

replicas is the number of Pods to maintain. selector.matchLabels identifies the Pods the Deployment manages, and template defines the shape of the Pods it creates. The labels in template must match matchLabels for the Deployment to recognize the Pods as its own.

Basic kubectl commands

bash
# Cluster information
kubectl cluster-info
 
# List resources
kubectl get pods
kubectl get services
kubectl get deployments
 
# Resource details
kubectl describe pod <pod-name>
 
# Check logs
kubectl logs <pod-name>
 
# Deploy
kubectl apply -f deployment.yaml
 
# Scale
kubectl scale deployment my-deployment --replicas=5
 
# Roll back
kubectl rollout undo deployment my-deployment

Summary

Kubernetes is the de facto standard for container orchestration. A Pod is the smallest deployable unit, and a Service provides a stable network endpoint in front of Pods that change dynamically. A Deployment manages the desired Pod state declaratively and handles rolling updates and rollbacks. A cluster is divided into the control plane, which decides state, and the worker nodes, which run the actual containers. Networking policies, storage provisioning, and RBAC (Role-Based Access Control) security settings are the next step in operating a production cluster.