What Is Kubernetes? Deploy and Recover Container Apps Declaratively
Understand Kubernetes desired state, Pods, Deployments, and Services, then follow a scoped example to apply and inspect a small web workload.
What Is Kubernetes? Deploy and Recover Container Apps Declaratively
Kubernetes is an open-source platform for deploying and operating containerized applications across multiple machines through a declarative API. You submit the state you want—for example, two web application Pods—and controllers in the control plane continuously observe actual state and try to reconcile differences. Kubernetes is therefore more than a set of commands that start containers: it manages resources through declared objects and ongoing reconciliation.
What problem does it address?
Manually placing containers on servers, restarting failed processes, and updating connection addresses as app instances change creates operational work. Kubernetes represents workloads and policies as API objects and provides scheduling, recovery, and service connectivity mechanisms. If a Deployment declares two replicas, Kubernetes tries to keep that number of Pods. If a Pod fails, a controller can create a replacement.
This does not guarantee immediate recovery or that failures will not happen. Image pull errors, insufficient resources, incorrect configuration, node outages, storage, and networking problems remain possible. Operators still need to inspect state and design application resilience, backups, security, and observability.
Cluster components and responsibilities
A Kubernetes cluster has a control plane and nodes. The placement and operational ownership of components vary by cluster and managed service.
The **API server (`kube-apiserver`)** is the entry point for the Kubernetes API. `kubectl` sends manifests to it to create or change objects.
**etcd** stores cluster data, including API objects. A self-managed cluster needs a backup and recovery plan for it.
The **scheduler (`kube-scheduler`)** chooses a node for Pods that have not yet been assigned, considering resource requests and constraints.
**Controllers** compare desired and current states and take action. For example, the Deployment controller uses ReplicaSets to maintain Pods and update versions.
The node **kubelet** receives Pod specifications assigned to that node and works with the container runtime to keep their containers running.
The **container runtime** manages container lifecycle on the node. Kubernetes can communicate through the CRI with runtimes such as containerd and CRI-O.
kube-proxy is commonly used for Service networking, but some network plugins provide equivalent behavior. Control plane responsibility also differs between self-managed and managed Kubernetes.
How are Pods, Deployments, and Services different?
A Pod is the smallest unit Kubernetes schedules and runs. It usually contains one app container, but may contain several tightly coupled containers that need to share storage or networking. Pods can be replaced and may receive different IP addresses, so treat them as disposable units rather than permanent servers.
A Deployment declares a Pod template and replica count, then uses ReplicaSets to maintain the requested Pods and update versions. Managing a Deployment instead of an individual Pod lets Kubernetes replace failed Pods, adjust replica counts, and perform declarative updates.
A Service is a stable logical point of connection for Pods whose IPs can change. A label selector finds the target Pods and routes traffic to them. The default ClusterIP type is reachable only inside the cluster. External access depends on additional configuration such as LoadBalancer, Ingress, or Gateway and on the cluster environment.
Example: deploy a small web app
This documentation-based example uses a web Deployment with two Pods running nginx:stable, plus a Service that selects those Pods and exposes port 80 inside the cluster. It was not applied to a cluster here. The stable tag can move; for reproducible production deployments, use an approved pinned version or image digest.
web.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:stable
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- port: 80
targetPort: 80
type: ClusterIPBefore applying, confirm kubectl targets the intended cluster and that you have the right permissions. This reduces the risk of changing the wrong context.
kubectl config current-context
kubectl apply --dry-run=server -f web.yaml
kubectl apply -f web.yaml
kubectl rollout status deployment/web
kubectl get deployment,pods,service -l app=webServer-side dry-run helps check whether the API server accepts the manifest, subject to the cluster's schema, permissions, and policies. After applying, confirm the rollout completes and the Deployment reports two ready replicas. To inspect the response locally, run this in another terminal:
kubectl port-forward service/web 8080:80Then open http://localhost:8080. This is a temporary connection for that local session, not a public production endpoint. For diagnosis, inspect kubectl get pods -l app=web, kubectl describe pod <pod-name>, and kubectl logs <pod-name> to see status, events, and container output. Remove the example resources with:
kubectl delete -f web.yamlCommands must target the intended cluster. The example was not executed here, and cluster installation is outside its scope.
Reading desired and current state
Kubernetes objects commonly have a user-specified spec and a system-reported status. For example, spec.replicas: 2 states the desired number, while status reports how many are currently ready. Controllers watch for differences and repeat corrective actions. This differs from a one-time imperative command: when you update and reapply a manifest, the declaration changes and the system works toward that state.
Do not diagnose readiness from Running alone. Image-pull failures, insufficient node resources, readiness failures, and app startup errors have different causes. Check Deployment and Pod state, events, and container logs together. Exact output and log access can vary with permissions, distribution, and plugins.
What Kubernetes does not do for you
Kubernetes does not build container images or automatically make every app stateful, backed up, encrypted, or secure. Data durability depends on volumes, storage classes, storage implementations, and separate backup/recovery procedures. External traffic may require a network plugin, cloud provider integration, or Ingress/Gateway implementation.
Pods may remain unscheduled if no node has adequate resources or satisfies their constraints. Operations also require planning for control plane availability, node capacity, monitoring, logging, access control, upgrades, and cost. Kubernetes can reduce some manual work, but it does not remove cluster complexity or ownership.
When should you consider it?
Consider Kubernetes when you need to declare deployments of several services consistently and manage replicas, rollouts, service discovery, and recovery through an API. For one or two services on one machine, a simpler tool such as Docker Compose may be sufficient. Compare deployment needs, failure recovery, data, network exposure, and your team's ability to operate a cluster.
| Question | Kubernetes concept | Check |
|---|---|---|
| Where and how many app instances? | Pod template, Deployment replicas, scheduler | CPU/memory requests and node capacity |
| Keep a connection point as Pods change? | Service and label selector | Selector matches Pod labels |
| Is the requested number actually ready? | Object spec/status, controllers | get, rollout, events, logs |
| Will data survive? | Volumes, PVCs, storage implementation | Backup and restore need separate validation |
| Can external users reach the app? |
Summary
Kubernetes declares the desired state of containerized applications as API objects and uses control plane and node components to keep working toward it. A Pod is the run unit, a Deployment manages Pod sets and updates, and a Service provides a logical connection point that survives Pod replacement. Check the context before applying manifests, then verify replicas, events, and logs. Data persistence, external networking, and cluster availability need separate design.
Sources
[Kubernetes: Overview](https://kubernetes.io/docs/concepts/overview/)
[Kubernetes: Cluster Architecture](https://kubernetes.io/docs/concepts/architecture/)
[Kubernetes: Objects in Kubernetes](https://kubernetes.io/docs/concepts/overview/working-with-objects/)
[Kubernetes: Workloads and Pods](https://kubernetes.io/docs/concepts/workloads/)
[Kubernetes: Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)
[Kubernetes: Services](https://kubernetes.io/docs/concepts/services-networking/service/)
[Kubernetes: `kubectl apply`](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_apply/)
Scope: Kubernetes concept documentation and kubectl reference checked 2026-11-22. Features and APIs vary by cluster version and distribution. The manifest and commands are illustrative and were not applied to a cluster here.