Scenario II
1.
You need to create a new Pod named 'web-app' in the default namespace. Which imperative command should you use?
kubectl run web-app --image=nginx
kubectl create pod web-app --image=nginx
kubectl apply -f pod-definition.yaml
kubectl run web-app --image=nginx
2.
You have a Pod named 'app-pod' with a container named 'app-container.' You need to execute a command 'echo 'Hello, Kubernetes!'' within the container. What imperative command should you use?
kubectl exec app-pod -c app-container -- echo 'Hello, Kubernetes!'
kubectl run app-pod --image=ubuntu -- echo 'Hello, Kubernetes!'
kubectl create pod app-pod --image=ubuntu -- echo 'Hello, Kubernetes!'
kubectl exec app-pod -- echo 'Hello, Kubernetes!'
3.
You have a Pod named 'web-app' that is running multiple containers. You need to view the logs for the container named 'app-container.' What imperative command should you use?
kubectl logs web-app -c app-container
kubectl describe pod web-app
kubectl get logs web-app -c app-container
kubectl pod logs web-app -c app-container
4.
You have a Deployment named 'nginx-deployment,' and you need to scale it to three replicas. What imperative command should you use?
kubectl scale deployment nginx-deployment --replicas=3
kubectl update deployment nginx-deployment --replicas=3
kubectl apply -f deployment-definition.yaml
kubectl scale deploy nginx-deployment --replicas=3
5.
You have a Deployment named 'app-deployment' with an updated container image, and you need to roll back to the previous version. What imperative command should you use?
kubectl rollout undo deployment app-deployment
kubectl rollout history deployment app-deployment
kubectl apply -f deployment-definition.yaml
kubectl rollback deployment app-deployment
6.
You need to delete a Pod named 'app-pod' without waiting for it to gracefully terminate. What imperative command should you use?
kubectl delete pod app-pod --grace-period=0 --force
kubectl remove pod app-pod --force
kubectl delete pod app-pod --grace-period=0
kubectl force-delete pod app-pod
7.
You have a Pod named 'frontend-pod' with a container named 'web-container,' and you need to view the environment variables set in that container. What imperative command should you use?
kubectl exec frontend-pod -c web-container -- printenv
kubectl get env frontend-pod -c web-container
kubectl describe pod frontend-pod -c web-container
kubectl logs frontend-pod -c web-container
8.
You want to get a list of all the services in the 'prod' namespace. What imperative command should you use?
kubectl get services -n prod
kubectl list services -n prod
kubectl describe services -n prod
kubectl show services -n prod
9.
You need to check the resource utilization of a Pod named 'monitor-pod' and view the CPU and memory metrics. What imperative command should you use?
kubectl top pod monitor-pod
kubectl describe pod monitor-pod
kubectl get resources monitor-pod
kubectl logs monitor-pod
10.
You have a Pod named 'nginx-pod' that is not running correctly, and you need to restart it. What imperative command should you use?
kubectl delete pod nginx-pod
kubectl restart pod nginx-pod
kubectl apply -f pod-definition.yaml
kubectl rollout restart pod nginx-pod
11.
You need to expose a Pod named 'web-app' using a NodePort service. What imperative command should you use?
kubectl expose pod web-app --type=NodePort --port=80
kubectl create service nodeport web-app --tcp=80:80
kubectl apply -f service-definition.yaml
kubectl expose pod web-app --type=NodePort --target-port=80
12.
You have a Pod named 'db-pod' that is running a database container, and you need to copy a file named 'backup.sql' from your local machine to the '/data' directory in the container. What imperative command should you use?
kubectl cp backup.sql db-pod:/data
kubectl copy backup.sql db-pod:/data
kubectl scp backup.sql db-pod:/data
kubectl upload backup.sql db-pod:/data
13.
You have a ConfigMap named 'app-config' that you want to update with new key-value pairs. What imperative command should you use?
kubectl create configmap app-config --from-file=new-config-file.properties
kubectl apply -f configmap-definition.yaml
kubectl edit configmap app-config
kubectl edit configmap app-config --from-literal=new-key=new-value
14.
You have a Pod named 'worker-pod' running multiple containers, and you need to execute an interactive shell within the 'worker-container.' What imperative command should you use?
kubectl exec -it worker-pod -c worker-container -- /bin/sh
kubectl shell worker-pod -c worker-container
kubectl run -it worker-pod --image=ubuntu /bin/sh
kubectl start shell worker-pod -c worker-container
15.
You need to check the status of a Deployment named 'app-deployment' and view details about its replicas. What imperative command should you use?
kubectl describe deployment app-deployment
kubectl status deployment app-deployment
kubectl get replicas app-deployment
kubectl rollout status deployment app-deployment
16.
You have a Pod named 'api-pod' running in the 'backend' namespace, and you need to execute a command 'curl localhost' within that Pod. What imperative command should you use?
kubectl exec api-pod -n backend -- curl localhost
kubectl run api-pod -n backend --image=ubuntu -- curl localhost
kubectl exec api-pod -n backend --command='curl localhost'
kubectl run api-pod -n backend --command='curl localhost'
17.
You have a Pod named 'db-pod' with a container named 'database-container,' and you need to open an interactive shell within that container. What imperative command should you use?
kubectl exec -it db-pod -c database-container -- /bin/sh
kubectl open-shell db-pod -c database-container
kubectl run -it db-pod --image=ubuntu /bin/sh
kubectl start shell db-pod -c database-container
18.
You need to view the logs for a Pod named 'backend-pod' with multiple containers, and you want to tail the logs for the 'app-container.' What imperative command should you use?
kubectl logs -f backend-pod -c app-container
kubectl describe pod backend-pod -c app-container
kubectl get logs -f backend-pod -c app-container
kubectl logs backend-pod -c app-container --follow
19.
You have a Pod named 'web-pod' with multiple containers, and you need to execute a command 'cat /etc/nginx/nginx.conf' within the 'nginx-container.' What imperative command should you use?
kubectl exec web-pod -c nginx-container -- cat /etc/nginx/nginx.conf
kubectl run web-pod --image=nginx -- cat /etc/nginx/nginx.conf
kubectl exec web-pod -- cat /etc/nginx/nginx.conf
kubectl create pod web-pod --image=nginx -- cat /etc/nginx/nginx.conf