PDF 12-Writing YAML Files
PDF 12-Writing YAML Files
YAML Structures
1 kind:
2 apiVersion:
3 metadata:
4 name:
5 labels:
6 label:
7 spec:
8 replicas:
9 strategy:
10 selector:
11 matchLabels:
12 label:
13 template:
14 metadata:
15 labels:
16 label:
17 spec:
18 containers:
19 - name:
20 image:
21 command:
22 args:
23 workingDir:
24 ports:
25 env:
26 resources:
27 volumeMounts:
28 livenessProbe:
29 readinessProbe:
30 lifecycle:
31 terminationMessagePath:
32 imagePullPolicy:
33 securityContext:
34 stdin:
35 stdinOnce:
36 tty:
1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4 name: deployment-corpwebsite
5 spec:
6 selector:
7 matchLabels:
8 app: pod-corpwebsite
9 replicas: 2
10 template:
11 metadata:
12 labels:
13 app: pod-corpwebsite
14 env: dev
15 spec:
16 containers:
17 - name: container-corpwebsite
18 image: tanvisinghny/ssl-website
19 ports:
20 - containerPort: 80
21 - containerPort: 443
POD Name
<DeploymentName>.<RandomString>
To prevent “bad words”, vowels and the numbers 0, 1 and 3 were removed from the rand.String function
So, the <RandomString> will be composed by a combination of the following alphanumeric characters: bcdfghjklmnpqrstvwxz2456789
1 apiVersion: v1
2 kind: Service
3 metadata:
4 name: service-corpwebsite
5 spec:
6 type: NodePort
7 selector:
8 app: pod-corpwebsite
9 ports:
10 - nodePort: 30163
11 port: 443
12 targetPort: 443
13 externalIPs:
14 - 165.232.184.39
15 - 139.59.19.74
16
1 externalIPs:
2 - 165.232.184.39
3 - 139.59.19.74
Type of Service is NodePort indicating PODs can be accessed from Internet using Workernode IPs and Ports
1 spec:
2 type: NodePort
3 selector:
4 app: pod-corpwebsite
1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4 name: deployment-corpwebsite
5 spec:
6 selector:
7 matchLabels:
8 app: pod-corpwebsite
9 replicas: 2 # tells deployment to run 2 pods matching the template
10 template:
11 metadata:
12 labels:
13 app: pod-corpwebsite
14 env: dev
15 spec:
16 containers:
17 - name: container-corpwebsite
18 image: tanvisinghny/ssl-website
19 ports:
20 - containerPort: 80
21 - containerPort: 443
22 resources:
23 limits:
24 memory: 200Mi
25 cpu: 300m
26 requests:
27 memory: 100Mi
28 cpu: 100m
1 resources:
2 limits:
3 memory: 200Mi
4 pu: 300m
5 requests:
6 memory: 100Mi
7 cpu: 100m