CKA試験無料問題集「Linux Foundation Certified Kubernetes Administrator (CKA) Program 認定」

Create a deployment spec file that will:
* Launch 7 replicas of the nginx Image with the labelapp_runtime_stage=dev
* deployment name: kual00201
Save a copy of this spec file to /opt/KUAL00201/spec_deployment.yaml
(or /opt/KUAL00201/spec_deployment.json).
When you are done, clean up (delete) any new Kubernetes API object that you produced during this task.
正解:

Print pod name and start time to "/opt/pod-status" file
正解:
kubect1 get pods -o=jsonpath='{range
items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\n"}{end}'
Schedule a Pod as follows:
. Name: kucc1
. App Containers : 2
. Container Name/Images :
* redis
* Memcached
正解:
A screen shot of a computer AI-generated content may be incorrect.
Get list of all the pods showing name and namespace with a jsonpath expression.
正解:
kubectl get pods -o=jsonpath="{.items[*]['metadata.name'
, 'metadata.namespace']}"
You must connect to the correct host.
Failure to do so may result in a zero score.
[candidate@base] $ ssh Cka000046
Task
First, create a new StorageClass named local-path for an existing provisioner named rancher.io/local-path .
Set the volume binding mode to WaitForFirstConsumer .
Not setting the volume binding mode or setting it to anything other than WaitForFirstConsumer may result in a reduced score.
Next, configure the StorageClass local-path as the default StorageClass .
正解:
Task Summary
You need to:
* SSH into cka000046
* Create a StorageClass named local-path using the provisioner rancher.io/local-path
* Set the volume binding mode to WaitForFirstConsumer
* Make this StorageClass the default
Step-by-Step Solution
1## SSH into the correct host
ssh cka000046
## Required. Skipping this = zero score
2## Create a StorageClass YAML file
Create a file named local-path-sc.yaml:
cat <<EOF > local-path-sc.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-path
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
EOF
# This:
* Sets WaitForFirstConsumer (as required)
* Marks the class as default using the correct annotation
3## Apply the StorageClass
kubectl apply -f local-path-sc.yaml
4## Verify it's the default StorageClass
kubectl get storageclass
You should see local-path with a (default) marker:
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION
AGE
local-path rancher.io/local-path Delete WaitForFirstConsumer false 10s
Final Command Summary
ssh cka000046
cat <<EOF > local-path-sc.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-path
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: rancher.io/local-path
volumeBindingMode: WaitForFirstConsumer
EOF
kubectl apply -f local-path-sc.yaml
kubectl get storageclass
Schedule a pod as follows:
* Name: nginx-kusc00101
* Image: nginx
* Node selector: disk=ssd
正解:


Monitor the logs of pod foo and:
* Extract log lines corresponding to error
unable-to-access-website
* Write them to/opt/KULM00201/foo
正解:


Step 0: Set the correct Kubernetes context
If you're given a specific context (k8s in this case), you must switch to it:
kubectl config use-context k8s
## Skipping this can cause you to work in the wrong cluster/namespace and cost you marks.
Step 1: Identify the namespace of the pod foo
First, check if foo is running in a specific namespace or in the default namespace.
kubectl get pods --all-namespaces | grep foo
Assume the pod is in the default namespace if no namespace is mentioned.
Step 2: Confirm pod foo exists and is running
kubectl get pod foo
You should get output similar to:
NAME READY STATUS RESTARTS AGE
foo 1/1 Running 0 1h
If the pod is not running, logs may not be available.
Step 3: View logs and filter specific error lines
We're looking for log lines that contain:
unable-to-access-website
Command:
kubectl logs foo | grep "unable-to-access-website"
Step 4: Write the filtered log lines to a file
Redirect the output to the required path:
kubectl logs foo | grep "unable-to-access-website" > /opt/KULM00201/foo
# This creates or overwrites the file /opt/KULM00201/foo with the filtered logs.
# You may need sudo if /opt requires elevated permissions. But in most exam environments, you're already the root or privileged user.
Step 5: Verify the output file (optional but smart)
Check that the file was created and has the correct content:
cat /opt/KULM00201/foo
# Final Answer Summary:
kubectl config use-context k8s
kubectl logs foo | grep "unable-to-access-website" > /opt/KULM00201/foo
Score: 7%

Task
Create a new nginx Ingress resource as follows:
* Name: ping
* Namespace: ing-internal
* Exposing service hi on path /hi using service port 5678
正解:
Solution:
vi ingress.yaml
#
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ping
namespace: ing-internal
spec:
rules:
- http:
paths:
- path: /hi
pathType: Prefix
backend:
service:
name: hi
port:
number: 5678
#
kubectl create -f ingress.yaml
Create a pod named kucc8 with a single app container for each of the
following images running inside (there may be between 1 and 4 images specified):
nginx + redis + memcached.
正解: