liveBook · Manning

Schema

As explained in Kubernetes in Action, Second Edition

A schema is a formal description of the fields and structure used to represent an object.

A schema is a formal description of the fields and structure used to represent an object. In Kubernetes, apiVersion identifies the schema used for an object, while kind identifies the object type. An object type can have more than one schema, although usually one schema is used. section 4.2.1

Schemas organize Kubernetes object representations into recognizable sections. A Node manifest, for example, contains type information, metadata, a kind-specific spec, and status. Kubernetes returns and accepts these structured representations as JSON or YAML. section 4.2.1 section 4.1.1

Inspecting a Node schema

Run `kubectl get node kind-control-plane -o yaml` to inspect a Node object. The output begins with `apiVersion: v1` and `kind: Node`, followed by `metadata`, `spec`, and `status` fields. section 4.2.1

$ kubectl get node kind-control-plane -o yaml
apiVersion: v1                                   #1
kind: Node                                       #1
metadata:                                            #2
  annotations: ...
  creationTimestamp: "2020-05-03T15:09:17Z" 
  labels: ... 
  name: kind-control-plane                            #3
  resourceVersion: "3220054"
  selfLink: /api/v1/nodes/kind-control-plane
  uid: 16dc1e0b-8d34-4cfb-8ade-3b0e91ec838b
spec:                                              #4
  podCIDR: 10.244.0.0/24                     #5
  podCIDRs:                                  #5
  - 10.244.0.0/24                            #5
  taints:
  - effect: NoSchedule
    key: node-role.kubernetes.io/master
status:                                     #6
  addresses:                                #7
  - address: 172.18.0.2                     #7
    type: InternalIP                        #7
  - address: kind-control-plane             #7
    type: Hostname                          #7
  allocatable: ... #7
  capacity:                                       #8
    cpu: "8"                                      #8
    ephemeral-storage: 401520944Ki                #8
    hugepages-1Gi: "0"                            #8
    hugepages-2Mi: "0"                            #8
    memory: 32720824Ki                            #8
    pods: "110"                                   #8
  conditions: #8
  - lastHeartbeatTime: "2020-05-17T12:28:41Z"
    lastTransitionTime: "2020-05-03T15:09:17Z"
    message: kubelet has sufficient memory available
    reason: KubeletHasSufficientMemory
    status: "False"
    type: MemoryPressure
    ...
  daemonEndpoints:
    kubeletEndpoint:
      Port: 10250
  images:                                                         #9
  - names:                                                        #9
    - k8s.gcr.io/etcd:3.4.3-0                                     #9
    sizeBytes: 289997247                                          #9
    ...                                                           #9
  nodeInfo:                                                       #10
    architecture: amd64                                           #10
    bootID: 233a359f-5897-4860-863d-06546130e1ff                  #10
    containerRuntimeVersion: containerd://1.3.3-14-g449e9269      #10
    kernelVersion: 5.5.10-200.fc31.x86_64                         #10
    kubeProxyVersion: v1.18.2                                     #10
    kubeletVersion: v1.18.2                                       #10
    machineID: 74b74e389bb246e99abdf731d145142d                   #10
    operatingSystem: linux                                        #10
    osImage: Ubuntu 19.10                                         #10
    systemUUID: 8749f818-8269-4a02-bdc2-84bf5fa21700              #10

Use the annotated Node manifest to see how apiVersion, kind, metadata, spec, and status form a schema-guided object representation. section 4.2.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains schemas through apiVersion, object sections, alternate API representations, and JSON/YAML, without detailing validation rules.
Examples
Uses a Node manifest retrieved with kubectl and contrasts Deployment representations across API versions.
What it assumes
Assumes basic Kubernetes objects and API access, while establishing how manifests represent object types.
What you can do after
Evaluate Kubernetes object representations by reading apiVersion and separating metadata, spec, and status.
How it connects
Connects schema to Kubernetes API, API version, object, resource, JSON, and YAML.

Also explained in

Compare how 44 books explain schema →

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.