SlideShare a Scribd company logo
1 of 64
Download to read offline
Kubernetes on Premise
Practical Guide
Kubernetes로 인프라를 옮기며
경험한 내용을 바탕으로 정리한,
클러스터 구축 실용 가이드를 공유합니다
Setup
Kubernetes Cluster
Multi Master Nodes (1)
● kubeadm 명령을 이용해 Multi Master Nodes 클러스터 구축 가능
● 노드 여유가 있다면 클러스터를 생성할 때 Multi Master 구성 적용
● Kubernetes 1.14.x 이상
○ --experimental-upload-certs 옵션을 이용해 인증서 공유
● Kubernetes 1.13.x 이하
○ Master Node 생성 후에 인증서를 다른 Master 노드로 복사하는 작업 필요
Multi Master Nodes (2)
● kubeadm-config.yaml
● controlPlaneEndpoint 항목에 내부에서 사용하는 LoadBalancer IP 지정
○ HAProxy 등을 이용한 LoadBalancer IP
○ Keepalived, Heartbeat 등을 이용한 Failover 구성 적용 가능
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
kubernetesVersion: 1.14.1
controlPlaneEndpoint: "NODEIP:6443"
Master Node 추가: 1.14.x 이상
● Master Node 생성
● Master Node 추가
$ sudo kubeadm init --config kubeadm-config.yaml --experimental-upload-certs
$ sudo kubeadm join NODEIP:6443 --token 9vr73a.a8uxyaju799qwdjv 
--discovery-token-ca-cert-hash 
sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866 
--experimental-control-plane 
--certificate-key 
f8902e114ef118304e561c3ecd4d0b543adc226b7a07f675f56564185ffe0c07
Master Node 추가: 1.13.x 이하 (1)
● Master Node 생성
● 복사할 인증서 목록
$ sudo kubeadm init --config kubeadm-config.yaml
/etc/kubernetes/pki/ca.crt /etc/kubernetes/pki/front-proxy-ca.crt
/etc/kubernetes/pki/ca.key /etc/kubernetes/pki/front-proxy-ca.key
/etc/kubernetes/pki/sa.key /etc/kubernetes/pki/etcd/ca.crt
/etc/kubernetes/pki/sa.pub /etc/kubernetes/pki/etcd/ca.key
Master Node 추가: 1.13.x 이하 (2)
● Master Node 추가
● 구성 확인
$ sudo kubeadm join NODEIP:6443 
--token 9vr73a.a8uxyaju799qwdjv 
--discovery-token-ca-cert-hash
sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866 
--experimental-control-plane
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-1 Ready master 3d v1.14.1
k8s-2 Ready master 3d v1.14.1
k8s-3 Ready master 3d v1.14.1
ETCD Cluster (1)
● Etcd 클러스터 구성
○ External Etcd 구성은 노드 여유가 있고 관리할 여력이 있다면 고려
○ Etcd 클러스터 최소 가용 노드 수를 유지하는 것이 매우 중요
○ (n / 2) + 1 노드 수를 유지하지 못할 경우에는 클러스터 운영에 영향
Cluster Size Majority Failure Tolerance
3 2 1
4 3 1
5 3 2
6 4 2
ETCD Cluster (2)
● Etcd client 설치
● Etcd member list 확인
$ sudo ETCDCTL_API=3 etcdctl --cacert /etc/kubernetes/pki/etcd/ca.crt 
--cert /etc/kubernetes/pki/etcd/peer.crt 
--key /etc/kubernetes/pki/etcd/peer.key member list
18b80ec995adf496, started, k8s-3, https://10.10.1.4:2380, https://10.10.1.4:2379
2ee7a00cdb8ac627, started, k8s-1, https://10.10.1.2:2380, https://10.10.1.2:2379
bcd6b446c02976ab, started, k8s-2, https://10.10.1.3:2380, https://10.10.1.3:2379
$ sudo apt install etcd-client
Pod Network Add-on
● Network Add-on IP 대역과 노드에서 사용하는 대역이 겹칠 경우 문제
○ 예) Weave Net 은 기본값으로 10.32.0.0/12 사용
○ 노드에서 10.0.0.0/8 대역을 사용할 경우
○ 10.32.x.y IP 주소에 대한 라우팅을 결정할 수 없음
● 사용하는 Network Add-on 에 IP 대역을 변경할 수 있는 옵션 이용
○ 예) 노드에서 10.0.0.0/8 대역 사용 중
○ Weave Net 이 기본값으로 사용하는 10.32.0.0/12 는 사용 불가
○ IPALLOC_RANGE 옵션을 이용해 172.30.0.0/16 대역으로 변경
Proxy Mode (1)
● iptables
○ Kubeadm 을 이용해 클러스터를 구축할 경우 기본값
○ iptables 를 이용해 적절한 성능 보장
○ 노드가 늘어나고 Pod 증가에 따라 성능 저하 우려
● ipvs
○ Kubeadm 을 이용해 클러스터를 구축할 때 kubeproxy 옵션을 통해 지정
○ 대규모 노드에서도 성능 보장
○ MetalLB 와 동시에 사용할 때 문제 발생 가능성 존재
■ 적용 전 테스트 필요
Proxy Mode (2)
● ipvsadm 명령을 이용해 제대로 설정되었는지 확인 가능
$ sudo ipvsadm –ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.17.0.1:30000 rr
-> 172.30.192.6:8443 Masq 1 0 0
TCP 172.17.0.1:31868 rr
-> 172.30.192.1:9000 Masq 1 0 0
TCP 172.30.0.1:30000 rr
-> 172.30.192.6:8443 Masq 1 0 0
TCP 172.30.0.1:30443 rr
-> 172.30.192.8:9000 Masq 1 0 0
Cluster
Managements
Management Tools (1)
● Kubernetes Dashboard
○ Web 기반 오픈소스 프로젝트
○ 사용자 인증 기능
○ YAML, JSON 파일을 직접 작성해 배포 가능
○ Deployment, ReplicaSet Scale 조절 가능
○ 컨테이너 로그 확인 기능
○ 웹 기반 터미널 기능 제공
Management Tools (2)
● kubectl
○ Command Line Interface 기반
○ 터미널로 접속하여 빠르게 원하는 작업 수행 가능
○ Kubectl Plugin 을 통해 추가적인 기능 제공
● Visual Studio Code: Kubernetes Plugin
○ Kubeconfig 파일을 이용해 로컬 클러스터 관리 가능
○ YAML 파일 템플릿 제공
○ TreeView 를 통해 클러스터 내부 컨테이너 상태 확인 가능
Namespace 관리 정책
● 프로젝트 별로 Namespace 할당
○ 프로젝트와 관계 있는 모든 자원을 하나의 Namespace 안에서 관리
○ 구성원이 Namespace 접근 권한을 공유하여 서비스 배포
○ 예) project-front, project-backend
● 조직 별로 Namespace 할당
○ 팀에서 사용할 수 있는 자원을 Namespace 별로 나눠 관리
○ 팀원은 Namespace 안에 있는 자원에 접근 가능
○ 예) dev-team: default, application, …
Namespace 접근 제어: ServiceAccount
● ServiceAccount 생성
● Role & RoleBinding 을 이용해 ServiceAccount 접근 권한 제어
● Namespace 에 접근할 때 사용할 ServiceAccount
apiVersion: v1
kind: ServiceAccount
metadata:
name: ghost-sa
namespace: ghost
Namespace 접근 제어: Role
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: ghost-role
namespace: ghost
rules:
- apiGroups: ["", "extensions", "apps"]
resources: ["*"]
verbs: ["*"]
- apiGroups: ["batch"]
resources:
- jobs
- cronjobs
verbs: ["*"]
Namespace 접근 제어: RoleBinding
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: ghost-rolebinding
namespace: ghost
subjects:
- kind: ServiceAccount
name: ghost-sa
namespace: ghost
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: ghost-role
Cluster
Enhancements
MetalLB (1)
● On Premise 환경에서 LoadBalancer 지원
● Layer 2 Mode or BGP Mode 선택 가능
● 클러스터 외부에 노출할 IP 대역 지정 필요
● Proxy Mode 로 ipvs 를 사용할 경우 동작 테스트 필요
● MetalLB 설치
$ kubectl apply –f 
https://raw.githubusercontent.com/google/metallb/v0.7.3/manifests/metallb.yaml
MetalLB (2)
● 클러스터 외부에 노출할 IP 대역 설정
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: service-ip-range
protocol: layer2
addresses:
- 10.10.1.100-10.10.1.250
Rook with Ceph (1)
● Open-Source, Cloud-Native Storage for Kubernetes
○ https://rook.io
● Rook 을 이용해 Ceph 클러스터 생성 및 관리
● Pod 를 특정 노드에 종속시키지 않고 배포 가능
● Ceph 클러스터 구축
○ Bluestore 저장소 설정
○ 물리 디스크당 OSD
○ 복제본 개수를 2 이상으로 지정하여 데이터 유실 방지
Rook with Ceph (2)
● Ceph 클러스터 구축
● Dashboard Admin 패스워드 확인
kubectl apply -f cluster/example/kubernetes/ceph/common.yaml
kubectl apply -f cluster/example/kubernetes/ceph/operator.yaml
kubectl apply -f cluster/example/kubernetes/ceph/cluster.yaml
kubectl apply -f cluster/example/kubernetes/ceph/storageclass.yaml
kubectl apply -f cluster/example/kubernetes/ceph/filesystem.yaml
kubectl apply -f cluster/example/kubernetes/ceph/dashboard-external-http.yaml
kubectl apply -f cluster/example/kubernetes/ceph/toolbox.yaml
kubectl get secret –n rook-ceph rook-ceph-dashboard-password 
-o jsonpath="{.data.password}" | base64 -d
CephCluster (1)
● Ceph 클러스터에 사용할 디스크, 데이터 저장 공간 지정
apiVersion: ceph.rook.io/v1
kind: CephCluster
metadata:
name: rook-ceph
namespace: rook-ceph
spec:
cephVersion:
image: ceph/ceph:v14.2.1-20190430
dataDirHostPath: /var/lib/rook
dashboard:
enabled: true
port: 7000
ssl: false
CephCluster (2)
storage:
config:
storeType: "bluestore"
databaseSizeMB: "512"
journalSizeMB: "512"
osdsPerDevice: "1"
nodes:
- name: "k8s-1"
devices:
- name: "sdd"
- name: "k8s-2"
devices:
- name: "sdd"
- name: "k8s-3"
devices:
- name: "sdd"
CephBlockPool
● 데이터 유실을 막기 위해 Host 단위로 복제본 유지
apiVersion: ceph.rook.io/v1
kind: CephBlockPool
metadata:
name: replicapool
namespace: rook-ceph
spec:
replicated:
size: 2
failureDomain: host
StorageClass
● PersistentVolumeClaim 에서 사용할 StorageClass 생성
● rook-ceph-block 을 지정하면, 앞에서 생성한 replicapool 사용
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: rook-ceph-block
provisioner: ceph.rook.io/block
parameters:
blockPool: replicapool
clusterNamespace: rook-ceph
fstype: xfs
CephFilesystem
● Pod 들이 같이 공유해서 사용하는 Filesystem 저장소 생성
apiVersion: ceph.rook.io/v1
kind: CephFilesystem
metadata:
name: shared-fs
namespace: rook-ceph
spec:
metadataPool:
replicated:
size: 2
dataPools:
- failureDomain: host
replicated:
size: 2
metadataServer:
activeCount: 1
activeStandby: true
Ceph Dashboard
Ceph Dashboard: Hosts
Ceph Dashboard: Pools
Ceph Tools
● Ceph 클러스터를 관리할 때 필요한 프로그램 모음
$ kubectl exec -it -n rook-ceph rook-ceph-tools-b8c679f95-pqnnz bash
[root@k8s-3 /]# ceph status
cluster:
id: 04a15e19-c6c3-471d-b552-f8ad39208b51
health: HEALTH_OK
services:
mon: 2 daemons, quorum a,b (age 69m)
mgr: a(active, since 9m)
mds: shared-fs:1 {0=shared-fs-b=up:active} 1 up:standby-replay
osd: 3 osds: 3 up (since 69m), 3 in (since 2d)
data:
pools: 3 pools, 300 pgs
objects: 116 objects, 271 MiB
usage: 3.5 GiB used, 23 GiB / 27 GiB avail
pgs: 300 active+clean
io:
client: 851 B/s rd, 1 op/s rd, 0 op/s wr
Application
Deployment
Pod Quality of Service (1)
● Kubernetes 노드에서 필요한 메모리 자원이 부족할 경우 Pod 제거
○ BestEffort Pod, Burstable Pod 순으로 삭제
● Guaranteed
○ Pod 안에 있는 모든 컨테이너가 CPU, Memory 자원 Limit & Requests 지정
○ CPU, Memory 항목별로 Limit 과 Requests 값이 동일
○ Memory Limit 제한을 넘기 전에는 강제로 종료되지 않음을 보장
Pod Quality of Service (2)
● Burstable
○ Pod 안에 있는 하나 이상의 컨테이너가 CPU 혹은 Memory 자원 Requests 를 가짐
○ BestEffort Pod 가 하나도 없고, Requests 이상의 자원을 사용할 경우 제거 가능
● BestEffort
○ Pod 안에 있는 어떤 컨테이너도 Limit 혹은 Requests 를 가지지 않음
○ Memory 자원이 부족할 경우 먼저 제거되는 Pod
HostPath vs. Local Volume
● HostPath
○ 로컬 디스크를 컨테이너에서 사용할 수 있도록 연결
○ 노드에 장착되어 있는 디스크를 직접 사용하기 때문에 높은 성능 보장
○ 컨테이너가 다른 노드로 옮겨갈 경우에 데이터 유실 가능성
● Local Volume (1.14.x 이상)
○ 로컬 디스크를 컨테이너에 연결해주는 것은 HostPath 와 동일
○ Pod 와 연결된 Local Volume 을 인식하여 동일 노드에 배포되도록 보장
Deployment: MySQL (1)
● MySQL 에서 사용할 PersistentVolumeClaim 생성
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
namespace: ghost
spec:
storageClassName: rook-ceph-block
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
Deployment: MySQL (2)
● Container 항목에 앞에서 생성한 PersistentVolumeClaim 지정
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
containers:
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pvc
Deployment: Ghost (1)
● Ghost 에서 사용할 PersistentVolumeClaim 생성
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ghost-pvc
namespace: ghost
spec:
storageClassName: rook-ceph-block
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Deployment: Ghost (2)
● Container 항목에 앞에서 생성한 PersistentVolumeClaim 지정
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
containers:
volumeMounts:
- name: ghost-persistent-storage
mountPath: /var/lib/ghost/content
volumes:
- name: ghost-persistent-storage
persistentVolumeClaim:
claimName: ghost-pvc
Cluster
Monitoring
Prometheus
● Prometheus 를 설치해 클러스터 Metric 데이터 수집
● Helm 을 이용해 설치 가능
● Prometheus 와 Alertmanager 에서 사용할 Persistent Volume 필요
○ HostPath 혹은 Local Volume 사용 가능
○ 네트워크 대역폭이 충분하다면 Ceph 저장소를 연결하는 것도 가능
Grafana (1)
● Prometheus 에서 수집한 데이터를 다양한 Dashboard 로 표현
○ Kubernetes 클러스터를 보여주는 많은 Dashboard 가 이미 존재
■ 클러스터 전체적인 Metric 을 보여주는 Dashboard
■ Pod 상태를 보여주는 Dashboard
■ 노드 별 상태를 보여주는 Dashboard
● 내부 데이터를 저장하는데 사용할 Persistent Volume 필요
○ HostPath 혹은 Local Volume 사용 가능
○ Metric 데이터를 직접 저장하지 않기 때문에 Ceph 저장소도 고려해 볼만함
Grafana (2)
Filebeat
● DaemonSet 형태로 모든 노드에 배포
● 다양한 로그 수집
○ Kubernetes 노드에 쌓이는 syslog, auth 관련
○ 컨테이너에서 기록하는 로그
● 수집한 로그를 Elasticsearch 로 전달
○ 전달 전에 로그 안에서 불필요한 내용 제거
■ INFO, DEBUG 로그 제외
■ 테스트 목적을 가진 Namespace 에서 생성한 로그 등
Metricbeat (1)
● DaemonSet 형태로 모든 노드에 배포
● 시스템, 컨테이너, Kubernetes 상태 Metric 정보 수집
○ CPU, Load, Memory, Network, Process
○ Node, Pod, Container, Volume
● Kibana Infrastructure 기능을 통해 컨테이너 세부 Metric 정보 확인 가능
Metricbeat (2)
● Kubernetes Metric 수집 설정
kubernetes.yml: |-
- module: kubernetes
metricsets:
- node
- system
- pod
- container
- volume
period: 10s
host: ${NODE_NAME}
hosts: ["localhost:10255"]
Metricbeat (3)
● Kubelet 정보 수집을 위해 Read-Only-Port 열기 (기본값: 비활성화)
● /var/lib/kubelet/kubeadm-flags.env 파일에 옵션 추가
● Kubelet 재시작
KUBELET_KUBEADM_ARGS=--cgroup-driver=cgroupfs --network-plugin=cni --pod-
infra-container-image=k8s.gcr.io/pause:3.1 --read-only-port 10255
sudo systemctl restart kubelet
Elasticsearch & Kibana
● 수집한 로그를 Kibana 에서 확인
● 원하는 키워드로 검색 가능
● Elasticsearch 를 배포할 때 Persistent Volume 사용
○ HostPath 혹은 Local Volume 사용 가능
○ 외부 Elasticsearch 클러스터도 괜찮은 구성
● Kibana Log 기능을 통해 원본 로그 확인 가능
Kibana: Discover
Kibana: Log
Infrastructure: Kubernetes Pods
Infrastructure: Docker Containers
NexClipper
● Open-Source Kubernetes Monitoring Service
○ https://github.com/NexClipper/NexClipper
● NexclipperAgent 를 DaemonSet 형태로 모든 노드에 배포
● Agent 에서 보내주는 데이터 수집
● 클러스터 Host, Container 등에서 Metric 데이터 수집
● Kubernetes Workloads Metric 데이터 수집
● Incident Manager 에 RuleSet 설정을 통해 중요 이벤트 검출 가능
NexClipper: Dashboard
NexClipper: Cluster
NexClipper: Host
NexClipper: Pod
NexClipper: Container
Demo
#1 Kubernetes Cluster
#2 Application
#3 Monitoring
Summary
● Multi Master Nodes 는 클러스터 구축 시에 같이
○ Etcd 클러스터 유효 노드 수 ((n / 2) + 1) 유지하는 것이 매우 중요
● Network Add-on 에서 사용하는 IP 대역과 노드 IP 대역 겹치지 않도록
● 노드 규모가 크다면 Proxy Mode 로 ipvs 고려
○ MetalLB 를 사용한다면 같이 동작하는지 테스트 필요
● Rook & Ceph 를 이용해 동적 Persistent Volume 사용 가능
● 다양한 Monitoring 방법 적용
감사합니다
임찬식
chanshik@gmail.com

More Related Content

What's hot

Kubernetes + Python = ❤ - Cloud Native Prague
Kubernetes + Python = ❤ - Cloud Native PragueKubernetes + Python = ❤ - Cloud Native Prague
Kubernetes + Python = ❤ - Cloud Native PragueHenning Jacobs
 
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...Yevgeniy Brikman
 
Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Yurii Bychenok
 
Using Terraform for AWS as the IaC tool
Using Terraform for AWS as the IaC toolUsing Terraform for AWS as the IaC tool
Using Terraform for AWS as the IaC toolLay How
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container securityVolodymyr Shynkar
 
Azure networking update 201908
Azure networking update 201908 Azure networking update 201908
Azure networking update 201908 Jay Kim
 
EKS Anywhere on vSphere
EKS Anywhere on vSphereEKS Anywhere on vSphere
EKS Anywhere on vSphereMasanori Nara
 
[221] docker orchestration
[221] docker orchestration[221] docker orchestration
[221] docker orchestrationNAVER D2
 
Rspec、あなたならどう書く? 20190626
Rspec、あなたならどう書く?  20190626Rspec、あなたならどう書く?  20190626
Rspec、あなたならどう書く? 20190626Koske Kano
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?OpenStack Korea Community
 
Docker 기반 개발환경 구축 - XE Open seminar #2
Docker 기반 개발환경 구축 - XE Open seminar #2Docker 기반 개발환경 구축 - XE Open seminar #2
Docker 기반 개발환경 구축 - XE Open seminar #2XpressEngine
 
A brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsRamit Surana
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker ComposeAjeet Singh Raina
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for BeginnerShahzad Masud
 
[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3
[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3
[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3Ji-Woong Choi
 
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!Java女子部
 
Kubernetes Security
Kubernetes SecurityKubernetes Security
Kubernetes Securityinovex GmbH
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceAmazon Web Services
 

What's hot (20)

Kubernetes + Python = ❤ - Cloud Native Prague
Kubernetes + Python = ❤ - Cloud Native PragueKubernetes + Python = ❤ - Cloud Native Prague
Kubernetes + Python = ❤ - Cloud Native Prague
 
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
 
Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.Pulumi. Modern Infrastructure as Code.
Pulumi. Modern Infrastructure as Code.
 
Using Terraform for AWS as the IaC tool
Using Terraform for AWS as the IaC toolUsing Terraform for AWS as the IaC tool
Using Terraform for AWS as the IaC tool
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
 
Azure networking update 201908
Azure networking update 201908 Azure networking update 201908
Azure networking update 201908
 
EKS Anywhere on vSphere
EKS Anywhere on vSphereEKS Anywhere on vSphere
EKS Anywhere on vSphere
 
[221] docker orchestration
[221] docker orchestration[221] docker orchestration
[221] docker orchestration
 
Rspec、あなたならどう書く? 20190626
Rspec、あなたならどう書く?  20190626Rspec、あなたならどう書く?  20190626
Rspec、あなたならどう書く? 20190626
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Intro to kubernetes
 
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
[OpenStack Days Korea 2016] Track1 - 카카오는 오픈스택 기반으로 어떻게 5000VM을 운영하고 있을까?
 
Docker 기반 개발환경 구축 - XE Open seminar #2
Docker 기반 개발환경 구축 - XE Open seminar #2Docker 기반 개발환경 구축 - XE Open seminar #2
Docker 기반 개발환경 구축 - XE Open seminar #2
 
A brief study on Kubernetes and its components
A brief study on Kubernetes and its componentsA brief study on Kubernetes and its components
A brief study on Kubernetes and its components
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
 
Kubernetes Security
Kubernetes SecurityKubernetes Security
Kubernetes Security
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3
[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3
[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3
 
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
Spring Bootでチャットツールを作りながらWebの仕組みを理解しよう!
 
Kubernetes Security
Kubernetes SecurityKubernetes Security
Kubernetes Security
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line Interface
 

Similar to Kubernetes on Premise Practical Guide

[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes
[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes
[OpenInfra Days Korea 2018] Day 2 - E5: GPU on KubernetesOpenStack Korea Community
 
resource on openstack
 resource on openstack resource on openstack
resource on openstackjieun kim
 
쿠버네티스 오픈 소스와 클라우드 매니지드 서비스 접점 소개
쿠버네티스 오픈 소스와 클라우드 매니지드 서비스 접점 소개쿠버네티스 오픈 소스와 클라우드 매니지드 서비스 접점 소개
쿠버네티스 오픈 소스와 클라우드 매니지드 서비스 접점 소개Ian Choi
 
제2회 난공불락 오픈소스 인프라 세미나 Kubernetes
제2회 난공불락 오픈소스 인프라 세미나 Kubernetes제2회 난공불락 오픈소스 인프라 세미나 Kubernetes
제2회 난공불락 오픈소스 인프라 세미나 KubernetesTommy Lee
 
[slideshare]k8s.pptx
[slideshare]k8s.pptx[slideshare]k8s.pptx
[slideshare]k8s.pptxssuserb8551e
 
세션3_데보션테크데이_gitopsinfra_v1.1.pdf
세션3_데보션테크데이_gitopsinfra_v1.1.pdf세션3_데보션테크데이_gitopsinfra_v1.1.pdf
세션3_데보션테크데이_gitopsinfra_v1.1.pdfJaesuk Ahn
 
Cloud for Kubernetes : Session1
Cloud for Kubernetes : Session1Cloud for Kubernetes : Session1
Cloud for Kubernetes : Session1WhaTap Labs
 
[OpenInfra Days Korea 2018] K8s workshop: with containers & K8s on OpenStack ...
[OpenInfra Days Korea 2018] K8s workshop: with containers & K8s on OpenStack ...[OpenInfra Days Korea 2018] K8s workshop: with containers & K8s on OpenStack ...
[OpenInfra Days Korea 2018] K8s workshop: with containers & K8s on OpenStack ...OpenStack Korea Community
 
kubernetes from beginner to advanced
kubernetes  from beginner to advancedkubernetes  from beginner to advanced
kubernetes from beginner to advancedOracle Korea
 
kubernetes : From beginner to Advanced
kubernetes : From beginner to Advancedkubernetes : From beginner to Advanced
kubernetes : From beginner to AdvancedInho Kang
 
2017 k8s and OpenStack-Helm
2017 k8s and OpenStack-Helm2017 k8s and OpenStack-Helm
2017 k8s and OpenStack-HelmSK Telecom
 
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXpressEngine
 
Kubernetes on GCP
Kubernetes on GCPKubernetes on GCP
Kubernetes on GCPDaegeun Kim
 
Source To URL Without Dockerfile
Source To URL Without DockerfileSource To URL Without Dockerfile
Source To URL Without DockerfileWon-Chon Jung
 
Toward kubernetes native data center
Toward kubernetes native data centerToward kubernetes native data center
Toward kubernetes native data center어형 이
 
F5 container ingress_service_in_kuernetes_with_calico_cni_by_duck_in_korea
F5 container ingress_service_in_kuernetes_with_calico_cni_by_duck_in_koreaF5 container ingress_service_in_kuernetes_with_calico_cni_by_duck_in_korea
F5 container ingress_service_in_kuernetes_with_calico_cni_by_duck_in_koreaInfraEngineer
 
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기Hyperledger Korea User Group
 

Similar to Kubernetes on Premise Practical Guide (20)

[온라인교육시리즈] NKS에서 Cluster & Pods Autoscaling 적용
[온라인교육시리즈] NKS에서 Cluster & Pods Autoscaling 적용[온라인교육시리즈] NKS에서 Cluster & Pods Autoscaling 적용
[온라인교육시리즈] NKS에서 Cluster & Pods Autoscaling 적용
 
[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes
[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes
[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes
 
resource on openstack
 resource on openstack resource on openstack
resource on openstack
 
Kafka slideshare
Kafka   slideshareKafka   slideshare
Kafka slideshare
 
쿠버네티스 오픈 소스와 클라우드 매니지드 서비스 접점 소개
쿠버네티스 오픈 소스와 클라우드 매니지드 서비스 접점 소개쿠버네티스 오픈 소스와 클라우드 매니지드 서비스 접점 소개
쿠버네티스 오픈 소스와 클라우드 매니지드 서비스 접점 소개
 
K8s in action02
K8s in action02K8s in action02
K8s in action02
 
제2회 난공불락 오픈소스 인프라 세미나 Kubernetes
제2회 난공불락 오픈소스 인프라 세미나 Kubernetes제2회 난공불락 오픈소스 인프라 세미나 Kubernetes
제2회 난공불락 오픈소스 인프라 세미나 Kubernetes
 
[slideshare]k8s.pptx
[slideshare]k8s.pptx[slideshare]k8s.pptx
[slideshare]k8s.pptx
 
세션3_데보션테크데이_gitopsinfra_v1.1.pdf
세션3_데보션테크데이_gitopsinfra_v1.1.pdf세션3_데보션테크데이_gitopsinfra_v1.1.pdf
세션3_데보션테크데이_gitopsinfra_v1.1.pdf
 
Cloud for Kubernetes : Session1
Cloud for Kubernetes : Session1Cloud for Kubernetes : Session1
Cloud for Kubernetes : Session1
 
[OpenInfra Days Korea 2018] K8s workshop: with containers & K8s on OpenStack ...
[OpenInfra Days Korea 2018] K8s workshop: with containers & K8s on OpenStack ...[OpenInfra Days Korea 2018] K8s workshop: with containers & K8s on OpenStack ...
[OpenInfra Days Korea 2018] K8s workshop: with containers & K8s on OpenStack ...
 
kubernetes from beginner to advanced
kubernetes  from beginner to advancedkubernetes  from beginner to advanced
kubernetes from beginner to advanced
 
kubernetes : From beginner to Advanced
kubernetes : From beginner to Advancedkubernetes : From beginner to Advanced
kubernetes : From beginner to Advanced
 
2017 k8s and OpenStack-Helm
2017 k8s and OpenStack-Helm2017 k8s and OpenStack-Helm
2017 k8s and OpenStack-Helm
 
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
 
Kubernetes on GCP
Kubernetes on GCPKubernetes on GCP
Kubernetes on GCP
 
Source To URL Without Dockerfile
Source To URL Without DockerfileSource To URL Without Dockerfile
Source To URL Without Dockerfile
 
Toward kubernetes native data center
Toward kubernetes native data centerToward kubernetes native data center
Toward kubernetes native data center
 
F5 container ingress_service_in_kuernetes_with_calico_cni_by_duck_in_korea
F5 container ingress_service_in_kuernetes_with_calico_cni_by_duck_in_koreaF5 container ingress_service_in_kuernetes_with_calico_cni_by_duck_in_korea
F5 container ingress_service_in_kuernetes_with_calico_cni_by_duck_in_korea
 
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
[2019.04] 쿠버네티스 기반 하이퍼레저 패브릭 네트워크 구축하기
 

More from Chan Shik Lim

FPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpegFPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpegChan Shik Lim
 
Improving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetricsImproving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetricsChan Shik Lim
 
pgday.seoul 2019: TimescaleDB
pgday.seoul 2019: TimescaleDBpgday.seoul 2019: TimescaleDB
pgday.seoul 2019: TimescaleDBChan Shik Lim
 
Kubernetes on Premise
Kubernetes on PremiseKubernetes on Premise
Kubernetes on PremiseChan Shik Lim
 
Hadoop High Availability Summary
Hadoop High Availability SummaryHadoop High Availability Summary
Hadoop High Availability SummaryChan Shik Lim
 
Python Programming: Tuning and Optimization
Python Programming: Tuning and OptimizationPython Programming: Tuning and Optimization
Python Programming: Tuning and OptimizationChan Shik Lim
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data StructureChan Shik Lim
 
Python Programming: Class and Object Oriented Programming
Python Programming: Class and Object Oriented ProgrammingPython Programming: Class and Object Oriented Programming
Python Programming: Class and Object Oriented ProgrammingChan Shik Lim
 
Python Programming: Function
Python Programming: FunctionPython Programming: Function
Python Programming: FunctionChan Shik Lim
 
Python Programming: Type and Object
Python Programming: Type and ObjectPython Programming: Type and Object
Python Programming: Type and ObjectChan Shik Lim
 

More from Chan Shik Lim (10)

FPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpegFPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpeg
 
Improving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetricsImproving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetrics
 
pgday.seoul 2019: TimescaleDB
pgday.seoul 2019: TimescaleDBpgday.seoul 2019: TimescaleDB
pgday.seoul 2019: TimescaleDB
 
Kubernetes on Premise
Kubernetes on PremiseKubernetes on Premise
Kubernetes on Premise
 
Hadoop High Availability Summary
Hadoop High Availability SummaryHadoop High Availability Summary
Hadoop High Availability Summary
 
Python Programming: Tuning and Optimization
Python Programming: Tuning and OptimizationPython Programming: Tuning and Optimization
Python Programming: Tuning and Optimization
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
 
Python Programming: Class and Object Oriented Programming
Python Programming: Class and Object Oriented ProgrammingPython Programming: Class and Object Oriented Programming
Python Programming: Class and Object Oriented Programming
 
Python Programming: Function
Python Programming: FunctionPython Programming: Function
Python Programming: Function
 
Python Programming: Type and Object
Python Programming: Type and ObjectPython Programming: Type and Object
Python Programming: Type and Object
 

Kubernetes on Premise Practical Guide

  • 2. Kubernetes로 인프라를 옮기며 경험한 내용을 바탕으로 정리한, 클러스터 구축 실용 가이드를 공유합니다
  • 4. Multi Master Nodes (1) ● kubeadm 명령을 이용해 Multi Master Nodes 클러스터 구축 가능 ● 노드 여유가 있다면 클러스터를 생성할 때 Multi Master 구성 적용 ● Kubernetes 1.14.x 이상 ○ --experimental-upload-certs 옵션을 이용해 인증서 공유 ● Kubernetes 1.13.x 이하 ○ Master Node 생성 후에 인증서를 다른 Master 노드로 복사하는 작업 필요
  • 5. Multi Master Nodes (2) ● kubeadm-config.yaml ● controlPlaneEndpoint 항목에 내부에서 사용하는 LoadBalancer IP 지정 ○ HAProxy 등을 이용한 LoadBalancer IP ○ Keepalived, Heartbeat 등을 이용한 Failover 구성 적용 가능 apiVersion: kubeadm.k8s.io/v1beta1 kind: ClusterConfiguration kubernetesVersion: 1.14.1 controlPlaneEndpoint: "NODEIP:6443"
  • 6. Master Node 추가: 1.14.x 이상 ● Master Node 생성 ● Master Node 추가 $ sudo kubeadm init --config kubeadm-config.yaml --experimental-upload-certs $ sudo kubeadm join NODEIP:6443 --token 9vr73a.a8uxyaju799qwdjv --discovery-token-ca-cert-hash sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866 --experimental-control-plane --certificate-key f8902e114ef118304e561c3ecd4d0b543adc226b7a07f675f56564185ffe0c07
  • 7. Master Node 추가: 1.13.x 이하 (1) ● Master Node 생성 ● 복사할 인증서 목록 $ sudo kubeadm init --config kubeadm-config.yaml /etc/kubernetes/pki/ca.crt /etc/kubernetes/pki/front-proxy-ca.crt /etc/kubernetes/pki/ca.key /etc/kubernetes/pki/front-proxy-ca.key /etc/kubernetes/pki/sa.key /etc/kubernetes/pki/etcd/ca.crt /etc/kubernetes/pki/sa.pub /etc/kubernetes/pki/etcd/ca.key
  • 8. Master Node 추가: 1.13.x 이하 (2) ● Master Node 추가 ● 구성 확인 $ sudo kubeadm join NODEIP:6443 --token 9vr73a.a8uxyaju799qwdjv --discovery-token-ca-cert-hash sha256:7c2e69131a36ae2a042a339b33381c6d0d43887e2de83720eff5359e26aec866 --experimental-control-plane $ kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-1 Ready master 3d v1.14.1 k8s-2 Ready master 3d v1.14.1 k8s-3 Ready master 3d v1.14.1
  • 9. ETCD Cluster (1) ● Etcd 클러스터 구성 ○ External Etcd 구성은 노드 여유가 있고 관리할 여력이 있다면 고려 ○ Etcd 클러스터 최소 가용 노드 수를 유지하는 것이 매우 중요 ○ (n / 2) + 1 노드 수를 유지하지 못할 경우에는 클러스터 운영에 영향 Cluster Size Majority Failure Tolerance 3 2 1 4 3 1 5 3 2 6 4 2
  • 10. ETCD Cluster (2) ● Etcd client 설치 ● Etcd member list 확인 $ sudo ETCDCTL_API=3 etcdctl --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/peer.crt --key /etc/kubernetes/pki/etcd/peer.key member list 18b80ec995adf496, started, k8s-3, https://10.10.1.4:2380, https://10.10.1.4:2379 2ee7a00cdb8ac627, started, k8s-1, https://10.10.1.2:2380, https://10.10.1.2:2379 bcd6b446c02976ab, started, k8s-2, https://10.10.1.3:2380, https://10.10.1.3:2379 $ sudo apt install etcd-client
  • 11. Pod Network Add-on ● Network Add-on IP 대역과 노드에서 사용하는 대역이 겹칠 경우 문제 ○ 예) Weave Net 은 기본값으로 10.32.0.0/12 사용 ○ 노드에서 10.0.0.0/8 대역을 사용할 경우 ○ 10.32.x.y IP 주소에 대한 라우팅을 결정할 수 없음 ● 사용하는 Network Add-on 에 IP 대역을 변경할 수 있는 옵션 이용 ○ 예) 노드에서 10.0.0.0/8 대역 사용 중 ○ Weave Net 이 기본값으로 사용하는 10.32.0.0/12 는 사용 불가 ○ IPALLOC_RANGE 옵션을 이용해 172.30.0.0/16 대역으로 변경
  • 12. Proxy Mode (1) ● iptables ○ Kubeadm 을 이용해 클러스터를 구축할 경우 기본값 ○ iptables 를 이용해 적절한 성능 보장 ○ 노드가 늘어나고 Pod 증가에 따라 성능 저하 우려 ● ipvs ○ Kubeadm 을 이용해 클러스터를 구축할 때 kubeproxy 옵션을 통해 지정 ○ 대규모 노드에서도 성능 보장 ○ MetalLB 와 동시에 사용할 때 문제 발생 가능성 존재 ■ 적용 전 테스트 필요
  • 13. Proxy Mode (2) ● ipvsadm 명령을 이용해 제대로 설정되었는지 확인 가능 $ sudo ipvsadm –ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 172.17.0.1:30000 rr -> 172.30.192.6:8443 Masq 1 0 0 TCP 172.17.0.1:31868 rr -> 172.30.192.1:9000 Masq 1 0 0 TCP 172.30.0.1:30000 rr -> 172.30.192.6:8443 Masq 1 0 0 TCP 172.30.0.1:30443 rr -> 172.30.192.8:9000 Masq 1 0 0
  • 15. Management Tools (1) ● Kubernetes Dashboard ○ Web 기반 오픈소스 프로젝트 ○ 사용자 인증 기능 ○ YAML, JSON 파일을 직접 작성해 배포 가능 ○ Deployment, ReplicaSet Scale 조절 가능 ○ 컨테이너 로그 확인 기능 ○ 웹 기반 터미널 기능 제공
  • 16. Management Tools (2) ● kubectl ○ Command Line Interface 기반 ○ 터미널로 접속하여 빠르게 원하는 작업 수행 가능 ○ Kubectl Plugin 을 통해 추가적인 기능 제공 ● Visual Studio Code: Kubernetes Plugin ○ Kubeconfig 파일을 이용해 로컬 클러스터 관리 가능 ○ YAML 파일 템플릿 제공 ○ TreeView 를 통해 클러스터 내부 컨테이너 상태 확인 가능
  • 17. Namespace 관리 정책 ● 프로젝트 별로 Namespace 할당 ○ 프로젝트와 관계 있는 모든 자원을 하나의 Namespace 안에서 관리 ○ 구성원이 Namespace 접근 권한을 공유하여 서비스 배포 ○ 예) project-front, project-backend ● 조직 별로 Namespace 할당 ○ 팀에서 사용할 수 있는 자원을 Namespace 별로 나눠 관리 ○ 팀원은 Namespace 안에 있는 자원에 접근 가능 ○ 예) dev-team: default, application, …
  • 18. Namespace 접근 제어: ServiceAccount ● ServiceAccount 생성 ● Role & RoleBinding 을 이용해 ServiceAccount 접근 권한 제어 ● Namespace 에 접근할 때 사용할 ServiceAccount apiVersion: v1 kind: ServiceAccount metadata: name: ghost-sa namespace: ghost
  • 19. Namespace 접근 제어: Role kind: Role apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: ghost-role namespace: ghost rules: - apiGroups: ["", "extensions", "apps"] resources: ["*"] verbs: ["*"] - apiGroups: ["batch"] resources: - jobs - cronjobs verbs: ["*"]
  • 20. Namespace 접근 제어: RoleBinding kind: RoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 metadata: name: ghost-rolebinding namespace: ghost subjects: - kind: ServiceAccount name: ghost-sa namespace: ghost roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: ghost-role
  • 22. MetalLB (1) ● On Premise 환경에서 LoadBalancer 지원 ● Layer 2 Mode or BGP Mode 선택 가능 ● 클러스터 외부에 노출할 IP 대역 지정 필요 ● Proxy Mode 로 ipvs 를 사용할 경우 동작 테스트 필요 ● MetalLB 설치 $ kubectl apply –f https://raw.githubusercontent.com/google/metallb/v0.7.3/manifests/metallb.yaml
  • 23. MetalLB (2) ● 클러스터 외부에 노출할 IP 대역 설정 apiVersion: v1 kind: ConfigMap metadata: namespace: metallb-system name: config data: config: | address-pools: - name: service-ip-range protocol: layer2 addresses: - 10.10.1.100-10.10.1.250
  • 24. Rook with Ceph (1) ● Open-Source, Cloud-Native Storage for Kubernetes ○ https://rook.io ● Rook 을 이용해 Ceph 클러스터 생성 및 관리 ● Pod 를 특정 노드에 종속시키지 않고 배포 가능 ● Ceph 클러스터 구축 ○ Bluestore 저장소 설정 ○ 물리 디스크당 OSD ○ 복제본 개수를 2 이상으로 지정하여 데이터 유실 방지
  • 25. Rook with Ceph (2) ● Ceph 클러스터 구축 ● Dashboard Admin 패스워드 확인 kubectl apply -f cluster/example/kubernetes/ceph/common.yaml kubectl apply -f cluster/example/kubernetes/ceph/operator.yaml kubectl apply -f cluster/example/kubernetes/ceph/cluster.yaml kubectl apply -f cluster/example/kubernetes/ceph/storageclass.yaml kubectl apply -f cluster/example/kubernetes/ceph/filesystem.yaml kubectl apply -f cluster/example/kubernetes/ceph/dashboard-external-http.yaml kubectl apply -f cluster/example/kubernetes/ceph/toolbox.yaml kubectl get secret –n rook-ceph rook-ceph-dashboard-password -o jsonpath="{.data.password}" | base64 -d
  • 26. CephCluster (1) ● Ceph 클러스터에 사용할 디스크, 데이터 저장 공간 지정 apiVersion: ceph.rook.io/v1 kind: CephCluster metadata: name: rook-ceph namespace: rook-ceph spec: cephVersion: image: ceph/ceph:v14.2.1-20190430 dataDirHostPath: /var/lib/rook dashboard: enabled: true port: 7000 ssl: false
  • 27. CephCluster (2) storage: config: storeType: "bluestore" databaseSizeMB: "512" journalSizeMB: "512" osdsPerDevice: "1" nodes: - name: "k8s-1" devices: - name: "sdd" - name: "k8s-2" devices: - name: "sdd" - name: "k8s-3" devices: - name: "sdd"
  • 28. CephBlockPool ● 데이터 유실을 막기 위해 Host 단위로 복제본 유지 apiVersion: ceph.rook.io/v1 kind: CephBlockPool metadata: name: replicapool namespace: rook-ceph spec: replicated: size: 2 failureDomain: host
  • 29. StorageClass ● PersistentVolumeClaim 에서 사용할 StorageClass 생성 ● rook-ceph-block 을 지정하면, 앞에서 생성한 replicapool 사용 apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: rook-ceph-block provisioner: ceph.rook.io/block parameters: blockPool: replicapool clusterNamespace: rook-ceph fstype: xfs
  • 30. CephFilesystem ● Pod 들이 같이 공유해서 사용하는 Filesystem 저장소 생성 apiVersion: ceph.rook.io/v1 kind: CephFilesystem metadata: name: shared-fs namespace: rook-ceph spec: metadataPool: replicated: size: 2 dataPools: - failureDomain: host replicated: size: 2 metadataServer: activeCount: 1 activeStandby: true
  • 34. Ceph Tools ● Ceph 클러스터를 관리할 때 필요한 프로그램 모음 $ kubectl exec -it -n rook-ceph rook-ceph-tools-b8c679f95-pqnnz bash [root@k8s-3 /]# ceph status cluster: id: 04a15e19-c6c3-471d-b552-f8ad39208b51 health: HEALTH_OK services: mon: 2 daemons, quorum a,b (age 69m) mgr: a(active, since 9m) mds: shared-fs:1 {0=shared-fs-b=up:active} 1 up:standby-replay osd: 3 osds: 3 up (since 69m), 3 in (since 2d) data: pools: 3 pools, 300 pgs objects: 116 objects, 271 MiB usage: 3.5 GiB used, 23 GiB / 27 GiB avail pgs: 300 active+clean io: client: 851 B/s rd, 1 op/s rd, 0 op/s wr
  • 36. Pod Quality of Service (1) ● Kubernetes 노드에서 필요한 메모리 자원이 부족할 경우 Pod 제거 ○ BestEffort Pod, Burstable Pod 순으로 삭제 ● Guaranteed ○ Pod 안에 있는 모든 컨테이너가 CPU, Memory 자원 Limit & Requests 지정 ○ CPU, Memory 항목별로 Limit 과 Requests 값이 동일 ○ Memory Limit 제한을 넘기 전에는 강제로 종료되지 않음을 보장
  • 37. Pod Quality of Service (2) ● Burstable ○ Pod 안에 있는 하나 이상의 컨테이너가 CPU 혹은 Memory 자원 Requests 를 가짐 ○ BestEffort Pod 가 하나도 없고, Requests 이상의 자원을 사용할 경우 제거 가능 ● BestEffort ○ Pod 안에 있는 어떤 컨테이너도 Limit 혹은 Requests 를 가지지 않음 ○ Memory 자원이 부족할 경우 먼저 제거되는 Pod
  • 38. HostPath vs. Local Volume ● HostPath ○ 로컬 디스크를 컨테이너에서 사용할 수 있도록 연결 ○ 노드에 장착되어 있는 디스크를 직접 사용하기 때문에 높은 성능 보장 ○ 컨테이너가 다른 노드로 옮겨갈 경우에 데이터 유실 가능성 ● Local Volume (1.14.x 이상) ○ 로컬 디스크를 컨테이너에 연결해주는 것은 HostPath 와 동일 ○ Pod 와 연결된 Local Volume 을 인식하여 동일 노드에 배포되도록 보장
  • 39. Deployment: MySQL (1) ● MySQL 에서 사용할 PersistentVolumeClaim 생성 apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql-pvc namespace: ghost spec: storageClassName: rook-ceph-block accessModes: - ReadWriteOnce resources: requests: storage: 2Gi
  • 40. Deployment: MySQL (2) ● Container 항목에 앞에서 생성한 PersistentVolumeClaim 지정 apiVersion: apps/v1 kind: Deployment spec: template: spec: containers: volumeMounts: - name: mysql-persistent-storage mountPath: /var/lib/mysql volumes: - name: mysql-persistent-storage persistentVolumeClaim: claimName: mysql-pvc
  • 41. Deployment: Ghost (1) ● Ghost 에서 사용할 PersistentVolumeClaim 생성 apiVersion: v1 kind: PersistentVolumeClaim metadata: name: ghost-pvc namespace: ghost spec: storageClassName: rook-ceph-block accessModes: - ReadWriteOnce resources: requests: storage: 1Gi
  • 42. Deployment: Ghost (2) ● Container 항목에 앞에서 생성한 PersistentVolumeClaim 지정 apiVersion: apps/v1 kind: Deployment spec: template: spec: containers: volumeMounts: - name: ghost-persistent-storage mountPath: /var/lib/ghost/content volumes: - name: ghost-persistent-storage persistentVolumeClaim: claimName: ghost-pvc
  • 44. Prometheus ● Prometheus 를 설치해 클러스터 Metric 데이터 수집 ● Helm 을 이용해 설치 가능 ● Prometheus 와 Alertmanager 에서 사용할 Persistent Volume 필요 ○ HostPath 혹은 Local Volume 사용 가능 ○ 네트워크 대역폭이 충분하다면 Ceph 저장소를 연결하는 것도 가능
  • 45. Grafana (1) ● Prometheus 에서 수집한 데이터를 다양한 Dashboard 로 표현 ○ Kubernetes 클러스터를 보여주는 많은 Dashboard 가 이미 존재 ■ 클러스터 전체적인 Metric 을 보여주는 Dashboard ■ Pod 상태를 보여주는 Dashboard ■ 노드 별 상태를 보여주는 Dashboard ● 내부 데이터를 저장하는데 사용할 Persistent Volume 필요 ○ HostPath 혹은 Local Volume 사용 가능 ○ Metric 데이터를 직접 저장하지 않기 때문에 Ceph 저장소도 고려해 볼만함
  • 47. Filebeat ● DaemonSet 형태로 모든 노드에 배포 ● 다양한 로그 수집 ○ Kubernetes 노드에 쌓이는 syslog, auth 관련 ○ 컨테이너에서 기록하는 로그 ● 수집한 로그를 Elasticsearch 로 전달 ○ 전달 전에 로그 안에서 불필요한 내용 제거 ■ INFO, DEBUG 로그 제외 ■ 테스트 목적을 가진 Namespace 에서 생성한 로그 등
  • 48. Metricbeat (1) ● DaemonSet 형태로 모든 노드에 배포 ● 시스템, 컨테이너, Kubernetes 상태 Metric 정보 수집 ○ CPU, Load, Memory, Network, Process ○ Node, Pod, Container, Volume ● Kibana Infrastructure 기능을 통해 컨테이너 세부 Metric 정보 확인 가능
  • 49. Metricbeat (2) ● Kubernetes Metric 수집 설정 kubernetes.yml: |- - module: kubernetes metricsets: - node - system - pod - container - volume period: 10s host: ${NODE_NAME} hosts: ["localhost:10255"]
  • 50. Metricbeat (3) ● Kubelet 정보 수집을 위해 Read-Only-Port 열기 (기본값: 비활성화) ● /var/lib/kubelet/kubeadm-flags.env 파일에 옵션 추가 ● Kubelet 재시작 KUBELET_KUBEADM_ARGS=--cgroup-driver=cgroupfs --network-plugin=cni --pod- infra-container-image=k8s.gcr.io/pause:3.1 --read-only-port 10255 sudo systemctl restart kubelet
  • 51. Elasticsearch & Kibana ● 수집한 로그를 Kibana 에서 확인 ● 원하는 키워드로 검색 가능 ● Elasticsearch 를 배포할 때 Persistent Volume 사용 ○ HostPath 혹은 Local Volume 사용 가능 ○ 외부 Elasticsearch 클러스터도 괜찮은 구성 ● Kibana Log 기능을 통해 원본 로그 확인 가능
  • 56. NexClipper ● Open-Source Kubernetes Monitoring Service ○ https://github.com/NexClipper/NexClipper ● NexclipperAgent 를 DaemonSet 형태로 모든 노드에 배포 ● Agent 에서 보내주는 데이터 수집 ● 클러스터 Host, Container 등에서 Metric 데이터 수집 ● Kubernetes Workloads Metric 데이터 수집 ● Incident Manager 에 RuleSet 설정을 통해 중요 이벤트 검출 가능
  • 62. Demo #1 Kubernetes Cluster #2 Application #3 Monitoring
  • 63. Summary ● Multi Master Nodes 는 클러스터 구축 시에 같이 ○ Etcd 클러스터 유효 노드 수 ((n / 2) + 1) 유지하는 것이 매우 중요 ● Network Add-on 에서 사용하는 IP 대역과 노드 IP 대역 겹치지 않도록 ● 노드 규모가 크다면 Proxy Mode 로 ipvs 고려 ○ MetalLB 를 사용한다면 같이 동작하는지 테스트 필요 ● Rook & Ceph 를 이용해 동적 Persistent Volume 사용 가능 ● 다양한 Monitoring 방법 적용