#killer koda and bregman exercies 1. creating a pod `kubectl run nginx --image=nginx` 2. list pods `kubectl get pods` 3. deleting pods `kubectl delete pods nginx` 3. creating a service `kubectl run nginx --image nginx --port=80 --labels="app=dev-nginx` ```yaml apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: dev-nginx ports: - protocol: TCP port: 80 targetPort: 9372 ``` 4. Creating a ReplicaSet ``` apiVersion: apps/v1 kind: ReplicaSet metadata: name: web labels: app: somewebapp type: web spec: replicas: 2 selector: matchLabels: type: web template: metadata: labels: type: web spec: containers: - name: httpd image: registry.redhat.io/rhscl/httpd-24-rhel7 ``` `kubectl apply -f rs.yaml` `kubectl get rs` ``` ## Operating ReplicaSet 1. Create ReplicaSet with 2 Replicas ``` cat >> rs.yaml < running_pods.txt` 4. Remove the label (type=web) from one of the Pods created by the ReplicaSet `kubectl label pod type-` 5. List the pods running? are there more pods? why? `Yes, there is an additional Pod running because once the label (used as a matching selector) was removed, the Pod became independent meaning, it's not controlled by the ReplicaSet anymore and the ReplicaSet was missing replicas based on its definition so, it created a new Pod.` 6. verify `kubectl describe rs web` ## labels and selectors 101 How to list all the Pods with the label "app=web"? How to list all objects labeled as "env=staging"? How to list all deployments from "env=prod" and "type=web"? Solution k get po -l app=web k get all -l env=staging k get deploy -l env=prod,type=web