BookStudyWithChimaek / 2023-Season-1

2023 북스터디 시즌1 (2023-08-17 ~ 2023-09-21)
2 stars 1 forks source link

Kubernetes Best Practices #1

Open bbb-86-ko opened 1 year ago

bbb-86-ko commented 1 year ago

Kubernetes Best Practices

1 주차

2 주차

3 주차

4 주차

5 주차

6 주차

bob-bbb commented 12 months ago
스크린샷 2023-09-05 오후 8 53 26

chapter 1 기본 서비스 설치

패스

bob-bbb commented 12 months ago

chapter 2 개발자 워크플로

개발 환경 설정 모범사례

bob-bbb commented 12 months ago

chapter 3 모니터링과 로깅

모니터링 기술

Blackbox Monitoring

Whitebox Monitoring

분산 시스템 모니터링 패턴

USE Pattern

RED Pattern

Four golden signals

Kubernetes Metric

Metic 수집

스크린샷 2023-08-28 오후 4 06 11

Kubernetes Log

Metic을 수집해야할 Component Log

모범사례

모니터링 모범 사례

로깅 모범 사례

알림 모범 사례

bob-bbb commented 12 months ago

chapter 4 설정, 시크릿, RBAC

Configmap, Secret API 모범사례

Secret 모범사례

RBAC 모범사례

RBAC

모범사례

bob-bbb commented 12 months ago

chapter 5 지속적 통합, 테스트, 배포

Ingress 배포

Canary

스크린샷 2023-08-28 오후 5 27 49

Rolling Update

스크린샷 2023-08-28 오후 5 21 50

Blue Green

스크린샷 2023-08-28 오후 5 24 19

Configuration Drift (설정 편차(?))

CI/CD 모범사례

bob-bbb commented 12 months ago

chapter 6 버전, 릴리스, 롤아웃

버전

릴리스

롤아웃

6.5 버전, 릴리스, 롤아웃 모범사례

bob-bbb commented 11 months ago

chapter 7 글로벌 애플리케이션 분산과 스테이지

이미지 분산

배포 파라미터화

글로벌 트래픽 로드벨런서

사전 롤아웃 검증

Canary Region

Region 타입 식별

글로벌 롤아웃 구축

글로벌 롤아웃 모범 사례

bob-bbb commented 11 months ago

chapter 8 리소스 관리

Kubernetes Scheduler

Podaffinity, PodAntiaffinity

NodeSelector

Node Taint, Toleration

Node Taint

Taints:gpu=true:nodSchedule

Pod 명세 1 : 스케쥴링됨

tolerations:
- key: "gpu"
   operator: "Equal"
   value: "true"
   affect: "noSchedule"

Pod 명세 2 : 스케쥴링되지 않음

tolerations:
- key: "gpu"
   operator: "Equal"
   value: "true"
   affect: "noSchedule"

Pod Resource 관리

Pod Quality of Service Classes(QoS)

스크린샷 2023-09-05 오후 6 47 42

PodDisruptionBudget

Namespace를 사용한 Resource 관리

Resource Quarter

apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: ResourceQuota
  metadata:
    name: pods-high
  spec:
    hard:
      cpu: "1000"
      memory: 200Gi
      pods: "10"
    scopeSelector:
      matchExpressions:
      - operator : In
        scopeName: PriorityClass
        values: ["high"]

LimitRange

apiVersion: v1
kind: LimitRange
metadata:
  name: cpu-min-max-demo-lr
spec:
  limits:
  - max:
      cpu: "800m"
    min:
      cpu: "200m"
    type: Container

Cluster Autoscaling

스크린샷 2023-09-05 오후 7 24 06

Application Autoscaling

스크린샷 2023-09-05 오후 7 24 00

HPA

VPA

Resource 관리 모범 사례

GKE에서 비용에 최적화된 Kubernetes 애플리케이션을 실행하기 위한 권장사항

https://cloud.google.com/architecture/best-practices-for-running-cost-effective-kubernetes-applications-on-gke?hl=ko#cluster_autoscaler

bob-bbb commented 11 months ago

chapter 9 네트워킹, 네트워크 보안, 서비스 메시

동일 Pod Container ↔ Container

스크린샷 2023-09-19 오후 4 42 48

Pod ↔ Pod

스크린샷 2023-09-19 오후 4 42 59

Service ↔ Pod

스크린샷 2023-09-19 오후 4 46 45

9.2 네트워크 플러그인

9.2.2 Kubenet 모범 사례

9.2.4 CNI 플러그인 모범 사례

9.3 Kubernetes Service

9.3.1 Service Type : ClusterIP

스크린샷 2023-09-19 오후 5 11 14

9.3.2 Service Type : Node Port

스크린샷 2023-09-19 오후 5 11 48
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app.kubernetes.io/name: MyApp
  ports:
      # 기본적으로 그리고 편의상 `targetPort` 는 `port` 필드와 동일한 값으로 설정된다.
    - port: 80
      targetPort: 80
      # 선택적 필드
      # 기본적으로 그리고 편의상 쿠버네티스 컨트롤 플레인은 포트 범위에서 할당한다(기본값: 30000-32767)
      nodePort: 30007

9.3.3 Service Type : ExternalName

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: prod
spec:
  type: ExternalName
  externalName: my.database.example.com

9.3.4 Service Type : LoadBalancer

스크린샷 2023-09-19 오후 5 12 12
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
    selector:
      app.kubernetes.io/name: MyApp
    ports:
      - protocol: TCP
         port: 80
         targetPort: 9376
      clusterIP: 10.0.171.239
      type: LoadBalancer
status:
  loadBalancer:
    ingress:
    - ip: 192.0.2.127

9.3.5 인그레스와 인그레스 컨트롤러

스크린샷 2023-09-19 오후 5 39 18

9.3.6 서비스와 인그레스 컨트롤러 모범사례

9.4 네트워크 보안 정책

9.4.1 네트워크 정책 모범 사례

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-all
spec:
  podSelector: {}
    policyTypes:
    - Ingress
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: internet-acccess
spec:
  podSelector:
        matchLabels:
            allow-internet: "true"
    policyTypes:
    - Ingress
    ingress:
    - {}

9.5 서비스 메시

서비스 메시 기능

Kubernetes에서..

9.5.1 서비스 메시 모범 사례