- Lab
- A Cloud Guru
CKA Practice Exam: Part 1
Services are an important part of accessing pods in Kubernetes. They ensure that the ephemeral nature of pods does 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.
Path Info
Table of Contents
-
Challenge
Create a Deployment Named webapp in the web Namespace and Verify Connectivity
-
Use the following command to create a namespace named
web
:kubectl create ns web
-
Use the following command to create a deployment named
webapp
:kubectl run webapp --image=linuxacademycontent/podofminerva:latest --port=80 --replicas=3 -n web
-
-
Challenge
Create a Service Named web-service and Forward Traffic from the Pods
-
Use the following command to get the IP address of a pod that’s a part of the deployment:
kubectl get po -o wide -n web
-
Use the following command to create a temporary pod with a shell to its container:
kubectl run busybox --image=busybox --rm -it --restart=Never -- sh
-
Use the following command (from the container’s shell) to send a request to the web pod:
wget -O- <pod_ip_address>:80
-
Use the following command to 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
-
Use Vim to add the namespace and the NodePort to the YAML:
vim web-service.yaml
Change the name to
web-service
, add the namespaceweb
, and addnodePort: 30080
. -
Use the following command to create the service:
kubectl apply -f web-service.yaml
-
Use the following command to verify that the service is responding on the correct port:
curl localhost:30080
-
Use the following command to modify the deployment:
kubectl edit deploy webapp -n web
-
Add the liveness probe and the readiness probe:
livenessProbe: httpGet: path: /healthz port: 8081 readinessProbe: httpGet: path: / port: 80
-
Use the following command to check if the pods are running:
kubectl get po -n web
-
Use the following command to check if the probes were added to the pods:
kubectl get po <pod_name> -o yaml -n web --export
-
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.