YAML in Kubernetes Flashcards
4 top level fields
apiVersion:
kind:
metadata:
spec:
[all required]
apiVersion
POD, Service: v1
ReplicaSet, Deployment: apps/v1
kind
POD, Service, ReplicaSet, Deployment
metadata
a dictionary form, data about the object
metadata expected by kubernetes
labels - do as you wish
metadata:
name: my-app-pod
labels:
app: my-app
type: front-end
spec
different for different objects
soec:
containers:
- name: nginx-container
image: nginx
cmd for creating a pod form pod.yml
kubectl create -f pod.yml
cmd list pods
kubectl get pods
cmd show info about my-pod
kubectl describe pod my-pod
yaml for postgress
apiVersion: v1
kind: Pod
metadata:
name: postgres
labels:
tier: db-tier
spec:
containers:
- name: postgres
image: postgres
env:
- name: POSTGRES_PASSWORD
value: mysecretpassword
create pod my-nginx and look at it
kubectl run my-nginx –image=nginx
kubectl get pods
kubectl get pods -o wide
kubectl describe pod my-nginx
Controllers
Processes that monitor kubernetes objects and respond accordingly. Control loops that watch the state of your cluster, then make or request changes where needed
Replication Controller
It ensures that a specified number of pods run at all times.
Load balancing and scaling
Replication Controller vs Replica Set
Older vs newer, recommended technology.
RS can be used to monitor the existing pods.
rc-definition.yml
apiVersion:
kind:
metadata:
spec:
template:
pod-definition.yml - (apiVersion+kind)
replicas: