โถ ์์ฉ ๊ณผ์ 1
startupProbe๊ฐ ์คํจ ๋๋๋ก ์ค์ ํด์ Pod๊ฐ ๋ฌดํ ์ฌ๊ธฐ๋ ์ํ๊ฐ ๋๋๋ก ์ค์ ํด ๋ณด์ธ์.
(์ฌ๋ฌ๋ถ๋ค์ด ๊ฐ์ฅ ๋ง์ด ๊ฒช๊ฒ๋ Pod ์๋ฌ์ ๋๋ค)
๊ธฐ์กด Deployment ์ startupProbe
startupProbe:
httpGet:
path: /ready
port: http
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 20
- timeoutSeconds : ํ๋ก๋ธ ์์ฒญ์ ํ์์์ ์๊ฐ
- periodSeconds : ํ๋ก๋ธ ์์ฒญ ์๊ฐ
- successThreshold : ๋ช ๋ฒ ์ฑ๊ณตํ์ ๋ ์ฑ๊ณต์ผ๋ก ๊ฐ์ฃผํ ์ง
- failureThreshole : ๋ช ๋ฒ ์คํจ๊น์ง ๊ธฐ๋ค๋ฆด์ง
์ค์ Pod ์ ๋ก๊ทธ๋ฅผ ๋ณด๋ฉด startUpProbe ๊ฐ 4๋ฒ ์คํจํ๊ณ , 5๋ฒ์งธ์์ ์ฑ๊ณต !!
=> failureThreshole ๋ฅผ ๋ฎ์ถฐ์ 1๋ฒ์ผ๋ก ๋ฎ์ถฐ์ ์คํจํ๋์ง ํ์ธํ๊ธฐ
startupProbe:
httpGet:
path: /ready
port: http
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 1
pod๊ฐ CrashLoopBackOff ์ํ๋ก ๊ณ์ restart ๋จ
๐ฅCrashLoopBackoff ์ํ๋ Kubernetes์์ Pod๊ฐ ๊ณ์ํด์ ํฌ๋์(์ถฉ๋)๋๊ณ ์๋์ผ๋ก ์ฌ์์๋์ง๋ง, ์ผ์ ํ์ ์ด์ ์คํจํ๋ฉด์ ์ฌ์์ ๊ฐ๊ฒฉ์ ์ ์ ๋๋ ค๊ฐ๋ ์ํ
โถ ์์ฉ ๊ณผ์ 2
์ผ์์ ์ฅ์ ์ํฉ(App ๋ด๋ถ ๋ถํ ์ฆ๊ฐ)๊ฐ ์์ ๋ ํ, 30์ด ๋ค์ ํธ๋ํฝ์ด ์ค๋จ๋๊ณ ,
3๋ถ ๋ค์๋ App์ด ์ฌ๊ธฐ๋ ๋๋๋ก ์ค์ ํด ๋ณด์ธ์.
(์๋ API๋ฅผ ๋ ๋ฆฌ๋ฉด readinessProbe์ livenessProbe๊ฐ ๋์์ ์คํจํ๊ฒ ๋ฉ๋๋ค)
// ๋ถํ ์ฆ๊ฐ API
curl http://192.168.56.30:31231/server-load-on
// ์ธ๋ถ API ์คํจ
curl http://192.168.56.30:31231/hello
// ๋ถํ ๊ฐ์ API
curl http://192.168.56.30:31231/server-load-off
๋ฌธ์
๋ถํ๊ฐ ์๊ธด ํ
- 30์ด ํ ํธ๋ํฝ ์ค๋จ (readliness ์คํจ)
- 3๋ถ ํ ์ฑ ์ฌ์์ (liveness ์คํจ)
์๊ฐ | ๋์ | ํด๋น probe |
0์ด | ๋ถํ ์์ | readiness + liveness ์คํจ |
30์ด | ์๋น์ค ์ ์ธ | readliness ์คํจ 3ํ -> 10์ด ๊ฐ๊ฒฉ -> 30์ด ์์ |
3๋ถ | ์ฑ ์ฌ์์ | livenessProbe ์คํจ 3ํ -> 60์ด ๊ฐ๊ฒฉ -> 3๋ถ ์์ |
๊ธฐ์กด ์ฝ๋
livenessProbe:
httpGet:
path: /ready
port: http
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: http
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
startupProbe:
httpGet:
path: /ready
port: http
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 10
- ํ์ฌ ์ค์ ๋ readinessProbe ๋ 10 * 3 = 30์ด
- ํ์ฌ ์ค์ ๋ livenessProbe ๋ 10 * 30 = 30์ด
-> livenessProbe ๊ฐ 3๋ถ์ด ๋์ด์ผํ๋ฏ๋ก periodSeconds ๋ฅผ 60์ผ๋ก ๋๋ฆฌ๊ธฐ
๋ณ๊ฒฝ๋ ์ฝ๋
livenessProbe:
httpGet:
path: /ready
port: http
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 60
successThreshold: 1
failureThreshold: 3
โถ ์์ฉ ๊ณผ์ 3
Secret ํ์ผ(/usr/src/myapp/datasource/postgresql-info.yaml)์ด ์กด์ฌํ๋์ง ์ฒดํฌํ๋ readinessProbe๋ฅผ ๋ง๋ค์ด ๋ณด์ธ์.
(๊ผญ API๋ฅผ ๋ ๋ฆฌ๋ ๊ฒ๋ง์ด readinessProbe ํ์ฉ์ ์ ๋ถ๋ ์๋๋๋ค)
๊ธฐ์กด ์ฝ๋
readinessProbe:
httpGet:
path: /ready
port: http
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
๋ณ๊ฒฝ๋ ์ฝ๋
readinessProbe:
exec:
command: ["cat", "/usr/src/myapp/datasource/postgresql-info.yaml"]
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
- exec ๋ผ๋ ์์ฑ์ผ๋ก command ๋ฅผ Pod ์ ๋ ๋ฆด ์ ์๋ค
- App ๊ธฐ๋์ ํ์ํ ํ์ผ์ด ์๋์ง ์ฒดํฌ
'๐ฑ ์ธํ๋ฐ > โ ์ฟ ๋ฒ๋คํฐ์ค ์ด๋๋ ํด๋์ค (์ง์ํธ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฏธ์ 4] Application ๊ธฐ๋ฅ์ผ๋ก ์ดํดํ๊ธฐ - PVC/PV, Deployment, Service, HPA (0) | 2025.06.08 |
---|---|
[๋ฏธ์ 3] Application ๊ธฐ๋ฅ์ผ๋ก ์ดํดํ๊ธฐ - Configmap, Secret > ์์ฉ๊ณผ์ (0) | 2025.06.08 |
(8) Component ๋์์ผ๋ก ์ดํดํ๊ธฐ (0) | 2025.06.08 |
(7) PV/PVC, Deployment, Service, HPA (1) | 2025.06.08 |
(6) Configmap, Secret ์ดํดํ๊ธฐ (2) | 2025.06.08 |