Use this page to check your work from your Mini-CKAD challenge! Also available are the answers to each task.
-
Create a new namespace called challenge
Correctness Check:
student@bchd:~$kubectl get ns | grep challengechallenge Active 13mSOLUTION
student@bchd:~$kubectl create ns challenge
-
Create a context named challenge-context that uses the following:
cluster: kubernetes-the-alta3-way namespace: challenge user: adminCorrectness Check:
student@bchd:~$kubectl config view | grep "name: challenge-context" -B 3cluster: kubernetes-the-alta3-way namespace: challenge user: admin name: challenge-contextSOLUTION
student@bchd:~$kubectl config set-context challenge-context --user=admin --namespace=challenge --cluster=kubernetes-the-alta3-way
-
Make challenge-context your current context. ALL OBJECTS SHOULD BE CREATED IN THIS CONTEXT!
Correctness Check:
All Pods/Deployments/Services/etc. below are in the challenge namespace.
SOLUTION
student@bchd:~$kubectl config use-context challenge-context
-
Create a single container pod named challengepod. Use an nginx image, version 1.18.0.
Correctness Check:
student@bchd:~$kubectl describe pod challengepod -n challenge | grep Image:Image: nginx:1.18.0SOLUTION
student@bchd:~$kubectl run challengepod --image=nginx:1.18.0
-
Inspect the pod using the
getanddescribecommands.SOLUTION
student@bchd:~$kubectl get pod challengepod -n challengestudent@bchd:~$kubectl describe pod challengepod -n challenge
-
Output your pod description into a file named
poddesc.txt. Save it to/home/student/static/.Correctness Check:
student@bchd:~$cat /home/student/static/poddesc.txt[...] QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 25m default-scheduler Successfully assigned challenge/challengepod to node-1 Normal Pulled 25m kubelet, node-1 Container image "nginx:1.18.0" already present on machine Normal Created 25m kubelet, node-1 Created container challengepod Normal Started 25m kubelet, node-1 Started container challengepodSOLUTION
student@bchd:~$kubectl describe pod challengepod -n challenge > /home/student/static/poddesc.txt
-
Convert your the manifest you used to create your Pod in step 4 into a Deployment manifest, then create it. Your deployment must:
-
Be named challengedeploy
-
Create 4 replicas.
-
Always be created with the latest version of nginx.
-
All pods created by this manifest should be scheduled on node-3.
-
Label the deployment with the label challenge: met.
-
Annotate the deployment with the following:
kubernetes: is super: easy i: am so: awesome
Correctness Check:
student@bchd:~$kubectl get pods -o wide -n challenge | grep challengedeploychallengedeploy-79cd84ccf8-2474t 1/1 Running 0 45m 192.168.139.81 node-3 <none> <none> challengedeploy-79cd84ccf8-hrfx9 1/1 Running 0 45m 192.168.139.82 node-3 <none> <none> challengedeploy-79cd84ccf8-kgmm9 1/1 Running 0 45m 192.168.139.84 node-3 <none> <none> challengedeploy-79cd84ccf8-kksm9 1/1 Running 0 45m 192.168.139.83 node-3 <none> <none>student@bchd:~$kubectl describe deploy challengedeploy -n challenge | grep Image:Image: nginxstudent@bchd:~$kubectl describe deploy challengedeploy -n challenge | grep Annotations: -A 4Annotations: deployment.kubernetes.io/revision: 1 i: am kubernetes: is so: awesome super: easystudent@bchd:~$kubectl describe deploy challengedeploy -n challenge | grep Labels:Labels: challenge=metSOLUTION
student@bchd:~$vim deploychallenge.ymlapiVersion: apps/v1 kind: Deployment metadata: name: challengedeploy labels: challenge: met annotations: kubernetes: is super: easy i: am so: awesome spec: replicas: 4 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: nodeName: node-3 containers: - name: nginx image: nginx ports: - containerPort: 80
student@bchd:~$kubectl apply -f deploychallenge.yml
-
-
Expose your deployment with a ClusterIP service.
Correctness Check:
student@bchd:~$kubectl get svc challengedeploy -n challengeYOUR OUTPUT WILL BE DIFFERENT NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE challengedeploy ClusterIP 172.16.3.243 <none> 80/TCP 2s- Copy the
CLUSTER-IPaddress in that output.
student@bchd:~$ssh node-1student@node-1:~$curl USE_YOUR_IP_ADDRESS:80<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> [...]SOLUTION
student@bchd:~$kubectl expose deploy challengedeploy
- Copy the
-
Create a PersistentVolume with the following parameters:
- 2GB storage
- name: persistentchallenge
- storage class: challenge
- host path: /mnt/data
Correctness Check:
student@bchd:~$kubectl get pv -n challengeNAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE persistentchallenge 2Gi RWO Retain Bound challenge/persistentclaimchallenge challenge 33mSOLUTION
student@bchd:~$vim PVchallenge.ymlapiVersion: v1 kind: PersistentVolume metadata: name: persistentchallenge labels: type: local spec: storageClassName: challenge capacity: storage: 2Gi accessModes: - ReadWriteOnce hostPath: path: "/mnt/data"
student@bchd:~$kubectl apply -f PVchallenge.ymlCreate a PersistentVolumeClaim with the following parameters:
- 1GB storage
- name: persistentclaimchallenge
- ReadWriteOnce permission
Correctness Check:
student@bchd:~$kubectl get pvc -n challengeNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE persistentclaimchallenge Bound persistentchallenge 2Gi RWO challenge 32mSOLUTION
student@bchd:~$vim PVCchallenge.ymlapiVersion: v1 kind: PersistentVolumeClaim metadata: name: persistentclaimchallenge spec: storageClassName: challenge accessModes: - ReadWriteOnce resources: requests: storage: 1Gi
student@bchd:~$kubectl apply -f PVCchallenge.ymlMount this PersistentVolumeClaim into a pod named
storagepodletusing the imagenginx.Correctness Check:
student@bchd:~$kubectl get pod storagepodlet -n challengeNAME READY STATUS RESTARTS AGE storagepodlet 1/1 Running 0 34mSOLUTION
student@bchd:~$vim storagepodlet.ymlapiVersion: v1 kind: Pod metadata: name: storagepodlet spec: containers: - name: myfrontend image: nginx volumeMounts: - mountPath: "/var/www/html" name: mypd volumes: - name: mypd persistentVolumeClaim: claimName: persistentclaimchallenge
student@bchd:~$kubectl apply -f storagepodlet.yml
student@bchd:~$ kubectl config use-context kubernetes-the-alta3-way