Skip to content

Core Objects

First PublishedByAtif Alam

Kubernetes manages everything as objects — records of intent stored in etcd. You create them with YAML manifests and kubectl apply.

The smallest deployable unit. A pod wraps one or more containers that share:

  • A network namespace (same IP, can talk via localhost).
  • Storage volumes (shared directories).

You rarely create pods directly; you use a Deployment or other controller.

apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
containers:
- name: app
image: nginx:1.25
ports:
- containerPort: 80

Ensures a specified number of pod replicas are running at all times. If a pod dies, the ReplicaSet creates a new one.

You almost never create a ReplicaSet directly — Deployments manage them for you.

The most common way to run stateless workloads. A Deployment manages a ReplicaSet and provides:

  • Rolling updates — replace pods gradually, zero downtime.
  • Rollbacks — revert to a previous version if something breaks.
  • Scaling — change the number of replicas.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: app
image: nginx:1.25
ports:
- containerPort: 80

Virtual partitions inside a cluster. Use them to isolate teams, environments, or projects.

  • default — where objects go if you don’t specify a namespace.
  • kube-system — Kubernetes system components.
  • kube-public — readable by everyone (rarely used directly).
Terminal window
kubectl get namespaces
kubectl create namespace staging
kubectl get pods -n staging

Labels are key-value pairs attached to objects. Selectors filter objects by their labels.

metadata:
labels:
app: my-app
env: production

Selectors are how Services find pods, how Deployments manage ReplicaSets, and how you query with kubectl:

Terminal window
kubectl get pods -l app=my-app
kubectl get pods -l env=production

Every Kubernetes resource is defined in a manifest with four top-level fields: apiVersion, kind, metadata, and spec. For full details on manifest structure, multi-resource files, spec vs status, and how to apply them, see Manifests.