A pod definition file always contains the 4 top-level fields

  1. apiVersion
  2. kind
  3. metadata
  4. spec

These are top-level or root-level fields. REQUIRED fields.

pod-definition.yml

apiVersion:  v1
kind:  Pod
metadata:
  name: myapp-pod
  labels:
     app:  myapp
     type: front-end 
spec:
  containers:
    -  name:  nginx-container
       image: nginx

apiVersion Link to heading

  • version of K8S api to create object
  • must use correct version depending on what create
KindVersion
PODv1
Servicev1
ReplicaSetapps/v1
Deploymentapps/v1

Kind Link to heading

  • see in kind field in table above

Metadata Link to heading

  • name, labels, app

Spec Link to heading

  • containers
  • name
  • image

kubectl create Link to heading

kubectl create -f pod-definition.yaml

Above will deploy pod based on YAML file

BIG NOTE! Link to heading

  • the dash under a field, parent-child, child in YAML definition indicates LIST
  • a LIST is an ARRAY