EMZETT.
Login

Kubernetes objects: Pod, Deployment, Service and ConfigMap

In short: In Kubernetes you describe the desired state in objects: pods run containers, deployments keep them running, services make them reachable and ConfigMaps/Secrets supply configuration.

In more detail: Kubernetes (K8s) is a system that manages containers across many machines. You describe in YAML files what should run; Kubernetes ensures that the actual state matches the desired state (restart on crash, distribution, scaling).

In Depth

The most important objects

  • Pod: smallest unit; one or more containers sharing network and storage. Pods are short-lived.
  • Deployment: manages pods of an application: number of replicas, rolling updates (new version step by step), rollback.
  • Service: stable address and load balancing for a group of pods (ClusterIP internal, NodePort/LoadBalancer external).
  • Ingress: HTTP routing from outside (domains, paths, TLS).
  • ConfigMap: configuration values; Secret: sensitive values (Base64-encoded, better with external encryption).
  • Namespace: logical separation (dev, prod).
  • PersistentVolume/Claim: permanent storage. StatefulSet for stateful applications (databases), Job/CronJob for tasks.

An example

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  selector:
    matchLabels: { app: web }
  template:
    metadata:
      labels: { app: web }
    spec:
      containers:
        - name: web
          image: my-app:1.2.0
          ports: [{ containerPort: 3000 }]
          readinessProbe:
            httpGet: { path: /health, port: 3000 }
---
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector: { app: web }
  ports: [{ port: 80, targetPort: 3000 }]

kubectl apply -f file.yaml, kubectl get pods, kubectl logs pod, kubectl describe pod, kubectl rollout undo deployment/web.

Important concepts

Labels and selectors connect objects. Probes (liveness/readiness) check health. Resource limits (CPU, memory) prevent one app from using everything. Autoscaling (HPA) adjusts replicas to load. Declarative instead of imperative: the YAML file is the source of truth, ideally in Git (GitOps).

Getting started and assessment

To learn: minikube, kind, k3s or Docker Desktop locally. In production managed services are used (GKE, EKS, AKS). K8s is powerful but complex; for small projects Docker Compose or a platform (Vercel, Fly.io) often suffices. Learn containers and networking first.

See also: Kubernetes basics, Docker Compose