Ckad 5
Ckad 5
Linux-Foundation
Exam Questions CKAD
Certified Kubernetes Application Developer (CKAD) Program
NEW QUESTION 1
Exhibit:
Context
A pod is running on the cluster but it is not responding. Task
The desired behavior is to have Kubemetes restart the pod when an endpoint returns an HTTP 500 on the
/healthz endpoint. The service, probe-pod, should never send traffic to the pod while it is failing. Please complete the following:
• The application has an endpoint, /started, that will indicate if it can accept traffic by returning an HTTP 200. If the endpoint returns an HTTP 500, the application
has not yet finished initialization.
• The application has another endpoint /healthz that will indicate if the application is still working as expected by returning an HTTP 200. If the endpoint returns an
HTTP 500 the application is no longer responsive.
• Configure the probe-pod pod provided to use these endpoints
• The probes should use port 8080
A. Mastered
B. Not Mastered
Answer: A
Explanation:
Solution:
apiVersion:v1 kind:Pod metadata: labels: test:liveness
name:liveness-exec
spec: containers:
-name:liveness
image:k8s.gcr.io/busybox args:
- /bin/sh
- -c
- touch/tmp/healthy;sleep30;rm-rf/tmp/healthy;sleep600
livenessProbe: exec: command:
- cat
- /tmp/healthy initialDelaySeconds:5 periodSeconds:5
In the configuration file, you can see that the Pod has a single Container. The periodSeconds field specifies that the kubelet should perform a liveness probe every
5 seconds. The initialDelaySeconds field tells the kubelet that it should wait 5 seconds before performing the first probe. To perform a probe, the kubelet
executes the command cat /tmp/healthy in the target container. If the command succeeds, it returns 0, and the
kubelet considers the container to be alive and healthy. If the command returns a non-zero value, the kubelet kills the container and restarts it.
When the container starts, it executes this command:
/bin/sh -c"touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600"
For the first 30 seconds of the container's life, there is a /tmp/healthy file. So during the first 30 seconds, the command cat /tmp/healthy returns a success code.
After 30 seconds, cat /tmp/healthy returns a failure co
Create the Pod:
kubectl apply -f https://k8s.io/examples/pods/probe/exec-liveness.yaml Within 30 seconds, view the Pod events:
kubectl describe pod liveness-exec
The output indicates that no liveness probes have failed yet:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ ------
24s 24s 1 {default-scheduler } Normal Scheduled Successfully assigned liveness-exec to worker0
23s 23s 1 {kubelet worker0} spec.containers{liveness} Normal Pulling pulling image "k8s.gcr.io/busybox" 23s 23s 1 {kubelet worker0} spec.containers{liveness}
Normal Pulled Successfully pulled image
"k8s.gcr.io/busybox"
23s 23s 1 {kubelet worker0} spec.containers{liveness} Normal Created Created container with docker id 86849c15382e; Security:[seccomp=unconfined]
23s 23s 1 {kubelet worker0} spec.containers{liveness} Normal Started Started container with docker id 86849c15382e
After 35 seconds, view the Pod events again: kubectl describe pod liveness-exec
At the bottom of the output, there are messages indicating that the liveness probes have failed, and the containers have been killed and recreated.
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ ------
37s 37s 1 {default-scheduler } Normal Scheduled Successfully assigned liveness-exec to worker0
36s 36s 1 {kubelet worker0} spec.containers{liveness} Normal Pulling pulling image "k8s.gcr.io/busybox" 36s 36s 1 {kubelet worker0} spec.containers{liveness}
Normal Pulled Successfully pulled image
"k8s.gcr.io/busybox"
36s 36s 1 {kubelet worker0} spec.containers{liveness} Normal Created Created container with docker id 86849c15382e; Security:[seccomp=unconfined]
36s 36s 1 {kubelet worker0} spec.containers{liveness} Normal Started Started container with docker id 86849c15382e
2s 2s 1 {kubelet worker0} spec.containers{liveness} Warning Unhealthy Liveness probe failed: cat: can't open '/tmp/healthy': No such file or directory
Wait another 30 seconds, and verify that the container has been restarted: kubectl get pod liveness-exec
The output shows that RESTARTS has been incremented: NAME READY STATUS RESTARTS AGE
liveness-exec 1/1 Running 1 1m
NEW QUESTION 2
Exhibit:
Context
You are tasked to create a secret and consume the secret in a pod using environment variables as follow:
Task
• Create a secret named another-secret with a key/value pair; key1/value4
• Start an nginx pod named nginx-secret using container image nginx, and add an environment variable exposing the value of the secret key key 1,
usingCOOL_VARIABLE as the name for the environment variable inside the pod
A. Mastered
B. Not Mastered
Answer: A
Explanation:
Solution:
NEW QUESTION 3
Exhibit:
Given a container that writes a log file in format A and a container that converts log files from format A to format B, create a deployment that runs both containers
such that the log files from the first container are converted by the second container, emitting logs in format B.
Task:
• Create a deployment named deployment-xyz in the default namespace, that:
•Includes a primary
lfccncf/busybox:1 container, named logger-dev
•includes a sidecar Ifccncf/fluentd:v0.12 container, named adapter-zen
•Mounts a shared volume /tmp/log on both containers, which does not persist when the pod is deleted
•Instructs the logger-dev container to run the command
which should output logs to /tmp/log/input.log in plain text format, with example values:
• The adapter-zen sidecar container should read /tmp/log/input.log and output the data to /tmp/log/output.* in Fluentd JSON format. Note that no knowledge of
Fluentd is required to complete this task: all you will need to achieve this is to create the ConfigMap from the spec file provided at /opt/KDMC00102/fluentd-
configma p.yaml , and mount that ConfigMap to /fluentd/etc in the adapter-zen sidecar container
A. Mastered
B. Not Mastered
Answer: A
Explanation:
Solution:
NEW QUESTION 4
Context
Anytime a team needs to run a container on Kubernetes they will need to define a pod within which to run the container.
Task
Please complete the following:
• Create a YAML formatted pod manifest
/opt/KDPD00101/podl.yml to create a pod named app1 that runs a container named app1cont using image Ifccncf/arg-output
with these command line arguments: -lines 56 -F
• Create the pod with the kubect1 command using the YAML file created in the previous step
• When the pod is running display summary data about the pod in JSON format using the kubect1 command and redirect the output to a file named
/opt/KDPD00101/out1.json
• All of the files you need to work with have been created, empty, for your convenience
A. Mastered
B. Not Mastered
Answer: A
Explanation:
Solution:
NEW QUESTION 5
Exhibit:
Task
You have rolled out a new pod to your infrastructure and now you need to allow it to communicate with the web and storage pods but nothing else. Given the
running pod kdsn00201 -newpod edit it to use a network policy that will allow it to send and receive traffic only to and from the web and storage pods.
A. Mastered
B. Not Mastered
Answer: A
Explanation:
NEW QUESTION 6
Exhibit:
Context
As a Kubernetes application developer you will often find yourself needing to update a running application. Task
Please complete the following:
• Update theappdeployment in the kdpd00202 namespace with a maxSurge of5% and a maxUnavailable of2%
• Perform a rolling update of the web1 deployment, changing the Ifccncf/ngmx image version to 1.13
• Roll back theappdeployment to the previous version
A. Mastered
B. Not Mastered
Answer: A
Explanation:
Solution:
NEW QUESTION 10
......
* CKAD Most Realistic Questions that Guarantee you a Pass on Your FirstTry
* CKAD Practice Test Questions in Multiple Choice Formats and Updatesfor 1 Year