Linux Foundation CKA Real Exam Questions Guaranteed Updated Dump from Exam4Tests [Q12-Q28]

Share

Linux Foundation CKA Real Exam Questions Guaranteed Updated Dump from Exam4Tests

Verified Pass CKA Exam in First Attempt Guaranteed


The Certified Kubernetes Administrator (CKA) Program Exam is a certification exam offered by the Linux Foundation. CKA exam is designed to test an individual's knowledge and skills related to Kubernetes administration, as well as their ability to work with various Kubernetes tools and resources. The CKA exam is a popular certification among IT professionals who are interested in building their knowledge of container orchestration and management.

 

NEW QUESTION # 12
Print all pod name and all image name and write it to a file
name "/opt/pod-details.txt"

Answer:

Explanation:
kubectl get pods -o=custom-columns='Pod Name:metadata.name','Image:spec.containers[*].image' > /opt/pod-details.txt


NEW QUESTION # 13
Check logs of each container that "busyboxpod-{1,2,3}"

  • A. kubectl logs busybox -c busybox-container-1
    kubectl logs busybox -c busybox-container-2
    kubectl logs busybox -c busybox-container-3
  • B. kubectl logs busybox -c busybox-container-1
    kubectl logs busybox -c busybox-container-3
    kubectl logs busybox -c busybox-container-3

Answer: A


NEW QUESTION # 14
Score: 4%

Task
Create a persistent volume with name app-data , of capacity 1Gi and access mode ReadOnlyMany. The type of volume is hostPath and its location is /srv/app-data .

Answer:

Explanation:
Solution:
#vi pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: app-config
spec:
capacity:
storage: 1Gi
accessModes:
- ReadOnlyMany
hostPath:
path: /srv/app-config
#
kubectl create -f pv.yaml


NEW QUESTION # 15
Create an nginx pod which reads username as the environment variable

  • A. // create a yml file
    kubectl run nginx --image=nginx --restart=Never --dry-run -o
    yaml > nginx.yml
    // add env section below and create
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    run: nginx
    name: nginx
    spec:
    containers:
    - image: nginx
    name: nginx
    env:
    - name: USER_NAME
    valueFrom:
    secretKeyRef:
    name: my-secret
    key: username
    restartPolicy: Never
    kubectl create -f nginx.yml
    //Verify
    kubectl exec -it nginx - env
  • B. // create a yml file
    kubectl run nginx --image=nginx --restart=Never --dry-run -o
    yaml > nginx.yml
    // add env section below and create
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    run: nginx
    name: nginx
    spec:
    containers:
    - image: nginx
    name: nginx
    env:
    - name: USER_NAME
    restartPolicy: Never
    kubectl create -f nginx.yml
    //Verify
    kubectl exec -it nginx - env

Answer: A


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

Answer:

Explanation:
Solution:
kubectl top -l name=cpu-user -A
echo 'pod name' >> /opt/KUT00401/KUT00401.txt


NEW QUESTION # 17
List all persistent volumes sorted bycapacity, saving the fullkubectloutput to
/opt/KUCC00102/volume_list. Usekubectl 's own functionality forsorting the output, and do not manipulate it any further.

Answer:

Explanation:
See the solution below.
Explanation
solution


NEW QUESTION # 18
You are running a service that handles requests from multiple pods. How can you scale the service to handle increased traffic without impacting the service availability during the scaling process?

Answer:

Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Use a Deployment:
- Deploy the service using a Deployment with the desired number of replicas.
2. Define a Service:
- Create a Service that exposes the application to the outside world.
- Use a 'type: LoadBalancer' to distribute traffic across the pods.
3. Implement Horizontal Pod Autoscaler (HPA):
- Create an HPA that monitors the service's CPU usage.
- Configure the HPA to scale the Deployment based on the CPU utilization.

4. Test the Autoscaling: - Simulate increased traffic to the service. - Observe the HPA scaling the Deployment to meet the demand. 5. Monitor the Service: - Monitor the service's performance and ensure that it remains available and stable during scaling. 6. Adjust HPA Configuration: - Fine-tune the HPA configuration to optimize scaling based on specific performance needs.


NEW QUESTION # 19
Score: 7%

Task
Create a new NetworkPolicy named allow-port-from-namespace in the existing namespace echo. Ensure that the new NetworkPolicy allows Pods in namespace my-app to connect to port 9000 of Pods in namespace echo.
Further ensure that the new NetworkPolicy:
* does not allow access to Pods, which don't listen on port 9000
* does not allow access from Pods, which are not in namespace my-app

Answer:

Explanation:
See the solution below.
Explanation
Solution:
#network.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-port-from-namespace
namespace: internal
spec:
podSelector:
matchLabels: {
}
policyTypes:
- Ingress
ingress:
- from:
- podSelector: {
}
ports:
- protocol: TCP
port: 8080
#spec.podSelector namespace pod
kubectl create -f network.yaml


NEW QUESTION # 20
Your Kubernetes cluster is experiencing a high number of pod restarts in the 'database-service' Deployment. The logs show errors related to "connection refused" from the database service. You need to diagnose the issue and resolve it.

Answer:

Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Check the Database Service:
- Verify the database service is running and healthy:
- Use 'kubectl get services database-service' to check the service status.
- If the service is not running, try restarting it with 'kubectl delete service database-service' followed by 'kubectl apply -f database-service.yaml'
2. Investigate Network Connectivity:
- Check if pods in the 'database-service' Deployment can connect to the database service:
- Use 'kubectl exec -it -n bash' to enter a pod in the Deployment.
- Run 'ping database-service' or 'telnet database-service to test network connectivity.
- If ping or telnet fails, there might be a network issue between the pods and the database service.
3. Examine Service Configuration:
- Inspect the database service YAML:
- Verify the port mapping in the service definition matches the port that the database service listens on.
- Ensure the service selector matches the labels of the database pods.
- Example:

4. Check for Network Policies: - Determine if any network policies are blocking traffic between the database service and the pods: - Use 'kubectl get networkpolicies -n ' to list network policies. - Examine the policies to see if they are blocking traffic based on labels, ports, or other criteria. 5. Troubleshoot Database Service: - Verify the database service itself is running and accessible: - If you can access the database service directly from outside the cluster, but the pods cannot connect, there may be an issue with the database service itself. - Run tests to ensure the database is functioning correctly. 6. Test and Redeploy: - After making changes to the service definition, apply the update: - 'kubectl apply -f database-service.yaml' - Monitor the pod restarts. If the issue persists, consider further troubleshooting steps, such as inspecting firewall rules or DNS resolution.


NEW QUESTION # 21
Make the node schedulable by uncordon the node

Answer:

Explanation:
kubectl uncordon node-1 //verify kubectl get no


NEW QUESTION # 22
For this item, you will have to ssh to the nodes ik8s-master-0 and ik8s-node-0 and complete all tasks on these nodes. Ensure that you return to the base node (hostname: node-1) when you have completed this item.
Context
As an administrator of a small development team, you have been asked to set up a Kubernetes cluster to test the viability of a new application.
Task
You must use kubeadm to perform this task. Any kubeadm invocations will require the use of the
--ignore-preflight-errors=all option.
* Configure the node ik8s-master-O as a master node. .
* Join the node ik8s-node-o to the cluster.

Answer:

Explanation:
See the solution below.
Explanation
solution
You must use the kubeadm configuration file located at /etc/kubeadm.conf when initializingyour cluster.
You may use any CNI plugin to complete this task, but if you don't have your favourite CNI plugin's manifest URL at hand, Calico is one popular option: https://docs.projectcalico.org/v3.14/manifests/calico.yaml Docker is already installed on both nodes and has been configured so that you can install the required tools.


NEW QUESTION # 23
Create a pod with init container which create a file "test.txt"
in "workdir" directory. Main container should check a file
"test.txt" exists and execute sleep 9999 if the file exists.

  • A. // create an initial yaml file with this
    kubectl run init-cont-pod --image=alpine --restart=Never --dry-run -o
    yaml > init-cont-pod.yaml
    // edit the yml as below and create it
    vim init-cont-pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: init-cont-pod
    labels:
    app: myapp
    spec:
    volumes:
    - name: test-volume
    emptyDir: {}
    containers:
    - name: main-container
    image: busybox:1.28
    command: ['sh', '-c', 'if [ -f /workdir/test.txt ]; then sleep
    9999; fi']
    volumeMounts:
    - name: test-volume
    mountPath: /workdir
    initContainers:
    - name: init-myservice
    image: busybox:1.28
    command: ['sh', '-c', "mkdir /workdir; echo >
    /workdir/test.txt"]
    volumeMounts:
    - name: test-volume
    mountPath: /workdir
    // Create the pod
    kubectl apply -f init-cont-pod.yaml
    kubectl get pods
    // Check Events by doing
    kubectl describe po init-cont-pod
    Init Containers:
    init-myservice:
    Container ID:
    docker://ebdbf5fad1c95111d9b0e0e2e743c2e347c81b8d4eb5abcccdfe1dd74524
    0d4f
    Image: busybox:1.28
    Image ID: dockerpullable://busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df
    416dea4f41046e0f37d47
    Port: <none>
    Host Port: <none>
    Command:
    sh
    -c
    mkdir /workdir; echo > /workdir/test.txt
    State: Terminated Reason: Completed
  • B. // create an initial yaml file with this
    kubectl run init-cont-pod --image=alpine --restart=Never --dry-run -o
    yaml > init-cont-pod.yaml
    // edit the yml as below and create it
    vim init-cont-pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: init-cont-pod
    labels:
    app: myapp
    spec:
    volumes:
    - name: test-volume
    emptyDir: {}
    containers:
    - name: main-container
    image: busybox:1.28
    command: ['sh', '-c', 'if [ -f /workdir/test.txt ]; then sleep
    9999; fi']
    volumeMounts:
    image: busybox:1.28
    command: ['sh', '-c', "mkdir /workdir; echo >
    /workdir/test.txt"]
    volumeMounts:
    - name: test-volume
    mountPath: /workdir
    // Create the pod
    kubectl apply -f init-cont-pod.yaml
    kubectl get pods
    // Check Events by doing
    kubectl describe po init-cont-pod
    Init Containers:
    init-myservice:
    Container ID:
    docker://ebdbf5fad1c95111d9b0e0e2e743c2e347c81b8d4eb5abcccdfe1dd74524
    0d4f
    Image: busybox:1.28
    Image ID: dockerpullable://busybox@sha256:141c253bc4c3fd0a201d32dc1f493bcf3fff003b6df
    416dea4f41046e0f37d47
    Port: <none>
    Host Port: <none>
    Command:
    sh
    -c
    mkdir /workdir; echo > /workdir/test.txt
    State: Terminated Reason: Completed

Answer: A


NEW QUESTION # 24
Create a nginx pod that will be deployed to node with the label
"gpu=true"

  • A. kubectl run nginx --image=nginx --restart=Always --dry-run -o
    yaml > nodeselector-pod.yaml
    // add the nodeSelector like below and create the pod
    kubectl apply -f nodeselector-pod.yaml
    vim nodeselector-pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx
    spec:
    nodeSelector:
    gpu: true
    containers:
    - image: nginx
    name: nginx
    restartPolicy: Always
    kubectl apply -f nodeselector-pod.yaml
    //Verify
    kubectl get no -show-labels
    kubectl get po
    kubectl describe po nginx | grep Node-Selectors
  • B. kubectl run nginx --image=nginx --restart=Always --dry-run -o
    yaml > nodeselector-pod.yaml
    // add the nodeSelector like below and create the pod
    kubectl apply -f nodeselector-pod.yaml
    vim nodeselector-pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx
    spec:
    nodeSelector:
    gpu: true
    yaml
    //Verify
    kubectl get no -show-labels
    kubectl get po
    kubectl describe po nginx | grep Node-Selectors

Answer: A


NEW QUESTION # 25
Create and configure the service front-end-service so it's accessible through NodePort and routes to the existing pod named front-end.

Answer:

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


NEW QUESTION # 26
List all persistent volumes sorted by capacity, saving the full kubectl output to /opt/KUCC00102/volume_list.
Use kubectl 's own functionality for sorting the output, and do not manipulate it any further.

Answer:

Explanation:


NEW QUESTION # 27
Create a pod with environment variables as var1=value1.Check the environment variable in pod

Answer:

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


NEW QUESTION # 28
......

Download Real Linux Foundation CKA Exam Dumps Test Engine Exam Questions: https://braindumps.exam4tests.com/CKA-pdf-braindumps.html