Kubernetes yaml file examples
Important: The tab spacing for all kubernetes yaml files are 2 spaces.
Basic Kubernetes YAML Structure
apiVersion: # Can have values such as v1 (Pod, Service) or apps/v1 (ReplicaSet, Deployment)
kind: # The type of Kubernetes resource.
metadata: # Usually only *name* and *labels* are allowed as child properties of metadata.
spec: # Like metadata, it is a dictionary with values under it.
containers # Just an example of what could be under *spec*. Here *containers*
# denotes an array/list where you can specify multiple container images.
- name: # the '-' denotes the first item in the list.
Basic Pod YAML file
apiVersion: v1
kind: Pod
metadata:
name: deb-pod
namespace: default
labels:
app: deb-pod
spec:
containers:
- image: debian
name: deb-pod
command: ["sleep", "2h"]
Shown above is a basic Pod yaml definition to use the debian
image and run the sleep 2h
command to keep from completing and quitting.