Posts Kubernetes 2
Post
Cancel

Kubernetes 2

Kubernetes 2


๐Ÿ’ฟ Liveness, Readiness, Startup Probes

Liveness Probes

  • ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์‚ด์•„์žˆ๋Š”์ง€ ํŒ๋‹จํ•˜๊ณ  ๋‹ค์‹œ ์‹œ์ž‘ํ•˜๋Š” ๊ธฐ๋Šฅ
  • ์ปจํ…Œ์ด๋„ˆ์˜ ์ƒํƒœ๋ฅผ ์Šค์Šค๋กœ ํŒ๋‹จํ•˜์—ฌ ๊ต์ฐฉ ์ƒํƒœ์— ๋น ์ง„ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์žฌ์‹œ์ž‘
  • ๋ฒ„๊ทธ๊ฐ€ ์ƒ๊ฒจ๋„ ๋†’์€ ๊ฐ€์šฉ์„ฑ์„ ๋ณด์ž„

Readiness Probes

  • ํฌ๋“œ๊ฐ€ ์ค€๋น„๋œ ์ƒํƒœ์— ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ์ •์ƒ ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ๊ธฐ๋Šฅ
  • ํฌ๋“œ๊ฐ€ ์ ์ ˆํ•˜๊ฒŒ ์ค€๋น„๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ ๋กœ๋“œ๋ฐธ๋Ÿฐ์‹ฑ์„ ํ•˜์ง€ ์•Š์Œ

Startup Probes

  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹œ์ž‘ ์‹œ๊ธฐ๋ฅผ ํ™•์ธํ•˜์—ฌ ๊ฐ€์šฉ์„ฑ์„ ๋†’์ด๋Š” ๊ธฐ๋Šฅ
  • Liveness์™€ Readiness์˜ ๊ธฐ๋Šฅ์„ ๋น„ํ™œ์„ฑํ™”
  • ์‹œ์ž‘ ์‹œ ๊ณผ๋„ํ•˜๊ฒŒ ์œ„์˜ ๋‘ Probe ๊ฐ€ ๋™์ž‘ํ•˜์—ฌ Pod์ด ์ƒ์„ฑ๋˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์‹œ์ž‘ ์‹œ๊ฐ„์„ ๋ฒŒ์–ด์ฃผ๋Š” ์šฉ๋„
    • ๋ถ€ํŒ…์ด ์˜ค๋ž˜๊ฑธ๋ฆฌ๋Š” ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ํฌํ•จ๋  ์ˆ˜๋„ ์žˆ๊ธฐ ๋•Œ๋ฌธ

๐Ÿ’ฟ Liveness Probe

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-http
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/liveness
    args:
    - /server
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
        - name: Custom-Header
          value: Awesome
      initialDelaySeconds: 3
      periodSeconds: 3
  • Liveness Probe๋Š” ์ปค๋งจ๋“œ ์‹คํ–‰(Http ์š”์ฒญ์ด๋‚˜ ๋ฆฌ๋ˆ…์Šค ๋ช…๋ น)์œผ๋กœ ์ปจํ…Œ์ด๋„ˆ ํ™•์ธ
    • ์œ„์˜ yml์€ Http ์š”์ฒญ์œผ๋กœ ํ™•์ธ
      • 200์ด์ƒ 400๋ฏธ๋งŒ(์ปจํ…Œ์ด๋„ˆ ์œ ์ง€)
      • ์„œ๋ฒ„ ์‘๋‹ต ์ฝ”๋“œ๊ฐ€ ๊ทธ ์™ธ์ผ ๊ฒฝ์šฐ(์ปจํ…Œ์ด๋„ˆ ์žฌ์‹œ์ž‘)

๐Ÿ’ฟ Readiness Probe

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
apiVersion: v1
kind: Pod
metadata:
  name: goproxy
  labels:
    app: goproxy
spec:
  containers:
  - name: goproxy
    image: k8s.gcr.io/goproxy:0.1
    ports:
    - containerPort: 8080
    readinessProbe:
      tcpSocket:
        port: 8080
      initialDelaySeconds: 5
      periodSeconds: 10
    livenessProbe:
      tcpSocket:
        port: 8080
      initialDelaySeconds: 15
      periodSeconds: 20
  • Readiness TCP ์„ค์ •
    • ์ค€๋น„ ํ”„๋กœ๋ธŒ๋Š” 8080ํฌํŠธ ๊ฒ€์‚ฌ
    • 5์ดˆ ํ›„ ๊ฒ€์‚ฌ ์‹œ์ž‘
    • ๊ฒ€์‚ฌ ์ฃผ๊ธฐ 10์ดˆ
      • ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘ํ•ด๋„ ๋œ๋‹ค
  • Liveness TCP ์„ค์ •
    • ํ™œ์„ฑํ™” ํ”„๋กœ๋ธŒ๋Š” 8080 ํฌํŠธ ๊ฒ€์‚ฌ
    • 14์ดˆ ํ›„ ๊ฒ€์‚ฌ ์‹œ์ž‘
    • ๊ฒ€์‚ฌ ์ฃผ๊ธฐ 20์ดˆ
      • ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์œ ์ง€ํ•œ๋‹ค.

๐Ÿ’ฟ Startup Probe

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
ports:
- name: liveness-port
  containerPort: 8080
  hostPort: 8080

livenessProbe:
  httpGet:
    path: /healthz
    port: liveness-port
  failureThreshold: 1
  periodSeconds: 10

startupProbe:
  httpGet:
    path: /healthz
    port: liveness-port
  failureThreshold: 30
  periodSeconds: 10
  • ์‹œ์ž‘ํ•  ๋•Œ๊นŒ์ง€ ๊ฒ€์‚ฌ๋ฅผ ์ˆ˜ํ–‰
  • http ์š”์ฒญ์„ ํ†ตํ•ด ๊ฒ€์‚ฌ
  • 30๋ฒˆ์„ ๊ฒ€์‚ฌํ•˜์—ฌ 10์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ ์ˆ˜ํ–‰
  • 300์ดˆ ํ›„์—๋„ ํฌ๋“œ๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์ข…๋ฃŒ
    • ์ฆ‰ 300์ดˆ ๋™์•ˆ ํฌ๋“œ๊ฐ€ ์ •์ƒ ์‹คํ–‰๋  ์‹œ๊ฐ„์„ ๋ฒŒ์–ด์ค€๋‹ค.

๐Ÿ’ฟ ๋ ˆํ”Œ๋ฆฌ์ผ€์ด์…˜ ์…‹(๋ ˆํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ปจํŠธ๋กค๋Ÿฌ)

  • ํฌ๋“œ๊ฐ€ ํ•ญ์ƒ ์‹คํ–‰๋˜๋„๋ก ์œ ์ง€ํ•˜๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ฆฌ์†Œ์Šค
  • ๋…ธ๋“œ๊ฐ€ ํด๋Ÿฌ์Šคํ„ฐ์—์„œ ์‚ฌ๋ผ์ง€๋Š” ๊ฒฝ์šฐ ํ•ด๋‹น ํฌํŠธ๋ฅผ ๊ฐ์ง€ํ•˜๊ณ  ๋Œ€์ฒด ํฌ๋“œ ์ƒ์„ฑ
  • ์‹คํ–‰ ์ค‘์ธ ํฌ๋“œ์˜ ๋ชฉ๋ก์„ ์ง€์†์ ์œผ๋กœ ๋ชจ๋‹ˆํ„ฐ๋ง ํ•˜๊ณ  โ€˜์œ ํ˜•โ€™์˜ ์‹ค์ œ ํฌ๋“œ ์ˆ˜๊ฐ€ ์›ํ•˜๋Š” ์ˆ˜์™€ ์ผ์น˜ํ•˜๋Š”์ง€ ํ™•์ธ
  • ์„ธ๊ฐ€์ง€ ์š”์†Œ
    • R.C๊ฐ€ ๊ด€๋ฆฌํ•˜๋Š” ํฌ๋“œ์˜ ๋ฒ”์œ„๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ๋ ˆ์ด๋ธ” ์…€๋ ‰ํ„ฐ
    • ์‹คํ–‰ํ•ด์•ผ ํ•˜๋Š” ํฌ๋“œ์˜ ์ˆ˜๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ๋ณต์ œ๋ณธ์˜ ์ˆ˜
    • ์ƒˆ๋กœ์šด ํฌ๋“œ์˜ ๋ชจ์–‘์„ ์„ค์ •ํ•˜๋Š” ํฌ๋“œ ํ…œํ”Œ๋ฆฟ
  • ์žฅ์ 
    • ํฌ๋“œ๊ฐ€ ์—†์„ ๊ฒฝ์šฐ ์ƒˆ ํฌ๋“œ๋ฅผ ํ•ญ์ƒ ์‹คํ–‰
    • ๋…ธ๋“œ๊ฐ€ ์žฅ์•  ๋ฐœ์ƒ ์‹œ ๋‹ค๋ฅธ ๋…ธ๋“œ์— ๋ณต์ œ๋ณธ ์ƒ์„ฑ
    • ์ˆ˜๋™, ์ž๋™์œผ๋กœ ์ˆ˜ํ‰ ์Šค์ผ€์ผ๋ง
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx
spec:
  replicas: 3
  selector:
    app: nginx
  template:
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80

This post is licensed under CC BY 4.0 by the author.

Spring Web MVC 3

Kubernetes 3