4. YAML Configuration File
Introduction
Config File is written in YAML Format
Config File should be stored with the code inside SCM
3 Parts of K8 Config File
Metadata
Specification
Status (Auto Generated & Added by K8)
K8 Gets Status from etcd
Template
The specified kind has its own metadata and spec
Pod has also a section of its own which contains its own configuration

Labels & Connectors
Metadata section contain the labels
Spec section contains the selectors
Connecting Deployment to Pods
Deployment looks which pods belong to it using labels (key value pairs)
The label is matched by the selector

Connecting Services to Deployments
Similar concept as connecting deployment to pods

Ports in Service & Pods
Service listens on port and forwards the request to target port which must be of a pod

Minimal Deployment File
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.16
ports:
- containerPort: 8080
Minimal Service File
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 8080
Last updated