A pod definition file always contains the 4 top-level fields
- apiVersion
- kind
- metadata
- 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
| Kind | Version |
|---|---|
| POD | v1 |
| Service | v1 |
| ReplicaSet | apps/v1 |
| Deployment | apps/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