Kubernetes core objects
The handful of Kubernetes objects you use every day, Pod, Deployment, Service, ConfigMap and Secret, and how labels and selectors wire them together.
Why orchestration existsImages, layers and writing a Dockerfile
Kubernetes core objects
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- Every Kubernetes object has the same shape: apiVersion and kind say what it is, metadata names it, spec is what you want, and status is what controllers report back.
- A Pod is one or more containers that share a network address. Pods are disposable, so you almost never create them directly.
- A Deployment keeps a set number of identical Pods running from a template, and replaces them gradually when the template changes.
- A Service gives a changing set of Pods one stable name and virtual IP, choosing its Pods by label, not by name.
- ConfigMaps hold configuration and Secrets hold sensitive values, both injected into Pods. Secrets are only base64-encoded unless the cluster encrypts them at rest.
What do you actually declare?
The last lesson said an orchestrator works from desired state. In Kubernetes, desired state is a set of objects, usually written as YAML and sent to the API server. There are dozens of kinds. For an ordinary web service you use about five, and once you see how they connect, the rest follow the same pattern.
The shape every object shares
apiVersion: apps/v1 # which API group and version defines this kind
kind: Deployment # what it is
metadata:
name: notes-api # its name, plus labels and annotations
spec: # what you want
...
status: # what is actually true (written by Kubernetes, not you)
...
spec and status are the declare-and-reconcile loop made visible. You write spec.replicas: 3. A controller works towards it and writes status.readyReplicas: 3 when it gets there.
The five you use every day
Pod. The smallest unit Kubernetes runs: one or more containers that share an IP address and can share volumes. Usually one app container, sometimes a helper beside it. Pods are disposable. When one dies, or its node goes away, it is not repaired, it is replaced by a new Pod with a new IP.
Deployment. “Keep N Pods running from this template.” Under the hood it manages a ReplicaSet, which counts Pods. When you change the template, for example a new image digest, the Deployment creates a new ReplicaSet and shifts Pods over gradually. That is the rolling update, and kubectl rollout undo goes back.
Service. Pods come and go with new IPs, so clients need something stable. A Service has a fixed name and virtual IP, notes-api inside the cluster, and forwards to whichever Pods currently match its label selector. The default type, ClusterIP, is internal only. LoadBalancer asks the cloud for an external load balancer.
ConfigMap and Secret. Configuration lives outside the image, as twelve-factor config recommends, and is injected as environment variables or files. A Secret is meant for sensitive values, but its data is only base64-encoded, so treat it as “not printed by accident” rather than “encrypted”. Real protection comes from encryption at rest, access control and a proper secret store, covered in secrets management for infrastructure.
Two more you will meet soon. Namespaces divide a cluster into named areas for teams or environments. Ingress, and its successor the Gateway API, route outside HTTP traffic to Services by host and path. Many tutorials still use the community ingress-nginx controller. The Kubernetes project announced in November 2025 that it would retire it in March 2026, with no further fixes after that, so new clusters should look at Gateway API implementations instead.
Wiring them together with labels
Objects do not reference Pods by name, because Pod names change. They use labels. Here are three objects for the notes API in one file:
apiVersion: v1
kind: ConfigMap
metadata:
name: notes-config
data:
LOG_LEVEL: info
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: notes-api
spec:
replicas: 3
selector:
matchLabels:
app: notes-api
template:
metadata:
labels:
app: notes-api
spec:
containers:
- name: api
image: ghcr.io/example/notes-api:1.4.2
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: notes-config
readinessProbe:
httpGet:
path: /healthz
port: 8080
---
apiVersion: v1
kind: Service
metadata:
name: notes-api
spec:
selector:
app: notes-api
ports:
- port: 80
targetPort: 8080
The label app: notes-api appears three times, and all three must agree. The Deployment’s selector must match its own Pod template labels. The Service’s selector must match the Pods. The Service’s targetPort must match the container’s port. The readinessProbe tells Kubernetes when a Pod may receive traffic, which is where a health check endpoint earns its keep.
There is no cluster or kubectl on this Mac, so I could not apply this file. What I could do was parse it with Python and check the wiring the way the controllers will:
$ python3 check.py notes.yaml
v1 ConfigMap notes-config
apps/v1 Deployment notes-api
v1 Service notes-api
deployment selector matches its pod template: True
service selector matches the pods: True
service targetPort == containerPort: True
configMap the pods read exists in the file: True
Then I changed one word, the Service’s selector from app: notes-api to app: notes, and checked again. The other three checks still passed. This one did not:
service selector matches the pods: False
This is the most common “it deployed but nothing works” bug. Kubernetes accepts the Service without complaint, because a selector that matches nothing is valid. The Service just has no endpoints, and requests to it go nowhere. On a real cluster, kubectl get endpointslices -l kubernetes.io/service-name=notes-api shows the empty list, and kubectl describe service notes-api is the first command to reach for.
About the video
“Kubernetes Components explained! Pods, Services, Secrets, ConfigMap” is from TechWorld with Nana, published January 2020, 18 minutes 11 seconds. Its chapters cover Node and Pod, Service and Ingress, ConfigMap and Secret, Volumes, Deployment and StatefulSet, and a summary. These objects’ APIs have been stable since well before 2020, so it has aged well, with two exceptions this lesson covers: Gateway API as Ingress’s successor and the retirement of ingress-nginx. English was judged from the title, description, channel and its English auto-caption track. Nana’s YAML walkthrough in deeper goes line by line through a Deployment and Service.
Where this fits
Writing these files by hand for three environments means copying 90 percent of them three times. Next, the two standard ways to avoid that: packaging Kubernetes apps with Helm and Kustomize.
Check yourself
Why do you create a Deployment rather than three Pods?
A bare Pod that dies or loses its node is not replaced. A Deployment's controller keeps the declared number running and handles rolling updates when you change the image.
Your Service exists, the Pods are Running, but requests get no response. What is the first thing to compare?
The Service's selector against the Pods' labels. If they do not match exactly, the Service has no endpoints and nowhere to send traffic.
What is the difference between spec and status?
spec is the desired state you write. status is the observed state the system writes back, such as how many replicas are ready.
Is a Kubernetes Secret encrypted?
Not by default. Values are base64-encoded, which anyone can decode. Encryption at rest in etcd must be configured, and access should be limited with RBAC.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.