ExamGecko

Linux Foundation CKA Practice Test - Questions Answers, Page 4

Question list
Search
Search

Question 31

Report
Export
Collapse

Create a pod that echo "hello world" and then exists. Have the pod deleted automatically when it's completed

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

kubectl run busybox --image=busybox -it --rm --restart=Never --

/bin/sh -c 'echo hello world'

kubectl get po # You shouldn't see pod with the name "busybox"

asked 18/09/2024
Sushil Karki
38 questions

Question 32

Report
Export
Collapse

Create a pod with environment variables as var1=value1.Check the environment variable in pod

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

kubectl run nginx --image=nginx --restart=Never --env=var1=value1

# then

kubectl exec -it nginx -- env

# or

kubectl exec -it nginx -- sh -c 'echo $var1'

# or

kubectl describe po nginx | grep value1

asked 18/09/2024
Santanu Roy
34 questions

Question 33

Report
Export
Collapse

Get list of all the pods showing name and namespace with a jsonpath expression.

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

kubectl get pods -o=jsonpath="{.items[*]['metadata.name' , 'metadata.namespace']}"

asked 18/09/2024
Eric De La Vega
41 questions

Question 34

Report
Export
Collapse

Check the image version in pod without the describe command

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

kubectl get po nginx -o

jsonpath='{.spec.containers[].image}{"\n"}'

asked 18/09/2024
Trevore Agee
25 questions

Question 35

Report
Export
Collapse

List the nginx pod with custom columns POD_NAME and POD_STATUS

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

kubectl get po -o=custom-columns="POD_NAME:.metadata.name,

POD_STATUS:.status.containerStatuses[].state"

asked 18/09/2024
Mashudu Abraham
34 questions

Question 36

Report
Export
Collapse

List all the pods sorted by name

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

kubect1 get pods --sort-by=.metadata.name

asked 18/09/2024
Mitchell Mansfield
28 questions

Question 37

Report
Export
Collapse

Create a pod that having 3 containers in it? (Multi-Container)

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

image=nginx, image=redis, image=consul

Name nginx container as "nginx-container"

Name redis container as "redis-container"

Name consul container as "consul-container"

Create a pod manifest file for a container and append container section for rest of the images

kubectl run multi-container --generator=run-pod/v1 --image=nginx --

dry-run -o yaml > multi-container.yaml

# then

vim multi-container.yaml

apiVersion: v1

kind: Pod

metadata:

labels:

run: multi-container

name: multi-container

spec:

containers:

- image: nginx

name: nginx-container

- image: redis

name: redis-container

- image: consul

name: consul-container

restartPolicy: Always

asked 18/09/2024
BETTE SLETTER
35 questions

Question 38

Report
Export
Collapse

Create 2 nginx image pods in which one of them is labelled with env=prod and another one labelled with env=dev and verify the same.

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

kubectl run --generator=run-pod/v1 --image=nginx -- labels=env=prod nginx-prod --dry-run -o yaml >

nginx-prodpod.yaml Now, edit nginx-prod-pod.yaml file and remove entries like "creationTimestamp:

null" "dnsPolicy: ClusterFirst"

vim nginx-prod-pod.yaml

apiVersion: v1

kind: Pod

metadata:

labels:

env: prod

name: nginx-prod

spec:

containers:

- image: nginx

name: nginx-prod

restartPolicy: Always

# kubectl create -f nginx-prod-pod.yaml

kubectl run --generator=run-pod/v1 --image=nginx --

labels=env=dev nginx-dev --dry-run -o yaml > nginx-dev-pod.yaml

apiVersion: v1

kind: Pod

metadata:

labels:

env: dev

name: nginx-dev

spec:

containers:

- image: nginx

name: nginx-dev

restartPolicy: Always

# kubectl create -f nginx-prod-dev.yaml

Verify :

kubectl get po --show-labels

kubectl get po -l env=prod

kubectl get po -l env=dev

asked 18/09/2024
HWANG SEON TAE
43 questions

Question 39

Report
Export
Collapse

Get IP address of the pod – "nginx-dev"

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

Kubect1 get po -o wide

Using JsonPath

kubect1 get pods -o=jsonpath='{range

.items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'

asked 18/09/2024
Zied Nassr
34 questions

Question 40

Report
Export
Collapse

Print pod name and start time to "/opt/pod-status" file

A.
See the solution below.
A.
See the solution below.
Answers
Suggested answer: A

Explanation:

kubect1 get pods -o=jsonpath='{range

.items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'

asked 18/09/2024
ivaylo Skechleiev
36 questions
Total 67 questions
Go to page: of 7