├── .gitignore ├── README.md ├── Section_Deployment ├── Exercise 1 │ └── deployment-definition.yml ├── Exercise 2 │ └── deployment-definition.yml ├── Exercise 3 │ └── deployment-definition.yml ├── Exercise 4 │ └── deployment-definition.yml ├── Exercise 5 │ └── deployment-definition.yml ├── Exercise 6 │ ├── deployment-definition.yml │ └── pod-definition.yml └── Exercise 7 │ ├── deployment-definition.yml │ └── pod-definition.yml ├── Section_Pod ├── Exercise 1 │ └── pod-definition.yml ├── Exercise 2 │ └── pod-definition.yml ├── Exercise 3 │ └── pod-definition.yml ├── Exercise 4 │ └── pod-definition.yml ├── Exercise 5 │ └── pod-definition.yml ├── Exercise 6 │ └── pod-definition.yml ├── Exercise 7 │ └── pod-definition.yml ├── Exercise 8 │ └── pod-definition.yml └── Exercise 9 │ └── pod-definition.yml ├── Section_ReplicaSet ├── Exercise 1 │ └── replicaset-definition.yml ├── Exercise 2 │ └── replicaset-definition.yml ├── Exercise 3 │ └── replicaset-definition.yml ├── Exercise 4 │ └── replicaset-definition.yml ├── Exercise 5 │ └── replicaset-definition.yml ├── Exercise 6 │ ├── pod-definition.yml │ └── replicaset-definition.yml └── Exercise 7 │ ├── pod-definition.yml │ └── replicaset-definition.yml ├── Section_Services ├── Exercise 1 │ └── service-definition.yml ├── Exercise 2 │ └── service-definition.yml ├── Exercise 3 │ └── service-definition.yml ├── Exercise 4 │ └── service-definition.yml ├── Exercise 5 │ └── service-definition.yml ├── Exercise 6 │ └── service-definition.yml ├── Exercise 7 │ ├── deployment-definition.yml │ └── service-definition.yml └── Exercise 8 │ ├── deployment-definition.yml │ └── service-definition.yml └── Section_YAML ├── Exercise_1 └── playbook.yml ├── Exercise_2 └── food.yml ├── Exercise_3 └── food.yml ├── Exercise_4 └── employee.yml ├── Exercise_5 └── employee.yml └── Exercise_6 └── employee.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is the answer key for my Kubernetes for Absolute Beginners training on Udemy at - https://www.udemy.com/learn-kubernetes/ 2 | 3 | Mumshad Mannambeth 4 | -------------------------------------------------------------------------------- /Section_Deployment/Exercise 1/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us start with Deployments! Given a deployment-definition.yml file. We are only getting started with it, so let's get it populated. 2 | 3 | # Instruction: Add all the root level properties to it. Note: Only add the properties, not any values. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | 8 | # ------------------------------ 9 | # AFTER 10 | # ------------------------------ 11 | 12 | apiVersion: 13 | kind: 14 | metadata: 15 | spec: -------------------------------------------------------------------------------- /Section_Deployment/Exercise 2/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for Deployment. Deployment is under apiVersion apps/v1 2 | 3 | # Instruction: Update values for apiVersion and kind 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: 8 | #kind: 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: apps/v1 17 | kind: Deployment 18 | metadata: 19 | spec: -------------------------------------------------------------------------------- /Section_Deployment/Exercise 3/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for metadata 2 | 3 | # Instruction: Name the Deployment frontend. And add labels app=>mywebsite and tier=> frontend 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: Deployment 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: apps/v1 17 | kind: Deployment 18 | metadata: 19 | name: frontend 20 | labels: 21 | app: mywebsite 22 | tier: frontend 23 | spec: -------------------------------------------------------------------------------- /Section_Deployment/Exercise 4/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now get to the specification 2 | 3 | # Instruction: The spec section for Deployment has 3 fields: replicas, template and selector. Simply add these properties. Do not add any values. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: Deployment 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: mywebsite 13 | # tier: frontend 14 | #spec: 15 | 16 | # ------------------------------ 17 | # AFTER 18 | # ------------------------------ 19 | 20 | apiVersion: apps/v1 21 | kind: Deployment 22 | metadata: 23 | name: frontend 24 | labels: 25 | app: mywebsite 26 | tier: frontend 27 | spec: 28 | replicas: 29 | template: 30 | selector: -------------------------------------------------------------------------------- /Section_Deployment/Exercise 5/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Instruction: Let us update the number of replicas to 4. 2 | # ------------------------------ 3 | # BEFORE 4 | # ------------------------------ 5 | #apiVersion: apps/v1 6 | #kind: Deployment 7 | #metadata: 8 | # name: frontend 9 | # labels: 10 | # app: mywebsite 11 | # tier: frontend 12 | #spec: 13 | # replicas: 4 14 | # template: 15 | # selector: 16 | 17 | # ------------------------------ 18 | # AFTER 19 | # ------------------------------ 20 | 21 | apiVersion: apps/v1 22 | kind: Deployment 23 | metadata: 24 | name: frontend 25 | labels: 26 | app: mywebsite 27 | tier: frontend 28 | spec: 29 | replicas: 4 30 | template: 31 | selector: -------------------------------------------------------------------------------- /Section_Deployment/Exercise 6/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: The template section expects a Pod definition. Luckily, we have the one we created in the previous set of exercises. Next to the deployment-definition.yml you will now find the same pod-definition.yml file that you created before. 2 | # Instruction: Let us now copy the contents of the pod-definition.yml file, except for the apiVersion and kind and place it under the template section. 3 | # Take extra care on moving the contents to the right so it falls under template. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: Deployment 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: mywebsite 13 | # tier: frontend 14 | #spec: 15 | # replicas: 4 16 | # template: 17 | # selector: 18 | 19 | # ------------------------------ 20 | # AFTER 21 | # ------------------------------ 22 | 23 | apiVersion: apps/v1 24 | kind: Deployment 25 | metadata: 26 | name: frontend 27 | labels: 28 | app: mywebsite 29 | tier: frontend 30 | spec: 31 | replicas: 4 32 | template: 33 | metadata: 34 | name: myapp-pod 35 | labels: 36 | app: myapp 37 | spec: 38 | containers: 39 | - name: nginx 40 | image: nginx 41 | selector: -------------------------------------------------------------------------------- /Section_Deployment/Exercise 6/pod-definition.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: myapp-pod 5 | labels: 6 | app: myapp 7 | spec: 8 | containers: 9 | - name: nginx 10 | image: nginx -------------------------------------------------------------------------------- /Section_Deployment/Exercise 7/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now link the pods to the Deployment by updating selectors. 2 | # Instruction: Add a property "matchLabels" under selector and copy the labels defined in the pod-definition under it. 3 | # Note: this may not work in play-with-k8s as it runs on 1.8 version of kubernetes 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: Deployment 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: mywebsite 13 | # tier: frontend 14 | #spec: 15 | # replicas: 4 16 | # template: 17 | # selector: 18 | 19 | # ------------------------------ 20 | # AFTER 21 | # ------------------------------ 22 | 23 | apiVersion: apps/v1 24 | kind: Deployment 25 | metadata: 26 | name: frontend 27 | labels: 28 | app: mywebsite 29 | tier: frontend 30 | spec: 31 | replicas: 4 32 | template: 33 | metadata: 34 | name: myapp-pod 35 | labels: 36 | app: myapp 37 | spec: 38 | containers: 39 | - name: nginx 40 | image: nginx 41 | selector: 42 | matchLabels: 43 | app: myapp -------------------------------------------------------------------------------- /Section_Deployment/Exercise 7/pod-definition.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: myapp-pod 5 | labels: 6 | app: myapp 7 | spec: 8 | containers: 9 | - name: nginx 10 | image: nginx -------------------------------------------------------------------------------- /Section_Pod/Exercise 1/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us start simple! Given a pod-definition.yml file. We are only getting started with it. I have added two root level properties - apiVersion and kind. 2 | 3 | # Instruction: Add the missing two properties - metadata and spec 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | apiVersion: 8 | kind: 9 | 10 | # ------------------------------ 11 | # AFTER 12 | # ------------------------------ 13 | 14 | apiVersion: 15 | kind: 16 | metadata: 17 | spec: -------------------------------------------------------------------------------- /Section_Pod/Exercise 2/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now populate values for each property. Start with apiVersion. 2 | 3 | # Instruction: Update value of apiVersion to v1. Remember to add a space between colon (:) and the value (v1) 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: 8 | #kind: 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: v1 17 | kind: 18 | metadata: 19 | spec: -------------------------------------------------------------------------------- /Section_Pod/Exercise 3/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: 2 | 3 | # Instruction: Update value of kind to Pod. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: v1 8 | #kind: 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: v1 17 | kind: Pod 18 | metadata: 19 | spec: -------------------------------------------------------------------------------- /Section_Pod/Exercise 4/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now get to the metadata section. 2 | 3 | # Instruction: Add a property "name" under metadata with value "myapp-pod". Remember to add a space before 'name' to make it a child of metadata. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: v1 8 | #kind: 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: v1 17 | kind: Pod 18 | metadata: 19 | name: myapp-pod 20 | spec: -------------------------------------------------------------------------------- /Section_Pod/Exercise 5/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us add some labels to our Pod 2 | 3 | # Instruction: Add a property "lables" under metadata with a child property "app" with a value "myapp". Remember to have equal number of spaces before "name" and "labels" so they are siblings. 4 | # 5 | # ------------------------------ 6 | # BEFORE 7 | # ------------------------------ 8 | #apiVersion: v1 9 | #kind: Pod 10 | #metadata: 11 | # name: myapp-pod 12 | #spec: 13 | 14 | # ------------------------------ 15 | # AFTER 16 | # ------------------------------ 17 | 18 | apiVersion: v1 19 | kind: Pod 20 | metadata: 21 | name: myapp-pod 22 | labels: 23 | app: myapp 24 | spec: -------------------------------------------------------------------------------- /Section_Pod/Exercise 6/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: We now need to provide information regarding the docker image we plan to use. 2 | 3 | # Instruction: Add a property containers under spec section. Do not add anything under it yet. 4 | # 5 | # ------------------------------ 6 | # BEFORE 7 | # ------------------------------ 8 | #apiVersion: v1 9 | #kind: Pod 10 | #metadata: 11 | # name: myapp-pod 12 | # labels: 13 | # app: myapp 14 | #spec: 15 | 16 | # ------------------------------ 17 | # AFTER 18 | # ------------------------------ 19 | 20 | apiVersion: v1 21 | kind: Pod 22 | metadata: 23 | name: myapp-pod 24 | labels: 25 | app: myapp 26 | spec: 27 | containers: -------------------------------------------------------------------------------- /Section_Pod/Exercise 7/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: 2 | 3 | # Instruction: Containers is an array/list. So create the first element in the array/list and add the following properties to it: name - nginx and image - nginx 4 | # 5 | # ------------------------------ 6 | # BEFORE 7 | # ------------------------------ 8 | #apiVersion: v1 9 | #kind: Pod 10 | #metadata: 11 | # name: myapp-pod 12 | # labels: 13 | # app: myapp 14 | #spec: 15 | # containers: 16 | 17 | # ------------------------------ 18 | # AFTER 19 | # ------------------------------ 20 | 21 | apiVersion: v1 22 | kind: Pod 23 | metadata: 24 | name: myapp-pod 25 | labels: 26 | app: myapp 27 | spec: 28 | containers: 29 | - name: nginx 30 | image: nginx -------------------------------------------------------------------------------- /Section_Pod/Exercise 8/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Perfect! You have successfully created a Kubernetes-Definition file. Let us try it one more time, this time all on your own! 2 | 3 | # Instruction: Create a Kubernetes Pod definition file using values from the table below: 4 | # Name: postgres 5 | # Labels - tier => db-tier 6 | # Container name: postgres . Image: postgres 7 | # 8 | # 9 | # ------------------------------ 10 | # BEFORE 11 | # ------------------------------ 12 | # 13 | # 14 | 15 | # ------------------------------ 16 | # AFTER 17 | # ------------------------------ 18 | 19 | apiVersion: v1 20 | kind: Pod 21 | metadata: 22 | name: postgres 23 | labels: 24 | tier: db-tier 25 | spec: 26 | containers: 27 | - name: postgres 28 | image: postgres 29 | 30 | -------------------------------------------------------------------------------- /Section_Pod/Exercise 9/pod-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Postgres Docker image requires an environment variable to be set for password. 2 | # https://hub.docker.com/_/postgres/ 3 | 4 | # Instruction: Set an environment variable for the docker container. POSTGRES_PASSWORD with a value mysecretpassword. ] 5 | # I know we haven't discussed this in the lecture, but it is easy. To pass in an environment variable add a new property 'env' to the container object. It is a sibling of image and name. 6 | # env is an array/list. So add a new item under it. The item will have properties name and value. name should be the name of the environment variable - POSTGRES_PASSWORD 7 | # And value should be the password - mysecretpassword 8 | # 9 | # 10 | # ------------------------------ 11 | # BEFORE 12 | # ------------------------------ 13 | #apiVersion: v1 14 | #kind: Pod 15 | #metadata: 16 | # name: postgres 17 | # labels: 18 | # tier: db-tier 19 | #spec: 20 | # containers: 21 | # - name: postgres 22 | # image: postgres 23 | 24 | # 25 | 26 | # ------------------------------ 27 | # AFTER 28 | # ------------------------------ 29 | 30 | apiVersion: v1 31 | kind: Pod 32 | metadata: 33 | name: postgres 34 | labels: 35 | tier: db-tier 36 | spec: 37 | containers: 38 | - name: postgres 39 | image: postgres 40 | env: 41 | - name: POSTGRES_PASSWORD 42 | value: mysecretpassword 43 | 44 | -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 1/replicaset-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us start with ReplicaSets! Given a blank replicaset-definition.yml file. We are only getting started with it, so let's get it populated. 2 | 3 | # Instruction: Add all the root level properties to it. Note: Only add the properties, not any values. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | 8 | # ------------------------------ 9 | # AFTER 10 | # ------------------------------ 11 | 12 | apiVersion: 13 | kind: 14 | metadata: 15 | spec: -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 2/replicaset-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for ReplicaSet. ReplicaSet is under apiVersion apps/v1 2 | 3 | # Instruction: Update values for apiVersion and kind 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: 8 | #kind: 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: apps/v1 17 | kind: ReplicaSet 18 | metadata: 19 | spec: -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 3/replicaset-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for metadata 2 | 3 | # Instruction: Name the ReplicaSet frontend. And add labels app=>mywebsite and tier=> frontend 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: ReplicaSet 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: apps/v1 17 | kind: ReplicaSet 18 | metadata: 19 | name: frontend 20 | labels: 21 | app: mywebsite 22 | tier: frontend 23 | spec: -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 4/replicaset-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now get to the specification 2 | 3 | # Instruction: The spec section for ReplicaSet has 3 fields: replicas, template and selector. Simply add these properties. Do not add any values. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: ReplicaSet 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: mywebsite 13 | # tier: frontend 14 | #spec: 15 | 16 | # ------------------------------ 17 | # AFTER 18 | # ------------------------------ 19 | 20 | apiVersion: apps/v1 21 | kind: ReplicaSet 22 | metadata: 23 | name: frontend 24 | labels: 25 | app: mywebsite 26 | tier: frontend 27 | spec: 28 | replicas: 29 | template: 30 | selector: -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 5/replicaset-definition.yml: -------------------------------------------------------------------------------- 1 | # Instruction: Let us update the number of replicas to 4. 2 | # ------------------------------ 3 | # BEFORE 4 | # ------------------------------ 5 | #apiVersion: apps/v1 6 | #kind: ReplicaSet 7 | #metadata: 8 | # name: frontend 9 | # labels: 10 | # app: mywebsite 11 | # tier: frontend 12 | #spec: 13 | # replicas: 4 14 | # template: 15 | # selector: 16 | 17 | # ------------------------------ 18 | # AFTER 19 | # ------------------------------ 20 | 21 | apiVersion: apps/v1 22 | kind: ReplicaSet 23 | metadata: 24 | name: frontend 25 | labels: 26 | app: mywebsite 27 | tier: frontend 28 | spec: 29 | replicas: 4 30 | template: 31 | selector: -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 6/pod-definition.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: myapp-pod 5 | labels: 6 | app: myapp 7 | spec: 8 | containers: 9 | - name: nginx 10 | image: nginx -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 6/replicaset-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: The template section expects a Pod definition. Luckily, we have the one we created in the previous set of exercises. Next to the replicaset-definition.yml you will now find the same pod-definition.yml file that you created before. 2 | # Instruction: Let us now copy the contents of the pod-definition.yml file, except for the apiVersion and kind and place it under the template section. 3 | # Take extra care on moving the contents to the right so it falls under template. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: ReplicaSet 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: mywebsite 13 | # tier: frontend 14 | #spec: 15 | # replicas: 4 16 | # template: 17 | # selector: 18 | 19 | # ------------------------------ 20 | # AFTER 21 | # ------------------------------ 22 | 23 | apiVersion: apps/v1 24 | kind: ReplicaSet 25 | metadata: 26 | name: frontend 27 | labels: 28 | app: mywebsite 29 | tier: frontend 30 | spec: 31 | replicas: 4 32 | template: 33 | metadata: 34 | name: myapp-pod 35 | labels: 36 | app: myapp 37 | spec: 38 | containers: 39 | - name: nginx 40 | image: nginx 41 | selector: -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 7/pod-definition.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: myapp-pod 5 | labels: 6 | app: myapp 7 | spec: 8 | containers: 9 | - name: nginx 10 | image: nginx -------------------------------------------------------------------------------- /Section_ReplicaSet/Exercise 7/replicaset-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now link the pods to the ReplicaSet by updating selectors. 2 | # Instruction: Add a property "matchLabels" under selector and copy the labels defined in the pod-definition under it. 3 | # Note: this may not work in play-with-k8s as it runs on 1.8 version of kubernetes 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: ReplicaSet 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: mywebsite 13 | # tier: frontend 14 | #spec: 15 | # replicas: 4 16 | # template: 17 | # selector: 18 | 19 | # ------------------------------ 20 | # AFTER 21 | # ------------------------------ 22 | 23 | apiVersion: apps/v1 24 | kind: ReplicaSet 25 | metadata: 26 | name: frontend 27 | labels: 28 | app: mywebsite 29 | tier: frontend 30 | spec: 31 | replicas: 4 32 | template: 33 | metadata: 34 | name: myapp-pod 35 | labels: 36 | app: myapp 37 | spec: 38 | containers: 39 | - name: nginx 40 | image: nginx 41 | selector: 42 | matchLabels: 43 | app: myapp -------------------------------------------------------------------------------- /Section_Services/Exercise 1/service-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us start with Services! Given a service-definition.yml file. We are only getting started with it, so let's get it populated. 2 | 3 | # Instruction: Add all the root level properties to it. Note: Only add the properties, not any values. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | 8 | # ------------------------------ 9 | # AFTER 10 | # ------------------------------ 11 | 12 | apiVersion: 13 | kind: 14 | metadata: 15 | spec: -------------------------------------------------------------------------------- /Section_Services/Exercise 2/service-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for Service. Service is under apiVersion v1 2 | 3 | # Instruction: Update values for apiVersion and kind 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: 8 | #kind: 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: v1 17 | kind: Service 18 | metadata: 19 | spec: -------------------------------------------------------------------------------- /Section_Services/Exercise 3/service-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for metadata. 2 | 3 | # Instruction: Add a name for the service frontend and a label app=>myapp 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: v1 8 | #kind: Service 9 | #metadata: 10 | #spec: 11 | 12 | # ------------------------------ 13 | # AFTER 14 | # ------------------------------ 15 | 16 | apiVersion: v1 17 | kind: Service 18 | metadata: 19 | name: frontend 20 | labels: 21 | app: myapp 22 | spec: -------------------------------------------------------------------------------- /Section_Services/Exercise 4/service-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for spec section. The spec section for Services have type, selector and ports. 2 | 3 | # Instruction: Add properties under spec section - type, selector and ports. Do not add any values for them. 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: v1 8 | #kind: Service 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: myapp 13 | #spec: 14 | 15 | # ------------------------------ 16 | # AFTER 17 | # ------------------------------ 18 | 19 | apiVersion: v1 20 | kind: Service 21 | metadata: 22 | name: frontend 23 | labels: 24 | app: myapp 25 | spec: 26 | type: 27 | ports: 28 | selector: -------------------------------------------------------------------------------- /Section_Services/Exercise 5/service-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for ports. Ports is an Array/ List. Each item in the list has a set of properties - port and targetPort 2 | 3 | # Instruction: Create an Array/List item under ports. Add a dictionary with properties port and targetPort. Set values for both to port 80. 4 | # Note: We will not be providing a NodePort as we would like Kubernetes to assign one automatically for us. 5 | # ------------------------------ 6 | # BEFORE 7 | # ------------------------------ 8 | #apiVersion: v1 9 | #kind: Service 10 | #metadata: 11 | # name: frontend 12 | # labels: 13 | # app: myapp 14 | #spec: 15 | # type: 16 | # ports: 17 | # selector: 18 | 19 | # ------------------------------ 20 | # AFTER 21 | # ------------------------------ 22 | 23 | apiVersion: v1 24 | kind: Service 25 | metadata: 26 | name: frontend 27 | labels: 28 | app: myapp 29 | spec: 30 | type: 31 | ports: 32 | - port: 80 33 | targetPort: 80 34 | selector: -------------------------------------------------------------------------------- /Section_Services/Exercise 6/service-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for type. Since we are creating a frontend service for enabling external access to users, we will set it to NodePort. 2 | 3 | # Instruction: Set value for type to NodePort. 4 | 5 | # ------------------------------ 6 | # BEFORE 7 | # ------------------------------ 8 | #apiVersion: v1 9 | #kind: Service 10 | #metadata: 11 | # name: frontend 12 | # labels: 13 | # app: myapp 14 | #spec: 15 | # type: 16 | # ports: 17 | # - port: 80 18 | # targetPort: 80 19 | # selector: 20 | 21 | # ------------------------------ 22 | # AFTER 23 | # ------------------------------ 24 | 25 | apiVersion: v1 26 | kind: Service 27 | metadata: 28 | name: frontend 29 | labels: 30 | app: myapp 31 | spec: 32 | type: NodePort 33 | ports: 34 | - port: 80 35 | targetPort: 80 36 | selector: -------------------------------------------------------------------------------- /Section_Services/Exercise 7/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now link the pods to the Deployment by updating selectors. 2 | # Instruction: Add a property "matchLabels" under selector and copy the labels defined in the pod-definition under it. 3 | # Note: this may not work in play-with-k8s as it runs on 1.8 version of kubernetes 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: Deployment 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: mywebsite 13 | # tier: frontend 14 | #spec: 15 | # replicas: 4 16 | # template: 17 | # selector: 18 | 19 | # ------------------------------ 20 | # AFTER 21 | # ------------------------------ 22 | 23 | apiVersion: apps/v1 24 | kind: Deployment 25 | metadata: 26 | name: frontend 27 | labels: 28 | app: mywebsite 29 | tier: frontend 30 | spec: 31 | replicas: 4 32 | template: 33 | metadata: 34 | name: myapp-pod 35 | labels: 36 | app: myapp 37 | spec: 38 | containers: 39 | - name: nginx 40 | image: nginx 41 | selector: 42 | matchLabels: 43 | app: myapp -------------------------------------------------------------------------------- /Section_Services/Exercise 7/service-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now add values for selector. We need to link the Service to the PODs created by the deployment. 2 | 3 | # Instruction: Given the deployment-definition file we created in the previous Section. Copy the appropriate labels and paste it under selector section of service-definition.yml file. 4 | 5 | # ------------------------------ 6 | # BEFORE 7 | # ------------------------------ 8 | #apiVersion: v1 9 | #kind: Service 10 | #metadata: 11 | # name: frontend 12 | # labels: 13 | # app: myapp 14 | #spec: 15 | # type: NodePort 16 | # ports: 17 | # - port: 80 18 | # targetPort: 80 19 | # selector: 20 | 21 | # ------------------------------ 22 | # AFTER 23 | # ------------------------------ 24 | 25 | apiVersion: v1 26 | kind: Service 27 | metadata: 28 | name: frontend 29 | labels: 30 | app: myapp 31 | spec: 32 | type: NodePort 33 | ports: 34 | - port: 80 35 | targetPort: 80 36 | selector: 37 | app: myapp -------------------------------------------------------------------------------- /Section_Services/Exercise 8/deployment-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now link the pods to the Deployment by updating selectors. 2 | # Instruction: Add a property "matchLabels" under selector and copy the labels defined in the pod-definition under it. 3 | # Note: this may not work in play-with-k8s as it runs on 1.8 version of kubernetes 4 | # ------------------------------ 5 | # BEFORE 6 | # ------------------------------ 7 | #apiVersion: apps/v1 8 | #kind: Deployment 9 | #metadata: 10 | # name: frontend 11 | # labels: 12 | # app: mywebsite 13 | # tier: frontend 14 | #spec: 15 | # replicas: 4 16 | # template: 17 | # selector: 18 | 19 | # ------------------------------ 20 | # AFTER 21 | # ------------------------------ 22 | 23 | apiVersion: apps/v1 24 | kind: Deployment 25 | metadata: 26 | name: image-processing-deployment 27 | labels: 28 | app: mywebsite 29 | tier: backend 30 | spec: 31 | replicas: 4 32 | template: 33 | metadata: 34 | name: image-processing-pod 35 | labels: 36 | tier: backend 37 | spec: 38 | containers: 39 | - name: mycustom-image-processing 40 | image: someorg/mycustom-image-processing 41 | selector: 42 | matchLabels: 43 | tier: backend -------------------------------------------------------------------------------- /Section_Services/Exercise 8/service-definition.yml: -------------------------------------------------------------------------------- 1 | # Introduction: Let us now try to create a service-definition.yml file from scratch. This time all in one go. 2 | # You are tasked to create a service to enable the frontend pods to access a backend set of Pods. 3 | 4 | # Instruction: Use the information provided in the below table to create a backend service definition file. Refer to the provided deployment-definition file for information regarding the PODs. 5 | # Service Name: image-processing 6 | # labels: app=> myapp 7 | # type: ClusterIP 8 | # Port on the service: 80 9 | # Port exposed by image processing container: 8080 10 | # 11 | 12 | # ------------------------------ 13 | # BEFORE 14 | # ------------------------------ 15 | 16 | # ------------------------------ 17 | # AFTER 18 | # ------------------------------ 19 | 20 | apiVersion: v1 21 | kind: Service 22 | metadata: 23 | name: image-processing 24 | labels: 25 | app: myapp 26 | spec: 27 | # type: ClusterIP 28 | ports: 29 | - port: 80 30 | targetPort: 8080 31 | selector: 32 | tier: backend -------------------------------------------------------------------------------- /Section_YAML/Exercise_1/playbook.yml: -------------------------------------------------------------------------------- 1 | # Update the food.yml file to add a Vegetable - Carrot 2 | 3 | Fruit: Apple 4 | Drink: Water 5 | Dessert: Cake 6 | Vegetable: Carrot -------------------------------------------------------------------------------- /Section_YAML/Exercise_2/food.yml: -------------------------------------------------------------------------------- 1 | # Update the food.yml file to add a list of Vegetables - Carrot, Tomato, Cucumber 2 | 3 | Fruits: 4 | - Apple 5 | - Banana 6 | - Orange 7 | 8 | Vegetables: 9 | - Carrot 10 | - Tomato 11 | - Cucumber -------------------------------------------------------------------------------- /Section_YAML/Exercise_3/food.yml: -------------------------------------------------------------------------------- 1 | # We have updated the food.yml file with nutrition information for Fruits. 2 | # Similarly update the nutrition information for Vegetables. Use the below table for information 3 | # Vegetable | Calories | Fat | Carbs 4 | # ------------------------------------- 5 | # Carrot | 25 | 0.1 | 6 6 | # Tomato | 22 | 0.2 | 4.8 7 | # Cucumber | 8 | 0.1 | 1.9 8 | 9 | 10 | Fruits: 11 | - Apple: 12 | Calories: 95 13 | Fat: 0.3 14 | Carbs: 25 15 | - Banana: 16 | Calories: 105 17 | Fat: 0.4 18 | Carbs: 27 19 | - Orange: 20 | Calories: 45 21 | Fat: 0.1 22 | Carbs: 11 23 | 24 | Vegetables: 25 | - Carrot: 26 | Calories: 25 27 | Fat: 0.1 28 | Carbs: 6 29 | - Tomato: 30 | Calories: 22 31 | Fat: 0.2 32 | Carbs: 4.8 33 | - Cucumber: 34 | Calories: 8 35 | Fat: 0.1 36 | Carbs: 1.9 37 | -------------------------------------------------------------------------------- /Section_YAML/Exercise_4/employee.yml: -------------------------------------------------------------------------------- 1 | # Jacob is 30 year old Male working as a Systems Engineer at a firm. Represent Jacob's information (Name, Sex, Age, Title) in YAML format. 2 | Employee: 3 | Name: Jacob 4 | Sex: Male 5 | Age: 30 6 | Title: Systems Engineer 7 | -------------------------------------------------------------------------------- /Section_YAML/Exercise_5/employee.yml: -------------------------------------------------------------------------------- 1 | # Update the YAML file to represent the Projects assigned to Jacob. Remember Jacob works on Multiple projects - Automation and Support. So remember to use a list. 2 | Employee: 3 | Name: Jacob 4 | Sex: Male 5 | Age: 30 6 | Title: Systems Engineer 7 | Projects: 8 | - Automation 9 | - Support 10 | -------------------------------------------------------------------------------- /Section_YAML/Exercise_6/employee.yml: -------------------------------------------------------------------------------- 1 | # Update the YAML file to include Jacob's pay slips. Add a new property "Payslips" and create a list of pay slip details. Each payslip detail contains Month and Wage. 2 | # June = 4000 3 | # July = 4500 4 | # August = 4000 5 | #Employee: 6 | # Name: Jacob 7 | # Sex: Male 8 | # Age: 30 9 | # Title: Systems Engineer 10 | # Projects: 11 | # - Automation 12 | # - Support 13 | # Payslips: 14 | # - Month: June 15 | # Wage: 4000 16 | # - Month: July 17 | # Wage: 4500 18 | # - Month: August 19 | # Wage: 4000 20 | 21 | Employee: 22 | Name: Jacob 23 | Sex: Male 24 | Age: 30 25 | Title: Systems Engineer 26 | Projects: 27 | - Automation 28 | - Support 29 | Payslips: 30 | - Month: June 31 | Wage: 4000 32 | - Month: July 33 | Wage: 4500 34 | - Month: August 35 | Wage: 4000 --------------------------------------------------------------------------------