푸잉이의 기술블로그
[Day6] Certified Kubernetes Administrator (CKA) with Practice Tests 본문
[Day6] Certified Kubernetes Administrator (CKA) with Practice Tests
data고수 2023. 1. 10. 02:3564강 Taints and Tolerations vs Node Affinity
ex) 빨강, 초록, 파랑 node와 pod가 있을 때
각 색에 맞게 Taints와 Tolerations을 넣어줌 (빨강 pod에 tolerations을 뿌려줬다해서 빨강 node에 들어가는 것이 아닌 other에 들어갈 수 있음)
Node affinity: Node label로 넣어주는데 다른 pod가 빨간색 node에 들어갈 수 있음
두개를 섞으면 빨강 node-빨강 pod 초록 node-초록 pod 파랑 node-파랑 pod로 배치 됨
65강 Resource Requirements and Limits
pod에 container에 대한 resource 요청을 지정하면, kube-scheduler는 pod가 배치될 node를 결정함
container에 대한 resource limit을 지정하면, kubelet은 실행 중인 container가 설정한 제한보다 많은 resource를 사용할 수 없도록 해당 제한을 적용함
cluster 안에 memory등이 가득 차면 hold back (pending)
리소스 단위: cpu일 경우 ms(밀리 세컨드), 메모리일 경우 Mb ex) 256MiB
해당 컨테이너에 얼만큼의 cpu resource를 할당할 것인가? -Request와 limit 사용
*쿠버네티스에서 CPU Resource를 1m보다 더 정밀한 단위로 표기할 수 없음
*0.005보다는 5m로 표기하는 것이 좋음
각 pod에서 요구하는 cpu, 메모리 기본 설정값은 0.5CPU, 256Mi임
제한 값은 1CPU, 512Mi
Request: 컨테이너가 생성될 때 요청하는 resource 양
limit: 컨테이너가 생성된 후 실행되다가 Resource가 더 필요한 경우 추가로 더 사용할 수 있는 부분
<리소스 정의 방법>
apiVersion: v1
kind: Pod
metadata:
name: frontend
spec:
containers:
- name: db
image: mysql
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
- name: wp
image: wordpress
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
-> container 운영에 필요한 리소스 양을 명시하여 요청하는 방법
어떤 개발자나 팀이 불필요하게 많은 리소스 요청 -> 자원 낭비 & 다른 팀 피해
-> Namespace 별로 사용할 수 있는 resource 양 정할 수 있음 & container마다 사용할 수 있는 resource 양을 지정할 수 있음 -> Resource Quota 이용
66강 Note on default resource requirements and limits
pod이 생성될 때 컨테이너에는 0.5의 기본 CPU 요청과 256Mi의 메모리가 할당할 때,
POD이 이러한 기본값을 선택하려면 먼저 해당 네임스페이스에 LimitRange를 만들어 요청 및 제한에 대한 기본값으로 설정해야 함.
67강 A quick note on editing Pods and deployments
You can then delete the existing pod by running the command:
-> kubectl delete pod webapp
Then create a new pod with your changes using the temporary file
-> kubectl create -f /tmp/kubectl-edit-ccvrq.yaml
2. The second option is to extract the pod definition in YAML format to a file using the command
-> kubectl get pod webapp -o yaml > my-new-pod.yaml
Then make the changes to the exported file using an editor (vi editor). Save the changes
-> vi my-new-pod.yaml
Then delete the existing pod
-> kubectl delete pod webapp
Then create a new pod with the edited file
-> kubectl create -f my-new-pod.yaml
Edit Deployments
-> kubectl edit deployment my-deployment
OOMKilled: 메모리 문제
70강 DeamonSets
like replicaset (여러개의 파드를 생성하고 관리할 수 있음)
one copy of the pod는 모든 cluster 안의 node에 있음
활용 예) 모니터링 시스템, kube-proxy, Networking
ReplicaSet과 Daemonset definition file 거의 동일 (중첩된 부분도 있음)
-> kubectl create -f daemon-set-definition.yaml
1node 1pod 할당 방법
-v1.12 이전: 생성되기 전에 적절한 nodename 설정
-v1.12 이후: nodeaffinity와 default scheduler를 사용
73강 Static Pods
kubeAPIServer 말고 자체적으로 생성된 pod (only pod)
API 서버 없이 특정 노드의 Kubelet (pod level)에 의해 생성/관리되는 pod
서버 내 특정 directory에 yaml 형태로 존재
<Life-cycle>
생성: Static pod 경로에 yaml 파일이 존재할 경우 자동으로 pod 생성
유지: Static pod 경로에 yaml 파일이 존재할 경우 pod가 삭제되어도 재생성
수정: Static pod 경로에 yaml 파일을 수정하면 자동으로 기존 pod가 삭제되고 새로운 pod가 생성
삭제: Static pod 경로에 yaml 파일을 삭제하고, pod를 delete해야 완전 삭제
DaemonSet
공통점: kube-scheduler에 의해 ignored됨
차이점: Static pods는 kubelet에 의해 생성, control plane component를 배포
Daemonset은 kube-api server에 의해 생성 (daemonseet controller), monitoring agent, 노드의 logging agent 배포
파일 가져오는 경로 확인/설정 가능
1) kubelet.service에서 --pod-manifest-path 확인
2) kubelet.service의 config option에서 config file path를 확인, 해당 파일에서 staticPodPath 확인
Static pod는 docker ps로 확인 가능 (kubeapi 사용불가)
KubeAPIServer ->(input)-> kubelet
1. pod definition file-> static pods folder 전달
2. ACDP API
KubeAPIServer도 pod 알 수 있음
KubeAPIserver는 static pods를 수정하기 위해선 manifest file 수정 해야함
참조:
쿠버네티스 #21 - 리소스(CPU/Memory) 할당과 관리
쿠버네티스 리소스(CPU/Memory)할당과 관리조대협 리소스 관리 쿠버네티스에서 Pod를 어느 노드에 배포할지를 결정하는 것을 스케쥴링이라고 한다.Pod에 대한 스케쥴링시에, Pod내의 애플리케이션이
bcho.tistory.com
https://sarc.io/index.php/cloud/2237-kubernetes-static-pod
Kubernetes Static Pod란 무엇인가?
Tech Note 정보 opennova 님이 작성하신 글입니다. 카테고리: [ Cloud Computing & MSA ] 게시됨: 28 December 2021 작성됨: 28 December 2021 최종 변경: 28 December 2021 조회수: 1572 1. 개요 쿠버네티스의 스태틱 파에 대해
sarc.io