[Feb 24, 2025] Free Linux Foundation CKA Exam Questions and Answer
Verified CKA dumps Q&As Latest CKA Download
Linux Foundation Certified Kubernetes Administrator (CKA) Program is a certification exam that validates one's skills and knowledge in Kubernetes administration. This program is offered by the Linux Foundation, a non-profit organization that aims to promote and support the growth of open source software. The CKA exam is designed to test one's ability to install, configure, and manage Kubernetes clusters, as well as troubleshoot common issues that may arise.
NEW QUESTION # 12
You have a Kubernetes cluster with a 'default' namespace. You want to prevent any users from creating pods in this namespace.
Create a ClusterRole and ClusterRoleBinding to achieve this restriction.
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
Step 1: Create a ClusterRole to deny pod creation in the 'default' namespace.
Step 2: Create a ClusterRoleBinding to apply the ClusterRole to all users.
We create a ClusterRole that specifically targets the 'default' namespace and denies 'create' permissions for pods. This ClusterRole uses 'resourceNames' and 'namespaceSelector& to precisely target the 'default' namespace. We create a ClusterRoleBinding that applies the ClusterRole to all users in the cluster. Applying the configurations: Use 'kubectl apply -f [filename].yaml' to apply the ClusterRole and ClusterRoleBinding YAML files. This will prevent anyone from creating pods in the 'default' namespace. This configuration is a powerful way to implement security policies and prevent unintended resource creation in sensitive namespaces. ,
NEW QUESTION # 13
Create a deployment as follows:
* Name: nginx-app
* Using container nginx with version 1.11.10-alpine
* The deployment should contain 3 replicas
Next, deploy the application with new version 1.11.13-alpine, by performing a rolling update.
Finally, rollback that update to the previous version 1.11.10-alpine.
Answer:
Explanation:
See the solution below.
Explanation
solution


NEW QUESTION # 14
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.
Answer:
Explanation:
Create a second pod named pod-secrets-via-env, using the redis Image, which exports password as CONFIDENTIAL See the solution below.
Explanation
solution


NEW QUESTION # 15
Create a redis pod named "test-redis" and exec into that pod and create a file named "test-file.txt" with the text 'This is called the test file' in the path /data/redis and open another tab and exec again with the same pod and verifies file exist in the same path.
- A. vim test-redis.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-redis
spec:
containers:
- name: redis
image: redis
ports:
- containerPort: 6379
volumeMounts:
- mountPath: /data/redis
name: redis-storage
volumes:
kubectl exec -it test-redis /bin/sh
cd /data/redis
echo 'This is called the test file' > file.txt
//open another tab
kubectl exec -it test-redis /bin/sh
cat /data/redis/file.txt - B. vim test-redis.yaml
apiVersion: v1
kind: Pod
metadata:
name: test-redis
spec:
containers:
- name: redis
image: redis
ports:
- containerPort: 6379
volumeMounts:
- mountPath: /data/redis
name: redis-storage
volumes:
- name: redis-storage
emptyDir: {}
kubectl apply -f redis-pod-vol.yaml
// first terminal
kubectl exec -it test-redis /bin/sh
cd /data/redis
echo 'This is called the test file' > file.txt
//open another tab
kubectl exec -it test-redis /bin/sh
cat /data/redis/file.txt
Answer: B
NEW QUESTION # 16
Deployment
a. Create a deployment of webapp with image nginx:1.17.1 with
container port 80 and verify the image version
- A. // Create initial YAML file with -dry-run option
kubectl create deploy webapp --image=nginx:1.17.1 --dryrun=client -o yaml > webapp.yaml vim webapp.yaml apiVersion: apps/v1 kind: Deployment metadata:
labels:
app: webapp
name: webapp
spec: replicas: 1 containers: - image: nginx:1.17.1 name: nginx kubectl create -f webapp.yaml -record=true //Verify Image Version kubectl describe deploy webapp | grep -i "Image" Using JsonPath kubectl get deploy -o=jsonpath='{range.items [*]}{.[*]} {.metadata.name}{"\t"}{.spec.template.spec.containers[*].i mage}{"\n"}' - B. // Create initial YAML file with -dry-run option
kubectl create deploy webapp --image=nginx:1.17.1 --dryrun=client -o yaml > webapp.yaml vim webapp.yaml apiVersion: apps/v1 kind: Deployment metadata:
labels:
app: webapp
name: webapp
spec: replicas: 1 selector: matchLabels: app: webapp template: metadata: labels: app: webapp spec: containers: - image: nginx:1.17.1 name: nginx kubectl create -f webapp.yaml -record=true //Verify Image Version kubectl describe deploy webapp | grep -i "Image" Using JsonPath kubectl get deploy -o=jsonpath='{range.items [*]}{.[*]} {.metadata.name}{"\t"}{.spec.template.spec.containers[*].i mage}{"\n"}'
Answer: B
NEW QUESTION # 17
Create a pod with environment variables as var1=value1.Check the environment variable in pod
Answer:
Explanation:
See the solution below.
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 # 18
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:
solution




NEW QUESTION # 19
Update the deployment with the image version 1.17.4 and verify
- A. kubectl set image deploy/webapp nginx=nginx:1.17.4
//Verify
kubectl describe deploy webapp | grep Image
kubectl get deploy -
{.metadata.name}{"\t"}{.spec.template.spec.containers[*].i
mage}{"\n"}' - B. kubectl set image deploy/webapp nginx=nginx:1.17.4
//Verify
kubectl describe deploy webapp | grep Image
kubectl get deploy -o=jsonpath='{range.items [*]}{.[*]}
{.metadata.name}{"\t"}{.spec.template.spec.containers[*].i
mage}{"\n"}'
Answer: B
NEW QUESTION # 20
List the nginx pod with custom columns POD_NAME and POD_STATUS
Answer:
Explanation:
kubectl get po -o=custom-columns="POD_NAME:.metadata.name, POD_STATUS:.status.containerStatuses[].state"
NEW QUESTION # 21
You have a Kubernetes cluster with multiple namespaces. You want to create a ClusterRole that grants users in the "admins" group the ability to create, delete, and list Pods in any namespace, but restricts them from managing namespaces themselves.
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Create the ClusterRole:
2. Create the ClusterRoleBinding:
3. Apply the ClusterRole and ClusterRoleBinding: bash kubectl apply -f clusterrole.yaml kubectl apply -f clusterrolebinding.yaml
NEW QUESTION # 22
Set the node named ek8s-node-1 as unavailable and reschedule all the pods running on it.
Answer:
Explanation:
See the solution below.
Explanation
solution
NEW QUESTION # 23
You are working with a Kubernetes cluster that has been configured with RBAC. You need to create a deployment for a new application, but you are encountering permission issues. You have verified that your user account belongs to the "developers" group, which should have sufficient permissions to create deployments. However, you are receiving an error message indicating insufficient privileges.
Investigate the potential causes for the permission issue and provide solutions to resolve the problem.
Answer:
Explanation:
See the solution below with Step by Step Explanation.
NEW QUESTION # 24
List all configmap and secrets in the cluster in all namespace and write it to a file /opt/configmap-secret
Answer:
Explanation:
kubectl get configmap,secrets --all-namespaces > /opt/configmap-secret // Verify Cat /opt/configmap-secret
NEW QUESTION # 25
You are running a stateful application using a StatefulSet. How do you ensure that the application data is preserved during a rolling update?
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Use Persistent Volumes:
- Use Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) to provide persistent storage for the stateful application data.
- Ensure that the PVCs are mounted to the pods in the StatefulSet.
2. Configure Rolling Updates: - Configure the StatefulSet's updateStrategy' to use a rolling update strategy. - Ensure that the 'updateStrategy.type' is set to 'RollingUpdate'. 3. Validate Data Preservation: - Perform a rolling update by updating the StatefulSet. - Validate that the application data is preserved during the update process. - Check the logs and application state to confirm that the data is intact.
NEW QUESTION # 26
You have a StatefulSet named 'mysql-cluster' running a MySQL database with 3 replicas. You want to add a new replica to the cluster without disrupting the existing database operations. How do you achieve this while ensuring data consistency and minimal downtime?
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Scale up the StatefulSet:
- Increase the 'replicas' value in the StatefulSet definition from 3 to 4. Apply the change using 'kubectl apply -f mysql-cluster.yaml'
2. Wait for the new pod to be created: - Monitor the pod creation process using 'kubectl get pods -l app=mysql-cluster'. Wait for the new pod to be created and enter a ready state. 3. Join the new pod to the cluster: - In the new pod's shell, execute the following command to join the existing MySQL cluster: Bash mysql -h -u -p -e "CHANGE MASTER TO MASTER PASSWORD=", MASTER DELAY=O" - Replace with the IP address of one of the existing MySQL replicas. - Replace , and '3306' with the appropriate values for your MySQL setup. 4. Verify the new replica is synchronized: - Use "SHOW SLAVE STATUS" command on the new replica to verify that it's successfully replicating data from the existing cluster. Ensure that the 'Slave 10 Running' and 'Slave SQL Running' statuses are both set to 'Yes'. 5. Promote the new replica: - Promote the new replica to a full member of the cluster by updating the StatefulSet definition to include the new pod's hostname. This will typically involve adding a new entry to the 'volumeClaimTemplates' section of the StatefulSet. 6. Test the cluster's health: - Run a series of read and write operations on the database to verify that the new replica is fully integrated and responding correctly. 7. Remove the old pod: - You can now delete the old pod that had the lowest pod index. This will trigger the automatic cleanup of the old volume, ensuring that only the healthy and synchronized replicas remain. By following these steps, you can add a new replica to your MySQL cluster while ensuring minimal downtime and preserving data consistency. ]
NEW QUESTION # 27
......
Use Real Dumps - 100% Free CKA Exam Dumps: https://pass4sures.freepdfdump.top/CKA-valid-torrent.html

