본문 바로가기
CKA

[CKA] 연습문제 정리 1탄!

by 싱숭생숭늉 2024. 8. 7.

 

해당 연습문제는 유데미 강의를 바탕으로 작성했다.

https://www.udemy.com/course/certified-kubernetes-administrator-with-practice-tests/?couponCode=ST10MT8624

 

문제를 풀때 https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

해당 경로를 많이 사용하고 많이 참고 했다.

 

시험 시간이 넉넉하지는 않았다 그래서 타이핑 시간과 삭제시간(pod 잘 못 생성시 삭제가 필요)을 줄이기 위해 아래 명령어를 사용했다. (https://peterica.tistory.com/540 피터님이 알려주신 좋은 꿀팁!)

# "kubectl"를 "k"약자로 변경
alias k=kubectl
# yaml파일과 문법이 정상적으로 작동하는 지 확인
export do="--dry-run=client -o yaml" # k create deploy nginx --image=nginx $do
# pod삭제 시 바로 삭제
export now="--force --grace=period 0" # k delete pod nginx $now

 

 

1.

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

k run nginx-pod --image=nginx:alpine
# https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run

 

명령어를 사용하여 pod를 실행시 run 을 사용한다.

 

만약 image를 지정해 주지 않는다면, 아래와 같이 에러가 발생한다.

 

문법이 정확한지 확인이 되었으면 뒤에 "$do"를 지우고 명령어를 실행시켜 주면된다.

 

2.

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

k run messaging --image=redis:alpine --labels="tier=msg"

 

3.

Create a namespace named apx-x9984574.

k create ns apx-x9984574

 

4.

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

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

k expose pod messaging --port=6379 --name messaging-service

 

6.

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

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

 

'CKA' 카테고리의 다른 글

[CKAD] 연습문제 정리 5탄!!  (0) 2024.08.22
[CKAD] 연습문제 정리 4탄!  (0) 2024.08.21
[CKA] 연습문제 정리 3탄!  (0) 2024.08.14
[CKA] 연습문제 정리 2탄!  (0) 2024.08.08
[CKA] 자격증 준비  (0) 2024.08.07