liveBook · Manning

Spec

As explained in Kubernetes in Action, Second Edition

A spec is the Kubernetes object field containing the declarative configuration of the desired state.

A spec is the part of a Kubernetes API object manifest where you declare the object’s desired state. Its fields depend on the object kind: a Pod spec can describe containers and storage volumes, while a Node spec can include the pod IP range assigned to that node. The status section records the current observed state instead. section 4.1.2 section 4.2.1

Use the spec as part of Kubernetes’ desired-state control loop:

  • Declare or change the configuration in the object manifest’s spec section. section 4.1.2
  • Let controllers watch the spec and reconcile the cluster’s actual state with it. section 4.3
  • Read status to see what Kubernetes currently observes, and inspect events when reconciliation encounters problems. section 4.1.2 section 4.3

Inspecting a Node spec

Run `kubectl get node kind-control-plane -o yaml` to view a complete Node object. Its `spec` includes `podCIDR: 10.244.0.0/24` and `podCIDRs`, while `status` contains observed addresses, capacity, conditions, cached images, and operating-system details. Use `kubectl explain node.spec` to inspect the available fields and their descriptions; add `--api-version` when examining another API version. section 4.2.1 section 4.2.2

Figure 4.3 The main sections of a Kubernetes API object
figure

Use the object-structure diagram to distinguish spec from type metadata, object metadata, and status. section 4.1.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains object-specific fields, controller reconciliation, status comparison, and command-line inspection, but defers complete field reference.
Examples
Demonstrates Pod configuration, Node pod CIDRs, Node YAML, kubectl explain, and controller-generated events.
What you can do after
Operate/configure Kubernetes objects by inspecting, documenting, and editing supported spec fields with kubectl.
How it connects
Connects desired state with Kubernetes API objects, object manifests, controllers, reconciliation, status, and events.

Related concepts

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