CKA Practice Exam: Part 1

Hands-On Lab

 

Photo of Chad Crowell

Chad Crowell

DevOps Training Architect II in Content

Length

01:30:00

Difficulty

Intermediate

Services are an important part of accessing pods in Kubernetes. They ensure the ephemeral nature of pods do not interrupt the end user experience. In this hands-on lab, you’ll be tasked with creating a deployment and a service, making sure you can access the application running on those pods without the potential of service interruptions. This will simulate a question you may receive on the Certified Kubernetes Administrator (CKA) exam.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

CKA Practice Exam: Part 1

In this hands-on lab, you’ll be tasked with creating a deployment and a service, making sure you can access the application running on those pods without the potential of service interruptions. This will simulate a question you may receive on the Certified Kubernetes Administrator (CKA) exam.

Log in to the Kube Master server using the credentials on the lab page (either in your local terminal, using the Instant Terminal feature, or using the public IP), and work through the objectives listed.

Create a deployment named webapp in the web namespace and verify connectivity.

  1. Create a namespace named web:

    kubectl create ns web
  2. Create a deployment named webapp:

    kubectl run webapp --image=linuxacademycontent/podofminerva:latest --port=80 --replicas=3 -n web

Create a service named web-service and forward traffic from the pods.

  1. Get the IP address of a pod that’s a part of the deployment:

    kubectl get po -o wide -n web
  2. Create a temporary pod with a shell to its container:

    kubectl run busybox --image=busybox --rm -it --restart=Never -- sh
  3. Use the following command (from the container’s shell) to send a request to the web pod:

    wget -O- <pod_ip_address>:80
  4. Exit out of the busybox pod:

    exit
  5. Create the YAML for the service named web-service:

    kubectl expose deployment/webapp --port=80 --target-port=80 --type=NodePort -n web --dry-run -o yaml > web-service.yaml

    This will save time for you on the exam, as it creates a template so you don't have to create the YAML from scratch.

  6. Use Vim to add the namespace and the NodePort to the YAML:

    vim web-service.yaml

    Change the name to web-service, add the namespace web, and add nodePort: 30080.

  7. Create the service:

    kubectl apply -f web-service.yaml
  8. Verify that the service is responding on the correct port:

    curl localhost:30080
  9. Modify the deployment:

    kubectl edit deploy webapp -n web
  10. Add the liveness probe and the readiness probe:

    livenessProbe:
      httpGet:
        path: /healthz
        port: 8081
    readinessProbe:
      httpGet:
        path: /
        port: 80
  11. Check if the pods are running:

    kubectl get po -n web
  12. Check if the probes were added to the pods:

    kubectl get po <pod_name> -o yaml -n web --export

Conclusion

Congratulations on completing this portion of the practice exam!