본문 바로가기
AEWS2기

1-0. 쿠버네티스 인 액션 (11장_쿠버네티스 내부 이해)

by yeongki0944 2024. 3. 8.

목차

 

 

 

1. 아키텍처 이해

https://kubernetes.io/docs/concepts/overview/components/

 

Control Plane

https://www.logicmonitor.com/support/kubernetes-control-plane-monitoring-overview

 

Worker Node

https://jyeonth.tistory.com/26

 

Addons

https://discuss.kubernetes.io/t/kubernetes-io-blog-automated-high-availability-in-kubeadm-v1-15-batteries-included-but-swappable/6914

 

 

1. 1 쿠버네티스 구성 요소의 분산 특성

  • 쿠버네티스의 모든 컴포넌트는 개별 프로세스로 실행
  • API 서버 - etcd와 직접적으로 통신할 수 있는 유일한 컴포넌트

 

  • API서버 - Kubelet 통신
    • kubectl logs : 컨테이너 로그 조회
    • kubectl attach : 실행 중인 컨테이너 연결
    • kubectl port-forward : Pod와 로컬 머신간에 포트 포워딩 설정

 

  • Control Plane HA 구성

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/ha-topology/

 

  • Pod로 실행되는 Control Plane의 구성요소들
    • 단, Kubelet은 무조건 데몬(시스템 구성요소)로 실행되어야 된다.

 

1. 2 쿠버네티스가 etcd를 사용하는 방법

  • etcd v2 vs etcd v3
etcd버전 디렉터리 지원 여부 프로토콜
v2 O HTTP/JSON
v3 X HTTP/JSON, gRPC

 

  • 쿠버네티스 -  루트 디렉터리 ( /registry )

 

# Etcd v2
etcdctl ls /registry
# Etcd v3
etcdctl get /registry --prefix=true


etcdctl get /registry/pods/default/kubia-159041347-wt6ga

/registry/pods/default/kubia-159041347-wt6ga

 

 

  • etcd - 오브젝트의 일관성, 유효성 보장

https://jyeonth.tistory.com/26

  • API 서버 - etcd와 통신할 수 있는 유일한 컴포넌트
    • 낙관적 잠금 메커니즘 ??
      • 오류 발생 가능성
      • 일관성
      • 보안

 

  • etcd - 클러스터링된 etcd의 일관성 보장
    • 고가용성을 위해 etcd 클러스터링, 일관성 유지가 어려워짐
      • RAFT 합의 알고리즘으로 일관성 유지함

 

 

  • etcd - 홀수인 이유
    • 합의 알고리즘 > 쿼럼 조건에 따라 3, 5, 7 홀수 갯수가 추천

 

1. 3  API 서버의 기능

 

 

  • kubeconfig - kubectl이 API 서버 주소를 저장하는 곳
    • clusters[0].cluster.server - API 서버 주소
# kubeconfig default 위치 : $HOME/.kube/config
# 위치 변경 방법 : export KUBECONFIG=/my/path/kubeconfig
cat $HOME/.kube/config
# apiVersion: v1
# clusters:
# - cluster:
# certificate-authority-data: xxxx
# server: https://10.0.0.1:6443
# name: cluster.local
# contexts:
# - context:
# ...
# ...

 

https://dockerlabs.collabnix.com/kubernetes/beginners/what-is-kubect.html

 

https://kubernetes.io/ko/docs/concepts/security/controlling-access/

인증, 인가 내용은 추후 다시 학습하기

현재 수준에서 공부하기에는 난이도가 높은 파트

  • 인증 플러그인으로 클라이언트 인증
  • 인가 플러그인을 통한 클라이언트 인가
  • 어드미션 컨트롤 플러그

 


1. 4 API 서버가 리소스 변경을 클라이언트에 통보하는 방법 이해

 


1. 5 스케줄러 이해

 

Kubernetes' scheduling process

https://www.researchgate.net/figure/Kubernetes-scheduling-process_fig6_347525517

 

스케줄링 FlowChart

https://www.alibabacloud.com/blog/a-brief-analysis-on-the-implementation-of-the-kubernetes-scheduler_595083


1. 6 컨트롤러 매니저에서 실행되는 컨트롤러 소개

https://sysdig.com/blog/how-to-monitor-kube-controller-manager/

  • 컨트롤러 매니저
    • a component of the control plane
    • running in the form of a container within a Pod, on every master node.
      • yaml path : /etc/kubernetes/manifests/kube-controller-manager.yaml
    • a collection of different Kubernetes controllers
  • 컨트롤러 매니저 main task
    • to watch for changes in the state of the objects
    • make sure that the actual state converges(수렴) towards the desired state
    • it is responsible for the reconciling tasks around the state of Kubernetes objects.

 

  • 컨트롤러 목록 (Kubernetes in action - EN. 2018 / KR. 2020 출판 버전 기준) 
    • 각 컨트롤러별 설명은 다음 스터디 포스팅시 진행

 


1. 7 Kubelet이 하는 일

kubelet이 기동할때 호출되는 구성요소(https://clarkshim.tistory.com/302)

https://sysdig.com/blog/how-to-monitor-kubelet/