Core Objects
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: v1kind: Podmetadata: name: my-appspec: containers: - name: app image: nginx:1.25 ports: - containerPort: 80ReplicaSets
Section titled “ReplicaSets”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.
Deployments
Section titled “Deployments”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/v1kind: Deploymentmetadata: name: my-appspec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: app image: nginx:1.25 ports: - containerPort: 80Namespaces
Section titled “Namespaces”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).
kubectl get namespaceskubectl create namespace stagingkubectl get pods -n stagingLabels and Selectors
Section titled “Labels and Selectors”Labels are key-value pairs attached to objects. Selectors filter objects by their labels.
metadata: labels: app: my-app env: productionSelectors are how Services find pods, how Deployments manage ReplicaSets, and how you query with kubectl:
kubectl get pods -l app=my-appkubectl get pods -l env=productionYAML Anatomy
Section titled “YAML Anatomy”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.