Pdf 11-Writing YAML Files
Pdf 11-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 ---
2 kind: Deployment
3 apiVersion: apps/v1
4
5 # Declare the Deployment Name
6 metadata:
7 name: dep-name-ssl-website
8 labels:
9
10 # Declare the Pod behaviour interms of Replicas needed
11 # Replicas are the DESIRED STATE of the Pods
12 # Kubernetes CONTROLLER always maintains the desired number of Pods
13 # Say we wanted 5 REPLICAS, Controller always compares CURRENT STATE vs DESIRED STATE
14 # If 3 PODS sudenly terminate due to failures, CURRENT STATE = 2, DESIRED STATE =5
15 # CONTROLLER imemdiately Creates 3 more PODS to ensure DESRITED STATE 5 is maintained
16 # This is "spec1", we also have another "spec" in Container Section
17 spec:
18 replicas: 1
19 # Currentky we are not using any Pod Re-creation Strategy
20 strategy:
21 # How does Kube CONTROLLER identify the PODs belonging to this Deployment Object?
22 # By using a FIELD called SELECTOR
23 # Below in the TEMPLATE SECTION we define the POD LABEL
24 # Here in the SELCTOR SECTION, declare the SAME POD LABEL
25 # CONTROLLER reads this "spec.selector.matchLabels" field
26 # CONTROLLER will maintain DESIRED STATE of PODs Matching this LABEL
27 selector:
28 matchLabels:
29 pod-name: pod-label-ssl-website
30 # POD Definition
31 # Here we are giving 2 LAbels to POD
32 # pod-name gives a LABEL to POD
33 # we used "env" to indicate that this POD deployment is Development Type
34 template:
35 metadata:
36 labels:
37 pod-name: pod-label-ssl-website
38 env: dev
39 # CONTAINER(s) Definition
40 # Define a CONTAINER NAME
41 # Define the IMAGE we want to use
42 # Here the Image is auto pulled from Docker Hub
43 # This is "spec2"
44 spec:
45 containers:
46 - name: con-name-ssl-website
47 image: tanvisinghny/ssl-website
48 ports:
49 - containerPort: 80
50 - 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