0
0
Kubernetesdevops~20 mins

Creating Pods with kubectl in Kubernetes - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pod Creation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of creating a pod with a missing image field?
You run the command kubectl run mypod --restart=Never --image= with an empty image value. What will kubectl output?
Kubernetes
kubectl run mypod --restart=Never --image=
Aerror: required flag(s) "image" not set
Bpod/mypod created
CWarning: image field is empty, pod created but will fail to start
Dcommand not found
Attempts:
2 left
💡 Hint
The image field is mandatory when creating a pod with kubectl run.
Configuration
intermediate
2:00remaining
Which YAML snippet correctly defines a pod with one container named 'web' running nginx?
Select the correct YAML configuration for a pod named 'web-pod' with a single container named 'web' using the nginx image.
A
apiVersion: v1
kind: Pod
metadata:
  name: web-pod
spec:
  containers:
  - web
  - image: nginx
B
apiVersion: v1
kind: Pod
metadata:
  name: web-pod
spec:
  containers:
    name: web
    image: nginx
C
apiVersion: v1
kind: Pod
metadata:
  name: web-pod
spec:
  containers:
  - name: web
    image: nginx
D
apiVersion: v1
kind: Pod
metadata:
  name: web-pod
spec:
  container:
  - name: web
    image: nginx
Attempts:
2 left
💡 Hint
The containers field must be a list with each container having a name and image.
🔀 Workflow
advanced
2:30remaining
What is the correct sequence to create a pod from a YAML file and verify it is running?
Arrange the steps in the correct order to create a pod from a YAML file named pod.yaml and check its status.
A1,2,4,3
B1,2,3,4
C1,3,2,4
D2,1,3,4
Attempts:
2 left
💡 Hint
First create, then list, then inspect, then optionally delete.
Troubleshoot
advanced
1:30remaining
What error will occur if you try to create a pod with an invalid apiVersion?
You use this YAML snippet to create a pod but the apiVersion is set to 'v2': apiVersion: v2 kind: Pod metadata: name: test-pod spec: containers: - name: test image: busybox command: ['sleep', '3600'] What error will kubectl show?
Aerror: unable to recognize "pod.yaml": no matches for kind "Pod" in version "v2"
Bpod/test-pod created
Cerror: unknown flag: --apiVersion
DWarning: apiVersion v2 deprecated, pod created with warnings
Attempts:
2 left
💡 Hint
apiVersion must be a valid Kubernetes API version.
Best Practice
expert
2:00remaining
Which kubectl command correctly creates a pod named 'fast-pod' with the image 'nginx' and disables restart policy?
Choose the command that creates a pod named 'fast-pod' using the nginx image and ensures the pod will not restart automatically.
Akubectl create pod fast-pod --image=nginx --restart=Always
Bkubectl create pod fast-pod --image=nginx --restart=Never
Ckubectl run fast-pod --image=nginx --restart=Always
Dkubectl run fast-pod --image=nginx --restart=Never
Attempts:
2 left
💡 Hint
The restart policy 'Never' disables automatic pod restarts.