liveBook · Manning

Metadata section

As explained in Kubernetes in Action, Second Edition

A metadata section is the part of a Kubernetes object definition containing identity and management metadata for an object instance.

A metadata section identifies and describes a Kubernetes object instance. It contains the object's name and may include labels, annotations, resourceVersion, managedFields, and other management fields. section 4.2.1

Use metadata when defining or inspecting objects:

  • Set metadata.name to give an object a recognizable identity. section 5.2.1
  • Expect the API to add fields after creation; a minimal Pod manifest may begin with only its name under metadata. section 5.2.1
  • Inspect labels, annotations, and low-level management fields when reading a complete object returned by the API. section 4.2.1

A minimal Pod identity

metadata:\n name: kiada\n\nThis gives the Pod the name kiada. Its manifest can then define the Pod's containers under spec; additional metadata and status fields appear after the object is created. section 5.2.1

Listing 5.1 A basic pod manifest file
apiVersion: v1      #1
kind: Pod      #2
metadata:     
  name: kiada     #3
spec: 
  containers:
  - name: kiada      #4
    image: luksa/kiada:0.1     #5
    ports: 
    - containerPort: 8080      #6

Browse the complete basic Pod manifest to see metadata.name alongside apiVersion, kind, and spec. section 5.2.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Defines metadata contents and shows a minimal Pod example, while deferring detailed labels, annotations, and low-level field treatment.
Examples
Uses a basic Pod manifest named kiada and a complete Node manifest containing metadata fields returned by the API.
What it assumes
Assumes familiarity with Kubernetes object manifests, while introducing metadata through a basic Pod definition.
What you can do after
Apply metadata in YAML manifests and recognize fields added when Kubernetes returns created objects.
How it connects
Connects object identity with labels, annotations, manifests, the API, spec, and status.

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.