Exam4Training

CNCF CKA Certified Kubernetes Administrator Online Training

Question #1

CORRECT TEXT

Perform the following tasks:

✑ Add an init container to hungry-bear (which has been defined in spec file /opt/KUCC00108/pod-spec-KUCC00108.yaml)

✑ The init container should create an empty file named/workdir/calm.txt

✑ If /workdir/calm.txt is not detected, the pod should exit

✑ Once the spec file has been updated with the init container definition, the pod should be created

Reveal Solution Hide Solution

Correct Answer: solution



Question #2

CORRECT TEXT

Create a deployment spec file that will:

✑ Launch 7 replicas of the nginx Image with the labelapp_runtime_stage=dev

✑ deployment name: kual00201

Save a copy of this spec file to /opt/KUAL00201/spec_deployment.yaml

(or /opt/KUAL00201/spec_deployment.json).

When you are done, clean up (delete) any new Kubernetes API object that you produced during this task.

Reveal Solution Hide Solution

Correct Answer: solution



Question #3

CORRECT TEXT

From the pod label name=cpu-utilizer, find pods running high CPU workloads and write the name of the pod consuming most CPU to the file /opt/KUTR00102/KUTR00102.txt (which already exists).

Reveal Solution Hide Solution

Correct Answer: solution



Question #4

CORRECT TEXT

Create a Kubernetes secret as follows:

✑ Name: super-secret

✑ password: bob

Create a pod named pod-secrets-via-file, using the redis Image, which mounts a secret named super-secret at /secrets.

Create a second pod named pod-secrets-via-env, using the redis Image, which exports password as CONFIDENTIAL

Reveal Solution Hide Solution

Correct Answer: solution



Question #5

CORRECT TEXT

Score: 7%

Task

Create a new nginx Ingress resource as follows:

• Name: ping

• Namespace: ing-internal

• Exposing service hi on path /hi using service port 5678

Reveal Solution Hide Solution

Correct Answer: Solution:

vi ingress.yaml

#

apiVersion: networking.k8s.io/v1

kind: Ingress metadata: name: ping

namespace: ing-internal

spec:

rules:

– http:

paths:

– path: /hi pathType: Prefix backend: service: name: hi

port:

number: 5678

#

kubectl create -f ingress.yaml

Question #6

CORRECT TEXT

A Kubernetes worker node, named wk8s-node-0 is in state NotReady. Investigate why this is the case, and perform any appropriate steps to bring the node to a Ready state, ensuring that any changes are made permanent.

You can ssh to the failed node using:

[student@node-1] $ | ssh Wk8s-node-0

You can assume elevated privileges on the node with the following command:

[student@w8ks-node-0] $ | sudo Ci

Reveal Solution Hide Solution

Correct Answer: solution



Question #7

CORRECT TEXT

Ensure a single instance of pod nginx is running on each node of the Kubernetes cluster where nginx also represents the Image name which has to be used. Do not

override any taints currently in place.

Use DaemonSet to complete this task and use ds-kusc00201 as DaemonSet name.

Reveal Solution Hide Solution

Correct Answer: solution



Question #8

CORRECT TEXT

Create and configure the service front-end-service so it’s accessiblethrough NodePort and routes to the existing pod named front-end.

Reveal Solution Hide Solution

Correct Answer: solution



Question #9

CORRECT TEXT

Scale the deployment webserver to 6 pods.

Reveal Solution Hide Solution

Correct Answer: solution



Question #10

CORRECT TEXT

Check to see how many worker nodes are ready (not including nodes tainted NoSchedule) and write the number to /opt/KUCC00104/kucc00104.txt.

Reveal Solution Hide Solution

Correct Answer: solution



Question #11

CORRECT TEXT

Score: 4%

Context

You have been asked to create a new ClusterRole for a deployment pipeline and bind it to a specific ServiceAccount scoped to a specific namespace.

Task

Create a new ClusterRole named deployment-clusterrole, which only allows to create the following resource types:

• Deployment

• StatefulSet

• DaemonSet

Create a new ServiceAccount named cicd-token in the existing namespace app-team1.

Bind the new ClusterRole deployment-clusterrole lo the new ServiceAccount cicd-token, limited to the namespace app-team1.

Reveal Solution Hide Solution

Correct Answer: Solution:

Task should be complete on node k8s -1 master, 2 worker for this connect use command [student@node-1] > ssh k8s

kubectl create clusterrole deployment-clusterrole –verb=create — resource=deployments,statefulsets,daemonsets

kubectl create serviceaccount cicd-token –namespace=app-team1

kubectl create rolebinding deployment-clusterrole –clusterrole=deployment-clusterrole — serviceaccount=default:cicd-token –namespace=app-team1

Question #12

CORRECT TEXT

Score: 5%

Task

From the pod label name=cpu-utilizer, find pods running high CPU workloads and write the name of the pod consuming most CPU to the file /opt/KUTR00401/KUTR00401.txt (which already exists).

Reveal Solution Hide Solution

Correct Answer: Solution:

kubectl top -l name=cpu-user -A

echo ‘pod name’>> /opt/KUT00401/KUT00401.txt

Question #13

CORRECT TEXT

Score: 4%

Task

Schedule a pod as follows:

• Name: nginx-kusc00401

• Image: nginx

• Node selector: disk=ssd

Reveal Solution Hide Solution

Correct Answer: Solution:

#yaml

apiVersion: v1

kind: Pod

metadata:

name: nginx-kusc00401

spec:

containers:

– name: nginx image: nginx imagePullPolicy: IfNotPresent nodeSelector:

disk: spinning

#

kubectl create -f node-select.yaml

Question #14

CORRECT TEXT

Score: 7%

Task

Given an existing Kubernetes cluster running version 1.20.0, upgrade all of the Kubernetes control plane and node components on the master node only to version 1.20.1.

Be sure to drain the master node before upgrading it and uncordon it after the upgrade.

You are also expected to upgrade kubelet and kubectl on the master node.

Reveal Solution Hide Solution

Correct Answer: SOLUTION:

[student@node-1] > ssh ek8s

kubectl cordon k8s-master

kubectl drain k8s-master –delete-local-data –ignore-daemonsets –force

apt-get install kubeadm=1.20.1-00 kubelet=1.20.1-00 kubectl=1.20.1-00 — disableexcludes=kubernetes

kubeadm upgrade apply 1.20.1 –etcd-upgrade=false

systemctl daemon-reload

systemctl restart kubelet

kubectl uncordon k8s-master

Question #15

CORRECT TEXT

Create a deployment as follows:

✑ Name: nginx-random

✑ Exposed via a service nginx-random

✑ Ensure that the service & pod are accessible via their respective DNS records

✑ The container(s) within any pod(s) running as a part of this deployment should use the nginx Image

Next, use the utility nslookup to look up the DNS records of the service & pod and write the output to /opt/KUNW00601/service.dns and /opt/KUNW00601/pod.dns respectively.

Reveal Solution Hide Solution

Correct Answer: Solution:



Question #16

CORRECT TEXT

Create an nginx pod and list the pod with different levels of verbosity

Reveal Solution Hide Solution

Correct Answer: // create a pod

kubectl run nginx –image=nginx –restart=Never –port=80

// List the pod with different verbosity kubectl get po nginx –v=7

kubectl get po nginx –v=8 kubectl get po nginx –v=9

Question #17

CORRECT TEXT

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

Reveal Solution Hide Solution

Correct Answer: kubect1 get pods -o=jsonpath='{range items[*]}{.metadata.name}{"t"}{.status.podIP}{"n"}{end}’
Question #18

CORRECT TEXT

Score:7%

Task

Create a new PersistentVolumeClaim

• Name: pv-volume

• Class: csi-hostpath-sc

• Capacity: 10Mi

Create a new Pod which mounts the PersistentVolumeClaim as a volume:

• Name: web-server

• Image: nginx

• Mount path: /usr/share/nginx/html

Configure the new Pod to have ReadWriteOnce access on the volume.

Finally, using kubectl edit or kubectl patch expand the PersistentVolumeClaim to a capacity of 70Mi and record that change.

Reveal Solution Hide Solution

Correct Answer: Solution:

vi pvc.yaml storageclass pvc apiVersion: v1

kind: PersistentVolumeClaim

metadata:

name: pv-volume

spec:

accessModes:

– ReadWriteOnce volumeMode: Filesystem resources:

requests: storage: 10Mi storageClassName: csi-hostpath-sc

# vi pod-pvc.yaml apiVersion: v1 kind: Pod metadata: name: web-server spec: containers:

– name: web-server

image: nginx volumeMounts:

– mountPath: "/usr/share/nginx/html"

name: my-volume volumes:

– name: my-volume persistentVolumeClaim: claimName: pv-volume

# craete

kubectl create -f pod-pvc.yaml

#edit

kubectl edit pvc pv-volume –record

Question #19

CORRECT TEXT

Create a file:

/opt/KUCC00302/kucc00302.txt that lists all pods that implement service baz in namespace development.

The format of the file should be one pod name per line.

Reveal Solution Hide Solution

Correct Answer: solution



Question #20

CORRECT TEXT

Create a pod as follows:

✑ Name: non-persistent-redis

✑ container Image: redis

✑ Volume with name: cache-control

✑ Mount path: /data/redis

The pod should launch in the staging namespace and the volume must not be persistent.

Reveal Solution Hide Solution

Correct Answer: solution



Exit mobile version