TL;DR
Learn the fundamentals of Kubernetes, including core concepts, architecture, and basic operations. Perfect for beginners starting with container orchestration.
Executive Summary
Kubernetes is a system for running containerised applications across a cluster of machines, where you declare the state you want and controllers work continuously to make reality match. This guide covers the pieces a beginner actually uses in the first months: the control plane and node components and what each one does, the core objects, pods, deployments, services, config maps, secrets, and persistent storage, and the daily kubectl operations for deploying, scaling, updating, and debugging an application. You will finish able to read a manifest and predict what the cluster will do with it, expose an application correctly for its audience, and troubleshoot a failing pod with evidence instead of guesswork.
Why This Matters
Containers solved packaging; they did not solve running software in production. Someone still has to restart failed processes, place work on machines with capacity, route traffic only to healthy instances, roll out new versions without downtime, and roll them back when they misbehave. Done by hand or by script, those tasks are slow and inconsistent. Kubernetes exists to make them declarative and continuous: you state that three replicas of this image should be running and reachable, and the system reconciles reality toward that state forever, including after a node dies at 3 AM. Learning the basics properly matters because every higher-level platform, managed service, and abstraction in this space is built on these objects, and debugging any of them eventually means reading the pod, deployment, and service underneath.
Core Concepts
Architecture: Control Plane and Nodes
A cluster divides into the control plane, which decides, and nodes, which run workloads. The API server is the single entry point: every kubectl command, controller, and component talks to it, and it validates and stores object definitions. Etcd is the cluster's data store, holding the desired and observed state of every object, which is why its backup and health are existential concerns for self-managed clusters. The scheduler assigns newly created pods to nodes based on resource requests, constraints, and affinity rules. The controller manager runs the loops that watch state and act: creating pods for a deployment, replacing failed ones, and progressing rollouts.
On each node, the kubelet receives pod definitions for its node and ensures the containers are running and healthy, reporting status back. The container runtime, accessed through the Container Runtime Interface, pulls images and starts containers; current clusters use runtimes such as containerd rather than Docker Engine directly. Kube-proxy, or an equivalent from your networking layer, implements service networking on the node. Namespaces partition a cluster into virtual areas for teams and environments, with quotas and policies applied per namespace.
Pods
A pod is the smallest deployable unit: one or more containers that share a network namespace, an IP address, and optionally storage volumes. Containers in a pod are co-located and scheduled together, which suits a main application with a tightly coupled helper such as a log shipper or proxy. You rarely create pods directly in production, because a bare pod is not replaced when its node fails; you create them through a controller.
# basic-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80Labels on the pod are not decoration. They are how services find pods, how deployments manage them, and how you select them in almost every kubectl query.
Deployments and ReplicaSets
A deployment manages a set of identical pods through a ReplicaSet, and adds rollout behaviour: change the image or configuration, and the deployment creates a new ReplicaSet and shifts pods across gradually, respecting availability settings, keeping the old version available for rollback.
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80The selector must match the pod template labels; a mismatch is a common first error and the API will reject or orphan resources if it is wrong. Deployments suit stateless applications. Stateful workloads with stable identities and storage belong to StatefulSets, and one-instance-per-node agents belong to DaemonSets, but both build on the same pod template idea.
Services and Networking
Pods are ephemeral and their addresses change, so nothing should talk to a pod address directly. A service selects pods by label and gives them one stable virtual address and DNS name, load-balancing across the healthy pods behind it.
# service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- port: 80
targetPort: 80
type: LoadBalancerThe service type decides the audience. ClusterIP, the default, is reachable only inside the cluster and is right for internal components.
apiVersion: v1
kind: Service
metadata:
name: backend-service
spec:
type: ClusterIP
selector:
app: backend
ports:
- port: 80
targetPort: 8080NodePort additionally opens a port on every node, mostly useful in local or constrained environments. LoadBalancer asks the cloud provider for an external load balancer and is the common production entry point, often fronted or replaced by an Ingress or Gateway that routes by host and path across many services. When a service has no endpoints, the cause is almost always a selector that matches no ready pods; check endpoints before checking the network. Network policies, where the networking layer enforces them, restrict which pods may talk to which.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: api-allow
spec:
podSelector:
matchLabels:
app: api
policyTypes:
- Ingress
ingress:
- from:
- podSelector:
matchLabels:
role: frontend
ports:
- protocol: TCP
port: 8080Configuration and Secrets
ConfigMaps hold non-sensitive configuration as key-value data, injected into pods as environment variables or files, so the same image runs in every environment with different settings.
# configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: app-config data: database_url: "mongodb://localhost:27017" api_endpoint: "https://api.example.com"
apiVersion: v1
kind: Pod
metadata:
name: app-pod
spec:
containers:
- name: app
image: my-app:1.0
envFrom:
- configMapRef:
name: app-configSecrets hold sensitive values in the same shapes. Understand what they are: base64 encoding is not encryption, so anyone who can read the secret object can decode it. Protect secrets with least-privilege access control, enable encryption at rest in etcd, and for serious workloads use an external secrets manager that syncs into the cluster.
# secret.yaml apiVersion: v1 kind: Secret metadata: name: app-secrets type: Opaque data: username: dXNlcm5hbWU= # base64 encoded password: cGFzc3dvcmQ= # base64 encoded
apiVersion: v1
kind: Pod
metadata:
name: app-pod
spec:
containers:
- name: app
image: my-app:1.0
env:
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: app-secrets
key: usernameStorage
Containers are ephemeral, so data that must survive a pod needs a volume. A PersistentVolume is a piece of cluster storage; a PersistentVolumeClaim is a request for storage with a size and access mode, which a pod mounts. In most managed clusters a storage class provisions the underlying disk dynamically when the claim is created, so you write claims, not volumes.
# pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: app-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5GiapiVersion: v1
kind: Pod
metadata:
name: app-pod
spec:
containers:
- name: app
image: my-app:1.0
volumeMounts:
- name: data-volume
mountPath: /app/data
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: app-pvcAccess modes are a real constraint: ReadWriteOnce storage attaches to one node, which limits how its pods can move, and is one reason stateful applications need deliberate design rather than a deployment with a volume attached.
Resources, Probes, and Scaling
Resource requests are what the scheduler uses to place pods and what guarantees the pod its share; limits cap what it may consume. A CPU-limited container is throttled; a memory-limited container that exceeds its limit is killed, which is why out-of-memory kills are a configuration event, not a mystery.
apiVersion: v1
kind: Pod
metadata:
name: resource-pod
spec:
containers:
- name: app
image: my-app:1.0
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"Probes tell Kubernetes about application health: readiness decides whether a pod receives traffic, liveness decides whether it is restarted, and startup protects slow-starting applications from liveness failures.
apiVersion: v1
kind: Pod
metadata:
name: app-pod
spec:
containers:
- name: app
image: my-app:1.0
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 3
periodSeconds: 3
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5The Horizontal Pod Autoscaler scales a deployment's replicas from metrics such as CPU or memory utilisation, provided requests are set, since utilisation is measured against them.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: app-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: app-deployment
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80Daily Operations and Debugging
Work declaratively: keep manifests in Git and apply them, rather than editing live objects by hand, so the cluster's state can be rebuilt and reviewed.
# View cluster information kubectl cluster-info # Get nodes status kubectl get nodes # View system components kubectl get pods -n kube-system
# Create resources kubectl apply -f deployment.yaml # View deployments kubectl get deployments # Scale deployment kubectl scale deployment nginx-deployment --replicas=5 # Update image kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1
Debug in a fixed order: get the object's status, describe it and read the events at the bottom, then read logs, including the previous container's logs when a pod is crash-looping.
# Get pod logs kubectl logs nginx-pod # Execute command in pod kubectl exec -it nginx-pod -- /bin/bash # Describe resource kubectl describe pod nginx-pod
The pod's phase and container states name the failure class: Pending points to scheduling, image pull errors point to registry or credentials, CrashLoopBackOff points to the application exiting, and out-of-memory kills are recorded in the container status. Set a security baseline from the start: run as a non-root user, drop privileges, and mount a read-only root filesystem where the application allows it.
apiVersion: v1
kind: Pod
metadata:
name: secure-pod
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
containers:
- name: app
image: my-app:1.0
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: trueDecision Framework
| Situation | Recommendation |
|---|---|
| Stateless application, the common case | Deployment plus a ClusterIP or LoadBalancer service, configuration in a ConfigMap |
| Internal component only other services call | ClusterIP service; no external exposure |
| Public web entry point | LoadBalancer service, or Ingress or Gateway routing to ClusterIP services |
| Application with stable identity and its own disk | StatefulSet with a claim per replica, not a Deployment with a shared volume |
| Agent that must run on every node | DaemonSet |
| Data must survive the pod | PersistentVolumeClaim via a storage class; never rely on the container filesystem |
| Traffic varies through the day | Horizontal Pod Autoscaler, with resource requests set on every container |
| Pod keeps restarting | Read describe, events, and previous logs before changing anything |
When a pod is not running, the status itself tells you where to look — the flowchart below is the order to follow, and the debugging section above has the commands for each step.
Implementation Checklist
Trade-offs
Kubernetes buys portability, self-healing, and a uniform operational model at the price of substantial conceptual and operational weight. A cluster is another system to upgrade, secure, monitor, and pay for, and its abstractions leak: networking, storage classes, and load balancer behaviour differ across environments in ways that matter. The declarative model also demands discipline, because imperative fixes applied live are silently reverted by controllers doing their job. For small workloads the platform can cost more in attention than the application it runs, which is a legitimate reason to choose something simpler until scale or team size justifies it.
When Not to Use
Do not use Kubernetes for a single small application on one server, where a virtual machine or a simple container service is cheaper to run and easier to reason about. Do not use it as a database platform by default; run stateful data systems on managed services unless you have the expertise to operate them on the cluster deliberately. Do not adopt it to solve an application problem, such as a monolith that needs refactoring; orchestration will not decompose anything. Managed container services, serverless platforms, and a plain Platform-as-a-Service are the better alternatives in each of those cases, and Kubernetes remains available when the workload genuinely needs its scheduling, scaling, and ecosystem.
Conclusion
The basics are a small set of ideas applied consistently: declare desired state, let controllers reconcile it, expose pods through services, inject configuration, and request resources honestly. Master pods, deployments, services, and the describe-and-logs debugging loop, and the rest of Kubernetes becomes variations on a model you already understand. Build the habits, Git-managed manifests, probes, limits, non-root containers, from the first cluster, because retrofitting them is harder than starting with them.
References
Why This Matters
Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.
Trade-offs to Consider
Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.
When NOT to Use This
Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.
Decision Framework
Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.