IT/CKA

[CKA] Mock Exam 1 풀이

고슴도치 엔지니어 2022. 2. 23. 00:45

1. Deploy a pod named nginx-pod using the nginx:alpine image.

# nginx-pod 라는 이름의 pod를 nginx:alpine 이라는 이미지를 사용하여 배포하라.

 

$ kubectl run nginx-pod --image=nginx:alpine

 

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

# messaging 이라는 pod를 redis:alpine 이라는 이미지를 사용하여 배포하라. lables는 tier=msg로 설정.

 

$ kubectl run messaging --image=redis:alpine --labels=tier=msg

 

3. Create a namespace named apx-x9984574.

 

$ kubectl create ns apx-x9984574

$ kubectl get ns

 

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

# node들의 목록을 JSON 포맷으로 저장하라. 위치 : /opt/outputs/nodes-z3444kd9.json

 

$ kubectl get nodes -o json > /opt/outputs/nodes-z3444kd9.json

 

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

# messaging-service 라는 서비스를 만들고 messaging 이라는 Pod에 expose해라. 포트는 6379로 설정.

  • Service: messaging-service
  • Port: 6379
  • Type: ClusterIp

 

$ kubectl expose pod messaging --name=messaging-service --port=6379

 

# 서비스는 create 명령어가 따로 없고 expose를 하면 생성되는것으로 추정.

 

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

 

$ kubectl create deployment hr-web-app --image=kodekloud/webapp-color --replicas=2

 

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

 

$ kubectl run static-busybox --image=busybox --dry-run=client -o yaml > static-busybox.yaml

$ vi static-busybox-pod.yaml

spec:

  container:

    command: ["sleep", "1000"]

 

$ mv static-busybox-pod.yaml /etc/kubernetes/manifests

 

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

 

$ kubectl run temp-bus --image=redis:alpine -n finance

 

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

 

$ kubectl get pod orange -o yaml > orange.yaml

 

$ kubectl delete pod orange

 

$ vi orange.yaml

sleeeep -> sleep 으로 수정

 

$ kubectl apply -f orange.yaml

 

10. Expose the hr-web-app as service hr-web-app-service application on port 30082 on the nodes on the cluster.

  • Name: hr-web-app-service
  • Type: NodePort
  • Endpoints: 2
  • Port: 8080
  • NodePort: 30082

$ kubectl expose 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

nodePort: 30082

 

$ kubectl apply -f hr-web-app-service

$ kubectl get svc

 

11. Use JSON PATH query to retrieve the os lmages of all the nodes and store it in a file /opt/outputs/nodes_os_x43kj56.txt

 

$ kubectl get nodes -o jsonpath='{.items[*].status.nodeInfo.osImage}' > /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

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-analytics
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/pv/data-analytics"

$ kubectl apply -f pv-analytics.yaml