CKA別格な問題集をダウンロードして無料で最新の(CKAテスト問題集をゲット) [Q49-Q71]

Share

CKA別格な問題集をダウンロードして無料で最新の(CKAテスト問題集をゲット2025年02月09日)

CKA問題集は合格保証します合格できるCKA試験問題2025年更新

質問 # 49
Get the pods with labels env=dev and env=prod and output the labels as well

正解:

解説:
kubectl get pods -l 'env in (dev,prod)' --show-labels


質問 # 50
Create an nginx pod with container Port 80 and it should only receive traffic only it checks the endpoint / on port 80 and verify and delete the pod.

  • A. kubectl run nginx --image=nginx --restart=Never --port=80 --
    dry-run -o yaml > nginx-pod.yaml
    // add the readinessProbe section and create
    vim nginx-pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    run: nginx
    name: nginx
    spec:
    containers:
    - image: nginx
    name: nginx
    ports:
    - containerPort: 80
    readinessProbe:
    httpGet:
    path: /
    port: 80
    restartPolicy: Never
    kubectl apply -f nginx-pod.yaml
    // verify
    kubectl describe pod nginx | grep -i readiness
    kubectl delete po nginx
  • B. kubectl run nginx --image=nginx --restart=Never --port=80 --
    dry-run -o yaml > nginx-pod.yaml
    // add the readinessProbe section and create
    vim nginx-pod.yaml
    run: nginx
    name: nginx
    spec:
    containers:
    - image: nginx
    name: nginx
    ports:
    - containerPort: 60
    readinessProbe:
    httpGet:
    path: /
    port: 60
    restartPolicy: Never
    kubectl apply -f nginx-pod.yaml
    // verify
    kubectl describe pod nginx | grep -i readiness
    kubectl delete po nginx

正解:A


質問 # 51
You have a deployment that runs multiple replicas of a web server application. You need to ensure that the Deployment always maintains at least 2 replicas available, even if one or more pods are deleted or become unavailable. How can you configure the Deployment to achieve this using the 'maxUnavailable' field in the 'strategy.rollingUpdate' section?

正解:

解説:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Define the Deployment with maxUnavailable': Define a Deployment YAML file with 'replicas: 3', indicating that you want three replicas of the web server application. Then, in the 'strategy.rollinglJpdate' section, set the 'maxUnavailable' field to '1'.

2. Apply the Deployment: Apply the YAML file to your cluster using 'kubectl apply -f my-web-server.yamr. The deployment will create three replicas of your web server application. 3. Test the 'maxUnavailable' Configuration: Delete or terminate one of the pods in the Deployment. The Deployment will automatically create a new pod to replace the deleted or unavailable one, ensuring that at least two replicas are always available. You can monitor the status of the deployment using 'kubectl get pods -l app=my-web-server'. You should see that two pods are consistently running, while the third is being replaced.


質問 # 52
You have a Deployment named 'worker-deployment' with 10 replicas of a worker container. You need to implement a rolling update strategy that allows for a maximum of 3 pods to be unavailable at any given time during the update process. You also want to ensure that the update process is completed within a specified timeout of 10 minutes. If the update fails to complete within the timeout, the deployment should revert to the previous version. Additionally, you want to implement a pause functionality to temporarily halt the rolling update process.

正解:

解説:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Update the Deployment YAML:
- Update the 'replicas' to 10.
- Define 'maxUnavailable: 3' and 'maxSurge: 0' in the 'strategy.rollingUpdate' section to control the rolling update process.
- Configure a 'strategy.type' to 'RollingUpdate' to trigger a rolling update when the deployment is updated.
- Set Always' to ensure that the new image is pulled even if it exists in the pod's local cache.
- Add a 'spec.progressDeadlineSeconds: 600' to set a timeout of 10 minutes for the update process.

2. Create the Deployment: - Apply the updated YAML file using 'kubectl apply -f worker-deployment.yaml' 3. Verify the Deployment: - Check the status of the deployment using 'kubectl get deployments worker-deployment' to confirm the rollout and updated replica count. 4. Trigger the Automatic Update: - Push a new image to the 'my.org/worker:latest' Docker Hub repository. 5. Monitor the Deployment: - Use "kubectl get pods -l app=worker' to monitor the pod updates during the rolling update process. 6. Pause the Rolling Update: - To pause the rolling update process, use the following command: bash kubectl rollout pause deployment worker-deployment 7. Resume the Rolling Update: - To resume the rolling update process, use the following command: bash kubectl rollout resume deployment worker-deployment 8. Observe Rollback if Timeout Exceeds: - If the update process takes longer than 10 minutes to complete, the deployment will be rolled back to the previous version. This can be observed using 'kubectl describe deployment worker-deployment' and checking the 'updatedReplicas' and 'availableReplicas" fields.


質問 # 53
Create a redis pod and expose it on port 6379

  • A. kubectl run redis --image=redis --restart=Never --port=6379
    YAML File :
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    run: redis
    name: redis
    spec:
    containers:
    - image: redis
    name: redis
    ports:
    - containerPort: 6379
    Rt restartPolicy: Always
  • B. kubectl run redis --image=redis --restart=Never --port=6379
    YAML File :
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    run: redis
    name: redis
    spec:
    containers:
    ports:
    - containerPort: 6679
    Rt restartPolicy: Alwaysf

正解:A


質問 # 54
Get IP address of the pod - "nginx-dev"

正解:

解説:
Kubect1 get po -o wide
Using JsonPath
kubect1 get pods -o=jsonpath='{range
.items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'


質問 # 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.

正解:

解説:
solution



質問 # 56
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?

正解:

解説:
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. ]


質問 # 57
Create a secret mysecret with values user=myuser and password=mypassword

  • A. kubectl create secret generic my-secret --fromliteral=username=user --from-literal=password=mypassword
    // Verify
    kubectl get secret generic my-secret -o yaml
  • B. kubectl create secret generic my-secret --fromliteral=username=user --from-literal=password=mypassword
    // Verify
    kubectl get secret --all-namespaces
    kubectl get secret generic my-secret -o yaml

正解:B


質問 # 58
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

正解:

解説:
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


質問 # 59
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

正解:B


質問 # 60
You have a Kubernetes cluster running a deployment named 'my-app' that is exposed via a NodePort service. You want to restrict access to the service from specific IP addresses within the cluster. How can you achieve this using a NetworkPolicy?

正解:

解説:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Create a NetworkPolicy:
- Create a NetworkPolicy in the namespace where 'my-app' deployment runs.
- Code:

2. Apply the NetworkPolicy: - Apply the NetworkPolicy using 'kubectl apply -f networkpolicy.yamP


質問 # 61
Your team is deploying a critical application on Kubernetes and needs to ensure its availability and performance. You are considering implementing a load balancer for the application to distribute traffic across multiple pods. Describe the types of load balancers available in Kubernetes and explain how to implement an external load balancer using a cloud provider's load balancer service.

正解:

解説:
See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1 . Types of Load Balancers in Kubernetes:
- NodePort: A simple load balancer that exposes the service on each node's IP address and a specific port.
- LoadBalancer: Exposes the service on the public IP address of the cloud provider's load balancer.
- Ingress: A higher-level abstraction that allows for more flexible routing and configuration of traffic to services.
2. Implementing an External Load Balancer using a Cloud Provider:
- Create a Kubernetes Service:
- Define a Kubernetes Service that exposes the application on a specific port.
- Configure the service type to 'LoadBalancer'.

- Configure a Cloud Provider Load Balancer: - Access the load balancer management console of your cloud provider (e.g., AWS Elastic Load Balancer, Google Cloud Load Balancing, Azure Load Balancer). - Create a new load balancer and configure it to listen on the desired port (e.g., port 80). - Configure the load balancer to distribute traffic to the Kubernetes service. This might involve specifying the Kubernetes service's IP address or hostname, depending on the cloud provider's setup. - Configure the health check settings to ensure that the load balancer only routes traffic to healthy pods. - Verify Load Balancer Configuration: - Once the cloud provider load balancer is configured, verify that it is working correctly by accessing the load balancer's public IP address and ensuring that the application responds as expected. - You can also use 'kubectl describe service myapp-service' to check the load balancer's status and external IP address. ,


質問 # 62
Create a nginx pod with label env=test in engineering namespace
See the solution below.

  • A. kubectl run nginx --image=nginx --restart=Never --labels=env=test --namespace=engineering --dry-run -o yaml > nginx-pod.yaml kubectl run nginx --image=nginx --restart=Never --labels=env=test --namespace=engineering --dry-run -o yaml | kubectl create -n engineering -f - YAML File:
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx
    namespace: engineering
    labels:
    env: test
    spec:
    containers:
    - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
    restartPolicy: Never
    kubectl create -f nginx-pod.yaml
  • B. kubectl run nginx --image=nginx --restart=Never --labels=env=test --namespace=engineering --dry-run -o yaml > nginx-pod.yaml kubectl run nginx --image=nginx --restart=Never --labels=env=test --namespace=engineering --dry-run -o yaml | kubectl create -n engineering -f - YAML File:
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx
    namespace: engineering
    labels:
    env: test
    spec:
    containers:
    - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
    restartPolicy: Never
    kubectl create -f nginx-pod.yaml

正解:B


質問 # 63
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.

正解:

解説:
solution



質問 # 64
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

正解:

解説:
solution



質問 # 65
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"}'

正解:B


質問 # 66
Get list of all pods in all namespaces and write it to file "/opt/pods-list.yaml"

正解:

解説:
See the solution below.
Explanation
kubectl get po -all-namespaces > /opt/pods-list.yaml


質問 # 67
Create 2 nginx image pods in which one of them is labelled with env=prod and another one labelled with env=dev and verify the same.

正解:

解説:
See the solution below.
Explanation
kubectl run --generator=run-pod/v1 --image=nginx -- labels=env=prod nginx-prod --dry-run -o yaml > nginx-prodpod.yaml Now, edit nginx-prod-pod.yaml file and remove entries like "creationTimestamp: null"
"dnsPolicy: ClusterFirst"
vim nginx-prod-pod.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
env: prod
name: nginx-prod
spec:
containers:
- image: nginx
name: nginx-prod
restartPolicy: Always
# kubectl create -f nginx-prod-pod.yaml
kubectl run --generator=run-pod/v1 --image=nginx --
labels=env=dev nginx-dev --dry-run -o yaml > nginx-dev-pod.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
env: dev
name: nginx-dev
spec:
containers:
- image: nginx
name: nginx-dev
restartPolicy: Always
# kubectl create -f nginx-prod-dev.yaml
Verify :
kubectl get po --show-labels
kubectl get po -l env=prod
kubectl get po -l env=dev


質問 # 68
Create a namespace called 'development' and a pod with image nginx called nginx on this namespace.

正解:

解説:
kubectl create namespace development kubectl run nginx --image=nginx --restart=Never -n development


質問 # 69
Create and configure the service front-end-service so it's accessible through NodePort and routes to the existing pod named front-end.

正解:

解説:
See the solution below.
Explanation
solution


質問 # 70
What file type upload is supported as part of the basic WildFire service?

  • A. VBS
  • B. ELF
  • C. PE
  • D. BAT

正解:C


質問 # 71
......

検証済みのCKA問題集で問題と解答で合格保証試験問題集テストエンジン:https://www.passtest.jp/Linux-Foundation/CKA-shiken.html

検証済みのCKA問題集122格別な問題:https://drive.google.com/open?id=1uj1WUMwx5z_5MktQ_QtIHyUum9OpN4jA