2. Container Orchestration
(Linux) Container?
Docker, rkt, containerd, cri-o, ...
Container X 10, 100, …, more than 10,000?!
• 이식성 어디에서든 구동
• 자원 격리 및 분배 성능 예측 가능
• 자원 집적도 높음 고효율
• …
(System, tool, platform, …, whatever)
$ docker run –name nginx –d nginx
Image
App
Registry
Containerization
Host OS Kernel
Container Container
App
Container Container
Library
App
Library
App
Library
App
Library
Virtualization
Host OS Kernel
VM
App
VM
Guest OS
Hypervisor
App
Library
App
Guest OS
App
Library
Host OS Kernel
App APp
Library
App APp
App APp
Applications on Host
The new wayThe old way
3. Container Orchestration
• 컨테이너 자동 배치 및 복제
• 컨테이너 그룹에 대한 로드 밸런싱
• 컨테이너 장애 복구
• 클러스터 외부에 서비스 노출
• 컨테이너 추가 또는 제거로 확장 및 축소
• 컨테이너 서비스간의 인터페이스를 통한 연결 및 네트워크 포트 노출 제어
http://www.mantech.co.kr/container_orchestration/
4. Brief history of Kubernetes
Borg Omega Kubernetes
2000년대 초
2014 9월 9일
v0.2 Release
내부 서버 운영 Opensource 공개
2019 6월 현재
v1.15.0 Beta1
Release
5. Cluster Architecture
Master (Control Plane)
etcd
API Server
Scheduler
Controller
Manager
Rest APIs
• etcd : Kubernetes DB
• Scheduler : 각 Node에 컨테이너 배치 관리
• Controller Manager : Controller 생성 및 관리
• API Server : 사용자 & Node 통신
• Kubelet : Master 통신, 컨테이너 관리
• Kube-Proxy : 트래픽 처리
Node (Worker)
Container
Runtime
Kubelet Kube-Proxy
6. Installing Kubeadm
https://kubernetes.io/docs/setup/independent/install-kubeadm/
1. 방화벽 포트 개방
2. Container Runtime Interface 설치 (Docker)
3. Kubeadm, Kubelet, Kubectl 설치
4. Swap off, Docker & Kubelet 실행
5. 클러스터 생성 (마스터 2 CPU, 2GB RAM 필수)
- kubeadm init --pod-network-cidr=<pod-network> --apiserver-advertise-address=<master-ip>
6. 3rd-party pod network 설치
7. Join nodes
8. Node Label 추가
- kubectl label node <hostname> <key>=<value>
- Master - Node
- Pod network (calico)
7. Workloads, Pod
Node
L/B
Kube-Proxy
Pod
Volume
Pause
(K8s Container)
Tomcat
(User container)
Nginx
(User Container)
localhost
Pod
Volume
Pause
(K8s Container)
Tomcat
(User container)
Nginx
(User Container)
localhost
Overlay
Network
Kubelet
Overlay
Network
The smallest deployable object
※ Pod 리소스는 실제로 Master의 API Server가 관리 (Node에 실체 없음)
※ Pause Container는 Pod내 Container 들이 Namespace를 공유할 수 있도록 하는 메커니즘 제공
8. Workloads, Controllers
(Pod) Controllers 특징 상태
ReplicationController Pod 복제 (replicas) Stateless
ReplicationSet RC 대신 사용 (확장된 표현식 사용) Stateless
Deployments RS의 상위 수준 리소스 (Deploy 시 자동 RS 생성) Stateless
StatefulSets 상태가 있는 Pod 생성 Stateful
DaemonSet Node 당 1개 보장 Stateless
Jobs 실행 후 삭제 Stateless
Resources 관리
API 서버를 모니터링하며 리소스 생성, 삭제 또는 업데이트
NodeMaster
Controller
Manager
Controller
API Server
Controller
Manifest
(ReplicationSet,
Pod, …)
모니터링
생성, 삭제, 업데이트
Kubelet
9. Services
• 논리적인 Pod Set에 대한 접근 정책 정의
• Pod에 대한 L4 L/B 제공
• Proxy-mode
• Multi-port 서비스
• DNS (Service name or FQDN)
• Service types
- ClusterIP : Only internal (cluster-internal IP)
- NodePort : Both internal and external (node IP & port)
- LoadBalancer : External service using a cloud provider’s load balancer (80 & 443)
- ExternalName : CNAME
userspace iptables ipvs
10. Ingress
• L7 Context L/B
• Virtual Hosting
• SSL/TLS
• Ingress Controller (3rd Party)
- 실제 패킷 처리
Service Service Service
Pod Pod Pod Pod
kubernetes.io/docs
kubernetes.io/blog
gwan-taek.io
kubernetes.io/docs kubernetes.io/bloggwan-taek.io
Ingress
Controller
L7 L/B
L4 L/B
※ On-Prem 환경에서 Nginx Ingress Controller 사용하여 Ingress 구성하는 3가지 방법
• MetalLB
• Ingress Controller Pod의 hostnetwork 설정
• Loadbalancer 타입 Service에서 externalIPs 사용 (Source IP 유실)
12. (very) Simple Live Demo
1. 클러스터 생성
- Master
- Node X 2
2. 노드 상태 및 Kube-system Pod 살펴 보기
3. 간단한 App 배포
- Tomcat
4. Service 생성
5. Ingress 구성 하여 Browser 에서 접속