100% Real & Accurate CKA Questions and Answers with Free and Fast Updates
Get Unlimited Access to CKA Certification Exam Cert Guide
Linux Foundation Certified Kubernetes Administrator (CKA) program is a certification designed to test the knowledge and skills of individuals in the field of Kubernetes administration. Kubernetes is one of the most popular container orchestration platforms, and it is widely used by organizations to manage their containerized applications. The CKA program is developed and maintained by the Linux Foundation, which is a non-profit organization that promotes the use of open source technologies.
NEW QUESTION # 33
Create a pod that having 3 containers in it? (Multi-Container)
Answer:
Explanation:
See the solution below.
Explanation
image=nginx, image=redis, image=consul
Name nginx container as "nginx-container"
Name redis container as "redis-container"
Name consul container as "consul-container"
Create a pod manifest file for a container and append container
section for rest of the images
kubectl run multi-container --generator=run-pod/v1 --image=nginx --
dry-run -o yaml > multi-container.yaml
# then
vim multi-container.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: multi-container
name: multi-container
spec:
containers:
- image: nginx
name: nginx-container
- image: redis
name: redis-container
- image: consul
name: consul-container
restartPolicy: Always
NEW QUESTION # 34
You are tasked with configuring RBAC for a Kubernetes cluster hosting a microservices application.
The application consists of three services:
- 'frontend' which only needs to access the 'nginx-ingress-controller' deployment to configure Ingress resources.
- 'backend' which needs read-only access to the 'postgres' service for database queries.
- 'worker' which needs to create, update, and delete pods in the 'worker-namespace' namespace and access the 'redis' service.
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Create the necessary RBAC roles, role bindings, and service accounts to enable these permissions.
Solution (Step by Step) :
1 . Create Service Accounts:
kubectl create serviceaccount frontend-sa -n default
kubectl create serviceaccount backend-sa -n default
kubectl create serviceaccount worker-sa -n worker-namespace
2. Create Roles:

3. Create Role Bindings: kubectl create rolebinding frontend-binding -n default -role=frontend-role serviceaccount=default:frontend-sa kubectl create rolebinding backend-binding -n default --role=backend-role - serviceaccount=default:backend-sa kubectl create rolebinding worker-binding -n worker-namespace -role=worker-role - serviceaccount=worker- namespace:worker-sa 4. Grant Access to Services: Frontend: The 'frontend' service account should have access to the 'nginx-ingress-controller' deployment. This can be done through a Role or ClusterRole and RoleBinding or ClusterRoleBinding, depending on if the controller is in the same namespace or across namespaces. Backend: The 'backend' service account should have read-only access to the postgres' service. This can be achieved by creating a 'ServiceAccount' for the 'backend' service and binding it to a 'Role' that grants the necessary permissions on the 'postgres' service. Worker: The 'worker' service account should have full access (create, update, delete) to pods in the 'worker- namespace' and read access to the 'redis' service. Important Notes: - The provided 'kubectl' commands are illustrative. You may need to adjust them based on your specific cluster configuration. - The above RBAC configuration is a basic example. Depending on the specific needs of your application, you may need to configure more granular roles and bindings.
NEW QUESTION # 35
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:
See the solution below.
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 # 36
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
Answer:
Explanation:
See the solution below.
Explanation
solution
F:\Work\Data Entry Work\Data Entry\20200827\CKA\12 B.JPG
F:\Work\Data Entry Work\Data Entry\20200827\CKA\12 C.JPG
F:\Work\Data Entry Work\Data Entry\20200827\CKA\12 D.JPG
NEW QUESTION # 37
Print pod name and start time to "/opt/pod-status" file
Answer:
Explanation:
kubect1 get pods -o=jsonpath='{range
.items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'
NEW QUESTION # 38
Get the memory and CPU usage of all the pods and find out top 3 pods which have the highest usage and put them into the cpuusage.txt file
- A. // Get the top 3 pods
kubectl top pod --all-namespaces | sort --reverse --key 3 --
numeric | head -8
// putting into file
kubectl top pod --all-namespaces | sort --reverse --key 6 --
numeric | head -6 > cpu-usage.txt
// verify
cat cpu-usage.txt - B. // Get the top 3 pods
kubectl top pod --all-namespaces | sort --reverse --key 3 --
numeric | head -3
// putting into file
kubectl top pod --all-namespaces | sort --reverse --key 3 --
numeric | head -3 > cpu-usage.txt
// verify
cat cpu-usage.txt
Answer: B
NEW QUESTION # 39
Create a pod as follows:
Name: mongo
Using Image: mongo
In a new Kubernetes namespace named: my-website
Answer:
Explanation:
solution
NEW QUESTION # 40
Score: 4%
Task
Scale the deployment presentation
Answer:
Explanation:
See the solution below.
Explanation
Solution:
kubectl get deployment
kubectl scale deployment.apps/presentation --replicas=6
NEW QUESTION # 41
Scale the deployment to 5 replicas
Answer:
Explanation:
kubectl scale deployment webapp -replicas=5 //Verify kubectl get deploy kubectl get po,rs
NEW QUESTION # 42
You are running a MySQL database on a Kubernetes cluster. You want to ensure that your database data is persistent even if a pod is deleted or restarted. You need to create a PersistentVolumeClaim (PVC) to request a specific storage class with a 1 OGB capacity, access mode of 'ReadWriteOnce', and storage class of 'fast-storage'. Explain the configuration and how to create the PVC and then use the PVC to create a StatefulSet for your MySQL deployment.
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Create a PersistentVolumeClaim:
- Create a YAML file named 'mysql-pvc.yaml' with the following content:
- Apply the YAML file using 'kubectl apply -f mysql-pvc.yamP. 2. Create a StatefulSet for MySQL Deployment: - Create a YAML file named 'mysql-statefulset.yaml' with the following content:
- Apply the YAML file using 'kubectl apply -f mysql-statefulset.yaml'. 3. Verify Deployment: - Check the status of the StatefulSet using 'kubectl get statefulsets mysql'. - Ensure that the pod is running and the PVC is mounted correctly. You can use 'kubectl describe pod mysql-0' to see the details of the pod and the mounted PVC.
NEW QUESTION # 43
You have a Kubernetes cluster with a Deployment named 'web-app' that runs a web application. You need to set up a mechanism to automatically scale the deployment based on the CPU utilization of the pods. The scaling should be triggered when the average CPU utilization across all pods reaches 70%. You should set the minimum and maximum replicas to 2 and 5 respectively.
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Create a Horizontal Pod Autoscaler (HPA):
- Use "kubectl create hpa' command to create an HPA resource.
- Specify the name of the HPA, the Deployment to scale, the target CPU utilization (70%), and the minimum and maximum replicas.
kubectl create hpa web-app-hpa --min=2 --max=5 --cpu-utilization-percentage=70 --target- ref=Deployment/web-app
2. Verify the HPA Creation:
- Use 'kubectl get hpa' command to check if the HPA was created successfully. You should see an HPA named 'web-app-hpa' with the configured settings.
3. Monitor the Scaling Behavior:
- You can use the 'kubectl get pods -l command to monitor the number of pods running as the CPU utilization changes.
- When the average CPU utilization across the pods reaches 70%, the HPA will automatically scale up the Deployment to add more pods.
- Conversely, when the CPU utilization falls below the threshold, the HPA will scale down the Deployment to reduce the number of pods.
Ensure that the 'metrics-server' is installed in your cluster to enable CPU utilization monitoring.,
NEW QUESTION # 44
Set the node named ek8s-node-1 as unavailable and reschedule all the pods running on it.
Answer:
Explanation:
solution
NEW QUESTION # 45
Score: 4%
Task
Schedule a pod as follows:
* Name: nginx-kusc00401
* Image: nginx
* Node selector: disk=ssd
Answer:
Explanation:
See the solution below.
Explanation
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
NEW QUESTION # 46
Scale the deployment webserver to
Answer:
Explanation:
See the solution below.
Explanation
solution
F:\Work\Data Entry Work\Data Entry\20200827\CKA\14 B.JPG
NEW QUESTION # 47
Create PersistentVolume named task-pv-volume with storage 10Gi, access modes ReadWriteMany, storageClassName manual, and volume at /mnt/data and Create a PersistentVolumeClaim of at least 3Gi storage and access mode ReadWriteOnce and verify
- A. vim task-pv-volume.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: task-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/data"
kubectl apply -f task-pv-volume.yaml
//Verify
kubectl get pv
vim task-pvc-volume.yaml
apiVersion: v1
- ReadWriteMany
resources:
requests:
storage: 3Gi
kubectl apply -f task-pvc-volume.yaml
//Verify
Kuk kubectl get pvc - B. vim task-pv-volume.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: task-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/mnt/data"
kubectl apply -f task-pv-volume.yaml
//Verify
kubectl get pv
vim task-pvc-volume.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: task-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 3Gi
kubectl apply -f task-pvc-volume.yaml
//Verify
Kuk kubectl get pvc
Answer: B
NEW QUESTION # 48
Create a snapshot of the etcd instance running at https://127.0.0.1:2379, saving the snapshot to the file path
/srv/data/etcd-snapshot.db.
The following TLS certificates/key are supplied for connecting to the server with etcdctl:
CA certificate: /opt/KUCM00302/ca.crt
Client certificate: /opt/KUCM00302/etcd-client.crt
Client key: Topt/KUCM00302/etcd-client.key
Answer:
Explanation:
See the solution below.
Explanation
solution
F:\Work\Data Entry Work\Data Entry\20200827\CKA\18 C.JPG
NEW QUESTION # 49
Get list of all the pods showing name and namespace with a jsonpath expression.
Answer:
Explanation:
kubectl get pods -o=jsonpath="{.items[*]['metadata.name' , 'metadata.namespace']}"
NEW QUESTION # 50
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 # 51
Create an nginx pod and load environment values from the above configmap "keyvalcfgmap" and exec into the pod and verify the environment variables and delete the pod
- A. // first run this command to save the pod yaml
kubectl run nginx --image=nginx --restart=Always --dry-run -o
yaml > nginx-pod.yml
// edit the yml to below file and create
vim nginx-pod.yml
apiVersion: v1
name: nginx
envFrom:
- configMapRef:
name: keyvalcfgmap
restartPolicy: Always
kubectl apply -f nginx-pod.yml
// verify
kubectl exec -it nginx -- env
kubectl delete po nginx - B. // first run this command to save the pod yaml
kubectl run nginx --image=nginx --restart=Always --dry-run -o
yaml > nginx-pod.yml
// edit the yml to below file and create
vim nginx-pod.yml
apiVersion: v1
kind: Pod
metadata:
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx
name: nginx
envFrom:
- configMapRef:
name: keyvalcfgmap
restartPolicy: Always
kubectl apply -f nginx-pod.yml
// verify
kubectl exec -it nginx -- env
kubectl delete po nginx
Answer: B
NEW QUESTION # 52
You are running a Kubernetes cluster with a critical application that requires high availability and resilience. You have a Deployment named 'web-app' with multiple replicas. Your current DNS setup relies on external DNS providers, but you want to implement CoreDNS within your cluster to enhance DNS resolution performance and reliability. You need to configure CoreDNS to resolve DNS queries for services within the cluster and for external domains.
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1 Create a CoreDNS ConfigMap:
- Create a ConfigMap named coredns' containing the CoreDNS configuration. You can use a basic configuration file or a more complex one tailored to your specific needs.
2. Deploy CoreDNS: - Deploy CoreDNS as a Deployment using the 'coredns' ConfigMap.
3. Configure Services for DNS Resolution: - Create a Service named 'coredns' of type 'ClusterlP' that exposes the CoreDNS Deployment on the cluster network.
4. Update Cluster DNS Configuration: - Modify the 'kube-system namespace 'ConfigMap' named 'cluster-dns' to point to the 'coredns' Service for DNS resolution.
5. Verify CoreDNS Functionality: - Use 'kubectl exec -it -- sh -c "nslookup ..svc.cluster.local"' to test DNS resolution for services within the cluster. - Use "kubectl exec -it sh -c "nslookup example.com"' to test DNS resolution for external domains. - If everything is configured correctly, CoreDNS should successfully resolve DNS queries.
NEW QUESTION # 53
Allow traffic from all the pods in "web" namespace and from pods
with label "type=monitoring" to the pods matching label "app: db"
- A. kubectl create namespace web
kubectl label namespace/web app=web
vim web-allow-all-ns-monitoring.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: web-allow-all-ns-monitoring
namespace: default
spec:
podSelector:
podSelector:
matchLabels:
type: monitoring
k kubectl apply -f web-allow-all-ns-monitoring.yaml - B. kubectl create namespace web
kubectl label namespace/web app=web
vim web-allow-all-ns-monitoring.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: web-allow-all-ns-monitoring
namespace: default
spec:
podSelector:
matchLabels:
app: db
ingress:
- from:
- namespaceSelector:
matchLabels:
app: web
podSelector:
matchLabels:
type: monitoring
k kubectl apply -f web-allow-all-ns-monitoring.yaml
Answer: B
NEW QUESTION # 54
You have a Deployment running on a Kubernetes cluster with limited resources. How can you adjust the Deployment to use resources more efficiently and prevent resource contention?
Answer:
Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Define Resource Requests and Limits:
- Set 'requests' and 'limits' for CPU and memory for the containers in the Deployment.
- This helps in specifying the minimum resources required by the pods and the maximum resources that they can consume.
2. Optimize Container Images: - Use smaller and more efficient container images to reduce the resource footprint of the pods. 3. Use Resource Quotas: - Apply resource quotas at the namespace level to control the resource consumption of the pods within a namespace. 4. Consider Pod Disruption Budgets (PDB): - Implement PDBs to control the maximum number of pods that can be unavailable during a rolling update or pod deletion. - This ensures that the application remains available during resource-intensive events. 5. Utilize Node Affinity and Tolerations: - Configure node affinity and tolerations to schedule pods on specific nodes that have the required resources. 6. Monitor Resource Utilization: - Regularly monitor the resource utilization of the cluster and the pods. - Use tools like 'kubectl top pods', 'kubectl top nodes', and 'kubectl describe nodes' to gather resource utilization data. - Adjust resource requests and limits accordingly based on the monitoring data.
NEW QUESTION # 55
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.
Answer:
Explanation:


NEW QUESTION # 56
......
Reliable Study Materials for CKA Exam Success For Sure: https://www.prepawaypdf.com/Linux-Foundation/CKA-practice-exam-dumps.html
100% Latest Most updated CKA Questions and Answers: https://drive.google.com/open?id=112GCoXRASdr4Ow1GT8t-Ypn_eXZadwKB