CKA 분류
[KodeKloud] [CKA] Mock Exam - 1
컨텐츠 정보
- 1,474 조회
- 1 댓글
- 0 추천
-
목록
본문
# MOCK EXAMS, MOCK EXAM – 1
Q. 1
- *info_outline*Question
Deploy a pod named `nginx-pod` using the `nginx:alpine` image.
Once done, click on the `Next Question` button in the top right corner of this panel. You may navigate back and forth freely between all questions. Once done with all questions, click on `End Exam`. Your work will be validated at the end and score shown. Good Luck!
- *info_outline*Solution
Use the command: `kubectl run nginx-pod --image=nginx:alpine`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 2
- *info_outline*Question
Deploy a `messaging` pod using the `redis:alpine` image with the labels set to `tier=msg`.
- *info_outline*Solution
Use the command `kubectl run messaging --image=redis:alpine -l tier=msg`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 3
- *info_outline*Question
Create a namespace named `apx-x9984574`.
- *info_outline*Solution
Run the command: `kubectl create namespace apx-x9984574`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 4
- *info_outline*Question
Get the list of nodes in JSON format and store it in a file at `/opt/outputs/nodes-z3444kd9.json`.
- *info_outline*Solution
Run the command: `kubectl get nodes -o json > /opt/outputs/nodes-z3444kd9.json`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 5
- *info_outline*Question
Create a service `messaging-service` to expose the `messaging` application within the cluster on port `6379`.
Use imperative commands.
- *info_outline*Solution
Run the command: `kubectl expose pod messaging --port=6379 --name messaging-service`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 6
- *info_outline*Question
Create a deployment named `hr-web-app` using the image `kodekloud/webapp-color` with `2` replicas.
- *info_outline*Solution
Run the command: `kubectl create deployment hr-web-app --image=kodekloud/webapp-color --replicas=2`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 7
- *info_outline*Question
Create a static pod named `static-busybox` on the controlplane node that uses the `busybox` image and the command `sleep 1000`.
- *info_outline*Solution
Create a pod definition file in the manifests directory. For that use command `kubectl run --restart=Never --image=busybox static-busybox --dry-run=client -oyaml --command -- sleep 1000 > /etc/kubernetes/manifests/static-busybox.yaml`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 8
- *info_outline*Question
Create a POD in the `finance` namespace named `temp-bus` with the image `redis:alpine`.
- *info_outline*Solution
Run the command: `kubectl run temp-bus --image=redis:alpine --namespace=finance --restart=Never`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 9
- *info_outline*Question
A new application `orange` is deployed. There is something wrong with it. Identify and fix the issue.
- *info_outline*Solution
To know more details of `orange` pod:
```
$ kubectl describe po orange
```
and look under the `initContainers` section. There is an issue with the given command.
To update the pod with an easiest way by running command:
```
$ kubectl edit po orange
```
It's not possible to update the changes in the running pod so after saving the changes. It will create a temporary file in the default location `/tmp/`.
Use that manifest file and replace with the existing pod:
```
$ kubectl replace -f /tmp/kubectl-edit-xxxx.yaml --force
```
Above command will delete the existing pod and will recreate the new pod with latest changes.
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 10
- *info_outline*Question
Expose the `hr-web-app` as service `hr-web-app-service` application on port `30082` on the nodes on the cluster.
The web application listens on port `8080`.
- *info_outline*Solution
Run the command: `kubectl expose deployment hr-web-app --type=NodePort --port=8080 --name=hr-web-app-service --dry-run=client -o yaml > hr-web-app-service.yaml` to generate a service definition file.
Now, in generated service definition file add the `nodePort` field with the given port number under the `ports` section and create a service.
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 11
- *info_outline*Question
Use JSON PATH query to retrieve the `osImage`s of all the nodes and store it in a file `/opt/outputs/nodes_os_x43kj56.txt`.
The `osImages` are under the `nodeInfo` section under `status` of each node.
- *info_outline*Solution
Run the command: `kubectl get nodes -o jsonpath='{.items[*].status.nodeInfo.osImage}' > /opt/outputs/nodes_os_x43kj56.txt`
**CheckCompleteIncomplete**
- *format_list_bulleted*Details
Q. 12
- *info_outline*Question
Create a `Persistent Volume` with the given specification.
- *info_outline*Solution
Solution manifest file to create a persistent volume `pv-analytics` as follows:
```
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-analytics
spec:
capacity:
storage: 100Mi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
hostPath:
path: /pv/data-analytics
```