Verified CKA Q&As - Pass Guarantee CKA Exam Dumps [Q12-Q31]

Share

Verified CKA Q&As - Pass Guarantee CKA Exam Dumps

Check the Free demo of our CKA Exam Dumps with 85 Questions

NEW QUESTION # 12
You have a Deployment that runs a containerized web application. The web application depends on a specific database service running on a different node in the cluster. The web application should only be able to connect to the database service on port 5432 and not any other services running on the database node. How can you define a NetworkPolicy to achieve this?

Answer:

Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Network Policy Definition:

2. Explanation: - 'apiVersion: networking.k8s.io/v1 Specifies the API version for NetworkPolicy resources. - 'kind: NetworkPolicy': Specifies that this is a NetworkPolicy resource. - 'metadata.name: allow-database-access': Sets the name of the NetworkPolicy. - 'metadata.namespace: Specifies the namespace where the NetworkPolicy is applied. Replace with the actual namespace where your web application Deployment is running. - 'spec.podSelector.matchLabels: app: web-app': This selector targets Pods labeled with 'app: web-app', ensuring the NetworkPolicy applies to the web application Pods. - 'spec.ingress.from.podSelector.matchLabels: app: database': This allows incoming traffic only from Pods labeled with 'app: database'. - 'spec.ingress.ports.port: 5432': This allows communication only on port 5432. - 'spec.ingress.ports.protocol: TCP': Specifies the protocol (TCP) for the allowed port. 3. How it works: - This NetworkPolicy allows the web application Pods to connect only to the database service Pods on port 5432. It denies all other traffic from the database node, including other services that might be running on that node. 4. Implementation: - Apply the YAML using 'kubectl apply -f allow-database-access.yaml' 5. Verification: After applying the NetworkPolicy, test the connectivity from the web application Pods to the database service on port 5432 and to other services on the database node. You should observe that the NetworkPolicy effectively enforces the restrictions, allowing access only to the specified database port.


NEW QUESTION # 13
You need to set up a load balancer for your Nginx service with the following requirements:
- Session affinity: Preserve client sessions across multiple pods, even if the pod is restarted or rescheduled.
- Health checks: Regularly check the health of Nginx pods and automatically remove unhealthy pods from the load balancer pool.
- Custom header: Add a custom header with the name "X-App-Version" and value "vl .0" to all requests to your Nginx service. How would you configure your Kubernetes resources to meet these requirements?

Answer:

Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Define the Service:
- Create a Service of type "LoadBalancer" for your Nginx service.
- Include the sessionAffinity' field with a value of 'ClientlP' to enable client IP-based session affinity.
- Example:

2. Configure the Deployment: - In your Nginx Deployment, define a liveness probe and readiness probe to check the health of your Nginx containers. - Example:

3. Implement the Custom Header: - Configure an Ingress resource with the nginx.ingress.kubernetes.io/add-request-headeo annotation. - Example:

4. Apply the Configurations: - Apply the updated Service, Deployment, and Ingress resources using 'kubectl apply -f service.yaml -f deployment.yaml -f ingress.yamr. 5. Verify the Load Balancer: - Access the Nginx service using the external IP address provided by the LoadBalancer. - Verify session affinity by making multiple requests and observing that they are consistently routed to the same pod. - Check the "X-App-Version" header in the responses to confirm that it is set to "vl .0".


NEW QUESTION # 14
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 # 15
Change the Image version back to 1.17.1 for the pod you just updated and observe the changes

Answer:

Explanation:
kubectl set image pod/nginx nginx=nginx:1.17.1 kubectl describe po nginx kubectl get po nginx -w # watch it


NEW QUESTION # 16
List all the pods sorted by name

Answer:

Explanation:
See the solution below.
Explanation
kubectl get pods --sort-by=.metadata.name


NEW QUESTION # 17
Given a partially-functioning Kubernetes cluster, identify symptoms of failure on the cluster.
Determine the node, the failing service, and take actions to bring up the failed service and restore the health of the cluster. Ensure that any changes are made permanently.
You can ssh to the relevant I nodes (bk8s-master-0 or bk8s-node-0) using:
[student@node-1] $ ssh <nodename>
You can assume elevated privileges on any node in the cluster with the following command:
[student@nodename] $ | sudo -i

Answer:

Explanation:
solution



NEW QUESTION # 18
List all the pods showing name and namespace with a json path expression

Answer:

Explanation:
See the solution below.
Explanation
kubectl get pods -o=jsonpath="{.items[*]['metadata.name',
'metadata.namespace']}"


NEW QUESTION # 19
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:





NEW QUESTION # 20
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 -o=jsonpath='{range.items [*]}{.[*]}
    {.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 -
    {.metadata.name}{"\t"}{.spec.template.spec.containers[*].i
    mage}{"\n"}'

Answer: A


NEW QUESTION # 21
Create and configure the servicefront-end-serviceso it's accessiblethroughNodePortand routes to theexisting pod namedfront-end.

Answer:

Explanation:
See the solution below.
Explanation
solution


NEW QUESTION # 22
create a pod in a specific node (node1) by placing the pod definition file in a particular folder "/etc/kubernetes/manifests".

  • A. Generate YAML before we SSH to the specific node, then copy the YAML into the exam notepad to use it after SSH into worker node.
    SSH to the node: "ssh node1"
    Gain admin privileges to the node: "sudo -i"
    Move to the manifest-path "cd /etc/kubernetes/manifests"
    kubelet config file -- /var/lib/kubelet/config.yaml
    Edit the config file "vi /var/lib/kubelet/config.yaml" to add
    staticPodPath
    staticPodPath: /etc/kubernetes/manifests
    Restart the kubelet "systemctl restart kubelet"
  • B. Generate YAML before we SSH to the specific node, then copy the YAML into the exam notepad to use it after SSH into worker node.
    SSH to the node: "ssh node1"
    Gain admin privileges to the node: "sudo -i"
    Move to the manifest-path "cd /etc/kubernetes/manifests"
    Place the generated YAML into the folder "vi nginx.yaml"
    Find the kubelet config file path "ps -aux | grep kubelet" . This
    will output information on kubelet process. Locate the kubelet config
    file location.
    kubelet config file -- /var/lib/kubelet/config.yaml
    Edit the config file "vi /var/lib/kubelet/config.yaml" to add
    staticPodPath
    staticPodPath: /etc/kubernetes/manifests
    Restart the kubelet "systemctl restart kubelet"

Answer: B


NEW QUESTION # 23
Get list of persistent volumes and persistent volume claim in the cluster

Answer:

Explanation:
kubectl get pv kubectl get pvc


NEW QUESTION # 24
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 # 25
Check the image version in pod without the describe command

Answer:

Explanation:
kubectl get po nginx -o jsonpath='{.spec.containers[].image}{"\n"}'


NEW QUESTION # 26
Score: 4%

Task
Schedule a pod as follows:
* Name: nginx-kusc00401
* Image: nginx
* Node selector: disk=ssd

Answer:

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 # 27
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 # 28
List "nginx-dev" and "nginx-prod" pod and delete those pods

Answer:

Explanation:
kubect1 get pods -o wide
kubectl delete po "nginx-dev"
kubectl delete po "nginx-prod"


NEW QUESTION # 29
You are setting up RBAC for a Kubernetes cluster with three namespaces: "development", "staging", and "production". You need to create a role binding that allows developers in the "development" namespace to create deployments, pods, and services, but only within their own namespace.

Answer:

Explanation:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1 Create a Role for Developers:

2. Create a Role Binding for Developers:

3. Replace 'developer-user' with the actual username of a developer. 4. Repeat steps 1-3 for other namespaces ("staging" and "production") with appropriate resource permissions and user names. 5. Verify the RBAC configuration: - Check that the roles and rolebindings are created successfully using 'kubectl get roles' and 'kubectl get rolebindings'. - Test the permissions by creating a pod, deployment, or service as a developer user in their respective namespaces. 6. If you encounter issues, review the configuration carefully, making sure the namespaces, roles, role bindings, and user names are correct.


NEW QUESTION # 30
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:



NEW QUESTION # 31
......

Get professional help from our CKA Dumps PDF: https://www.2pass4sure.com/Kubernetes-Administrator/CKA-actual-exam-braindumps.html

Clear your concepts with CKA Questions Before Attempting Real exam: https://drive.google.com/open?id=1eneSLRRadBk6R2_yWOoKAdaeehiyIFaB