liveBook · Manning

Kubernetes manifest

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

A Kubernetes manifest is a declarative configuration document, typically written in YAML, that describes a resource's desired state.

A Kubernetes manifest is a YAML file that describes a resource’s desired state. Rather than scripting each step, submit the file to the Kubernetes API and let the control plane reconcile the current state toward that goal. The file also documents the configuration and can be kept in version control for change tracking. section 1.9

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: nginx
  name: nginx
spec:
  containers:
  - image: nginx
    name: nginx

Inspect the Pod manifest’s apiVersion, kind, metadata, and spec. Its spec names an nginx container and image. section 1.9

Choose a submission command based on what already exists:

  • Use kubectl create -f my-pod-manifest.yaml when the resource does not yet exist; it errors if one already exists. section 1.9
  • Use kubectl apply -f my-pod-manifest.yaml to create or update the resource. section 1.9

Schedule a Pod using a manifest

Generate a starting file with kubectl run ssd-pod --image=nginx --dry-run=client -o yaml > ssd-pod.yaml. Check node labels with kubectl get no --show-labels, then label the intended worker with kubectl label no kind-worker disktype=ssd. In the Pod YAML, add nodeSelector under spec, alongside containers, with disktype: ssd beneath it. After submitting the edited YAML, use kubectl get po -o wide to verify that the Pod is Running on kind-worker. section 4.1

A manifest also gives you a starting point for diagnosis. The kubelet follows a Pod’s specified restart behavior when a container fails; inspect kubectl get po and kubectl describe po nginx for status and events. For a multi-container Pod, inspect a particular container with kubectl logs busybox -c sidecar. section 1.6 section 8.1.1

One operational exception is /etc/kubernetes/manifests: the kubelet picks up YAML files there and creates the control-plane components automatically, rather than relying on the scheduler to detect those files. section 2.4

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Works through Pod YAML, submission commands, node-selector editing, and verification; does not detail the API’s reconciliation internals.
Examples
Uses an nginx Pod manifest, a node-selector scheduling task, and a two-container Pod prepared for log inspection.
What it assumes
Assumes access to a Kubernetes cluster and kubectl; introduces the basic YAML manifest pattern through a Pod example.
What you can do after
Apply it via kubectl to create or update Pods, then verify scheduling and inspect status or logs.
How it connects
Connects manifests to declarative configuration, Kubernetes API reconciliation, Pods, node selectors, kubelet, and container troubleshooting.

Also explained in

Compare how 10 books explain Kubernetes manifest →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.