본문 바로가기
cloud/k8s(문제풀이)

[cka] Mock exam-1

by mozi2 2022. 8. 19.
반응형

1.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!

  • Name: nginx-pod

  • Image: nginx:alpine

방법1)
k run nginx-pod --image=nginx:alpine

방법2)
k run nginx-pod --image=nginx:alpine --dry-run=client -o yaml > nginx-pod.yaml
k apply -f nginx-pod.yaml

k get pod

 

2.Deploy a messaging pod using the redis:alpine image with the labels set to tier=msg.

  • Pod Name: messaging

  • Image: redis:alpine

Labels: tier=msg

방법1)
k run messaging --image=redis:alpine --labels=tier=msg

방법2)
k run messaging --image=redis:alpine --dry-run=client -o yaml > messaging.yaml

vi messaging.yaml

k apply -f messaging.yaml
k get po

3.Create a namespace named apx-x9984574.

  • Namespace: apx-x9984574

k create ns apx-x9984574
k get ns apx-x9984574

4.Get the list of nodes in JSON format and store it in a file at /opt/outputs/nodes-z3444kd9.json.

  • Task completed

k get nodes -o json > /opt/outputs/nodes-z3444kd9.json

cat /opt/outputs/nodes-z3444kd9.json

5.Create a service messaging-service to expose the messaging application within the cluster on port 6379.

Use imperative commands.

  • Service: messaging-service

  • Port: 6379

  • Type: ClusterIp

  • Use the right labels

kubectl expose pod messaging clusterip --name=messaging-service --port=6379 --dry-run=client -o yaml > messaging-service.yaml

k apply -f messaging-service
k get svc

6.Create a deployment named hr-web-app using the image kodekloud/webapp-color with 2 replicas.

  • Name: hr-web-app

  • Image: kodekloud/webapp-color

  • Replicas: 2

k create deployment hr-web-app --image=kodekloud/webapp-color --replicas=2 --dry-run=client -o yaml > hr-web-app.yaml

k apply -f hr-web-app.yaml

7. Create a static pod named static-busybox on the controlplane node that uses the busybox image and the command sleep 1000.

  • Name: static-busybox

  • Image: busybox

방법1)
k run static-busybox --image=busybox --dry-run=client -o yaml > static-busybox.yaml

vi static-busybox.yaml    ----- command추가
k apply -f static-busybox.yaml

방법2)
k run static-busybox --image=busybox --command -- sleep 1000

 

8.Create a POD in the finance namespace named temp-bus with the image redis:alpine.

  • Name: temp-bus

  • Image Name: redis:alpine

k create ns temp-bus

k run finance temp-bus -n finance --image=redis:alpine --dry-run=client -o yaml > finance.yaml
k apply -f finance.yaml

9.A new application orange is deployed. There is something wrong with it. Identify and fix the issue.

  • Issue fixed

방법1)
k get po orange -o yaml > oragne.yaml

vi orange.yaml

sleeeep -> sleep 

방법1)
k edit pod orange
k replace --force -f [경로/이름]

10.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.

  • Name: hr-web-app-service

  • Type: NodePort

  • Endpoints: 2

  • Port: 8080

  • NodePort: 30082

kubectl expose deployment hr-web-app --name=hr-web-app-service --port=8080 --type=NodePort --dry-run=client -o yaml > hr-web-app-service.yaml

vi hr-web-app-service.yaml
k apply -f hr-web-app-service.yaml

11.Use JSON PATH query to retrieve the osImages 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.

  • Task Completed

k get nodes -o jsonpath='{.items[*].status.nodeInfo.osImage}' > /opt/outputs/nodes_os_x43kj56.txt

cat /opt/outputs/nodes_os_x43kj56.txt

 

12.Create a Persistent Volume with the given specification.

  • Volume Name: pv-analytics

  • Storage: 100Mi

  • Access modes: ReadWriteMany

  • Host Path: /pv/data-analytics

vi pv-analytics.yaml
k apply -f pv-analytics.yaml

728x90
반응형