Create three Pods using the nginx image:
kubectl run pod-1 --image=nginx --restart=Never \
--labels=tier=frontend,team=artemidis
kubectl run pod-2 --image=nginx --restart=Never \
--labels=tier=backend,team=artemidis
kubectl run pod-3 --image=nginx --restart=Never \
--labels=tier=backend,team=artemidiskubectl get pods --show-labelsAnnotate pod-1 and pod-3 with the key deployer and use your name as the value:
kubectl annotate pod pod-1 pod-3 deployer="Benjamin Muschko"kubectl describe pod pod-1 pod-3 | grep Annotations:Retrieve all Pods that belong to either the artemidis or aircontrol teams and are categorized as backend services:
kubectl get pods -l tier=backend,'team in (artemidis,aircontrol)' --show-labelsCreate a new Deployment named server-deployment using the image grand-server:1.4.6:
kubectl create deployment server-deployment --image=grand-server:1.4.6kubectl get deployments
kubectl get pods
kubectl describe pod server-deployment-<POD_ID>The Deployment will fail because grand-server:1.4.6 does not exist.
Change the Deployment's image to nginx:
kubectl set image deployment server-deployment grandserver=nginxkubectl rollout history deployments server-deploymentThere should be two revisions:
- Initial Deployment with
grand-server:1.4.6(failed). - Updated Deployment with
nginx.
Create a CronJob named google-ping that runs a curl command every 2 minutes using the nginx image:
kubectl create cronjob google-ping --schedule="*/2 * * * *" \
--image=nginx -- /bin/sh -c 'curl google.com'kubectl get cronjob -wModify the CronJob to retain the last 7 successful executions:
kubectl patch cronjob google-ping --type='merge' -p \
'{"spec": {"successfulJobsHistoryLimit": 7}}'Modify the CronJob to forbid a new execution if the current execution is still running:
kubectl patch cronjob google-ping --type='merge' -p \
'{"spec": {"concurrencyPolicy": "Forbid"}}'- Created and labeled Pods for frontend and backend services.
- Annotated Pods and queried Pods using labels.
- Deployed a failing Deployment, debugged it, and fixed the issue.
- Created and configured a CronJob with execution history and concurrency limits.
This lab covers core Kubernetes resource management, troubleshooting, and batch job scheduling. 🚀