[Apr-2023] Pass Linux Foundation CKA Exam in First Attempt Guaranteed! [Q39-Q55]

Share

[Apr-2023] Pass Linux Foundation CKA Exam in First Attempt Guaranteed!

Full CKA Practice Test and 68 unique questions with explanations waiting just for you, get it now!

NEW QUESTION # 39
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.

Answer:

Explanation:
See the solution below.
Explanation
solution
F:\Work\Data Entry Work\Data Entry\20200827\CKA\10 B.JPG

F:\Work\Data Entry Work\Data Entry\20200827\CKA\10 C.JPG


NEW QUESTION # 40
Scale the deployment to 5 replicas

Answer:

Explanation:
kubectl scale deployment webapp -replicas=5 //Verify kubectl get deploy kubectl get po,rs


NEW QUESTION # 41
Create an nginx pod and set an env value as 'var1=val1'. Check the env value existence within the pod

  • A. kubectl run nginx --image=nginx --restart=Never --env=var1=val1
    # then
    kubectl exec -it nginx -- env
    # or
    kubectl run nginx --restart=Never --image=nginx --env=var1=val1
    -it --rm -- env
  • B. kubectl run nginx --image=nginx --restart=Never --env=var1=val1
    # then
    kubectl exec -it nginx -- env
    # or
    kubectl exec -it nginx -- sh -c 'echo $var1'
    # or
    kubectl describe po nginx | grep val1
    # or
    kubectl run nginx --restart=Never --image=nginx --env=var1=val1
    -it --rm - env

Answer: B


NEW QUESTION # 42
Create a persistent volume with name app-data, of capacity 2Gi and access mode ReadWriteMany. The type of volume is hostPath and its location is /srv/app-data.

Answer:

Explanation:
See the solution below.
Explanation
solution
Persistent Volume
A persistent volume is a piece of storage in a Kubernetes cluster. PersistentVolumes are a cluster-level resource like nodes, which don't belong to any namespace. It is provisioned by the administrator and has a particular file size. This way, a developer deploying their app on Kubernetes need not know the underlying infrastructure. When the developer needs a certain amount of persistent storage for their application, the system administrator configures the cluster so that they consume the PersistentVolume provisioned in an easy way.
Creating Persistent Volume
kind: PersistentVolumeapiVersion: v1metadata: name: spec: capacity: # defines the capacity of PV we are creating storage: 2Gi #the amount of storage we are tying to claim accessModes: # defines the rights of the volume we are creating - ReadWriteMany " # path to which we are creating the volume Challenge Create a Persistent Volume named ReadWriteMany, storage classname shared, 2Gi of storage capacity and the host path

2. Save the file and create the persistent volume.
Image for post

3. View the persistent volume.

Our persistent volume status is available meaning it is available and it has not been mounted yet. This status will change when we mount the persistentVolume to a persistentVolumeClaim.
PersistentVolumeClaim
In a real ecosystem, a system admin will create the PersistentVolume then a developer will create a PersistentVolumeClaim which will be referenced in a pod. A PersistentVolumeClaim is created by specifying the minimum size and the access mode they require from the persistentVolume.
Challenge
Create a Persistent Volume Claim that requests the Persistent Volume we had created above. The claim should request 2Gi. Ensure that the Persistent Volume Claim has the same storageClassName as the persistentVolume you had previously created.
kind: PersistentVolumeapiVersion: v1metadata: name:
spec:
accessModes: - ReadWriteMany
requests: storage: 2Gi
storageClassName: shared
2. Save and create the pvc
njerry191@cloudshell:~ (extreme-clone-2654111)$ kubect1 create -f app-data.yaml persistentvolumeclaim/app-data created
3. View the pvc
Image for post

4. Let's see what has changed in the pv we had initially created.
Image for post

Our status has now changed from available to bound.
5. Create a new pod named myapp with image nginx that will be used to Mount the Persistent Volume Claim with the path /var/app/config.
Mounting a Claim
apiVersion: v1kind: Podmetadata: creationTimestamp: null name: app-dataspec: volumes: - name:congigpvc persistenVolumeClaim: claimName: app-data containers: - image: nginx name: app volumeMounts: - mountPath: "/srv/app-data " name: configpvc


NEW QUESTION # 43
Deploy a pod with image=redis on a node with label disktype=ssd

  • A. // Get list of nodes
    kubectl get nodes
    //Get node with the label disktype=ssd
    kubectl get no -l disktype=ssd
    // Create a sample yaml file
    kubectl run node-redis --generator=run-pod/v1 --image=redis --dry
    run -o yaml > test-redis.yaml
    // Edit test-redis.yaml file and add nodeSelector
    vim test-redis.yaml
    apiVersion: v1
    - name: node-redis
    image: redis
    imagePullPolicy: IfNotPresent
    kubectl apply -f test-redis.yaml
    / // Verify
    K kubectl get po -o wide
  • B. // Get list of nodes
    kubectl get nodes
    //Get node with the label disktype=ssd
    kubectl get no -l disktype=ssd
    // Create a sample yaml file
    kubectl run node-redis --generator=run-pod/v1 --image=redis --dry
    run -o yaml > test-redis.yaml
    // Edit test-redis.yaml file and add nodeSelector
    vim test-redis.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: redis
    spec:
    nodeSelector:
    disktype: ssd
    containers:
    - name: node-redis
    image: redis
    imagePullPolicy: IfNotPresent
    kubectl apply -f test-redis.yaml
    / // Verify
    K kubectl get po -o wide

Answer: B


NEW QUESTION # 44
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.

Answer:

Explanation:
See the solution below.
Explanation
Solution:
Task should be complete on node -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


NEW QUESTION # 45
Configure the kubelet systemd- managed service, on the node labelled with name=wk8s-node-1, to launch a pod containing a single container of Image httpd named webtool automatically. Any spec files required should be placed in the /etc/kubernetes/manifests directory on the node.
You can ssh to the appropriate node using:
[student@node-1] $ ssh wk8s-node-1
You can assume elevated privileges on the node with the following command:
[student@wk8s-node-1] $ | sudo -i

Answer:

Explanation:
See the solution below.
Explanation
solution
F:\Work\Data Entry Work\Data Entry\20200827\CKA\21 C.JPG

F:\Work\Data Entry Work\Data Entry\20200827\CKA\21 D.JPG

F:\Work\Data Entry Work\Data Entry\20200827\CKA\21 E.JPG

F:\Work\Data Entry Work\Data Entry\20200827\CKA\21 F.JPG

F:\Work\Data Entry Work\Data Entry\20200827\CKA\21 G.JPG


NEW QUESTION # 46
List all the pods sorted by created timestamp

Answer:

Explanation:
kubect1 get pods--sort-by=.metadata.creationTimestamp


NEW QUESTION # 47
View certificate details in /etc/kubernetes/pki

Answer:

Explanation:
// Verify Public Key / Certificate file Openssl x509 -in certificate.crt -noout -text // Verify Private Key Openssl rsa -in "private-key" -check // Verify CSR Openssl req -text -noout -verify


NEW QUESTION # 48
Pause the rollout of the deployment

Answer:

Explanation:
kubectl rollout pause deploy webapp


NEW QUESTION # 49
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

Answer:

Explanation:
See the solution below.
Explanation
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


NEW QUESTION # 50
Score: 7%

Task
Reconfigure the existing deployment front-end and add a port specification named http exposing port 80/tcp of the existing container nginx.
Create a new service named front-end-svc exposing the container port http.
Configure the new service to also expose the individual Pods via a NodePort on the nodes on which they are scheduled.

Answer:

Explanation:
See the solution below.
Explanation
Solution:
kubectl get deploy front-end
kubectl edit deploy front-end -o yaml
#port specification named http
#service.yaml
apiVersion: v1
kind: Service
metadata:
name: front-end-svc
labels:
app: nginx
spec:
ports:
- port: 80
protocol: tcp
name: http
selector:
app: nginx
type: NodePort
# kubectl create -f service.yaml
# kubectl get svc
# port specification named http
kubectl expose deployment front-end --name=front-end-svc --port=80 --tarport=80 --type=NodePort


NEW QUESTION # 51
Create a busybox pod that runs the command "env" and save the output to "envpod" file

Answer:

Explanation:
See the solution below.
Explanation
kubectl run busybox --image=busybox --restart=Never --rm -it -- env > envpod.yaml


NEW QUESTION # 52
Monitor the logs of pod foo and:
* Extract log lines corresponding unable-to-access-website
* Write them to/opt/KULM00201/foo

Answer:

Explanation:
See the solution below.
Explanation
solution


NEW QUESTION # 53
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).

Answer:

Explanation:
See the solution below.
Explanation
solution


NEW QUESTION # 54
Create a redis pod, and have it use a non-persistent storage
(volume that lasts for the lifetime of the Pod)

  • A. vim redis-pod-vol.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: redis
    spec:
    containers:
    - name: redis
    image: redis
    ports:
    - containerPort: 6679
    volumeMounts:
    - mountPath: /data
    name: redis-storage
    volumes:
    - name: redis-storage
    emptyDir: {}
    kubectl apply -f redis-pod-vol.yaml
  • B. vim redis-pod-vol.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: redis
    spec:
    containers:
    - name: redis
    image: redis
    ports:
    - containerPort: 6379
    volumeMounts:
    - mountPath: /data
    name: redis-storage
    volumes:
    - name: redis-storage
    emptyDir: {}
    kubectl apply -f redis-pod-vol.yaml

Answer: B


NEW QUESTION # 55
......

Get Latest CKA Dumps Exam Questions in here: https://testking.vcetorrent.com/CKA-valid-vce-torrent.html