[k8s] ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์ปจํŠธ๋กค๋Ÿฌ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์ž

๊ฐœ์š”

์ด์ „์— ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ์˜ค๋ธŒ์ ํŠธ์— ๋Œ€ํ•ด ํ•™์Šตํ–ˆ์—ˆ๋‹ค.

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๋Š” ํฌ๊ฒŒ ์˜ค๋ธŒ์ ํŠธ์™€ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ๋กœ ๋‚˜๋‰œ๋‹ค๊ณ  ํ–ˆ์—ˆ๋Š”๋ฐ ์ด๋ฒˆ์—” ์ปจํŠธ๋กค๋Ÿฌ์— ๋Œ€ํ•ด ์ •๋ฆฌํ•˜๊ณ ์ž ํ•œ๋‹ค.

 

https://dgjinsu.tistory.com/68

 

[k8s] ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ๊ธฐ๋ณธ ์˜ค๋ธŒ์ ํŠธ (Pod, Service, Volume, Namespace)

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๋Š” ํฌ๊ฒŒ ์˜ค๋ธŒ์ ํŠธ(object)์™€ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ(controller)๋กœ ๋‚˜๋ˆ ์ ธ ์žˆ๋‹ค.์˜ค๋ธŒ์ ํŠธ์—” ์–ด๋–ค ๊ฒƒ๋“ค์ด ์žˆ๊ณ  ๊ฐ๊ฐ์˜ ์˜ค๋ธŒ์ ํŠธ์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ •๋ฆฌํ•ด๋ณด์•˜๋‹ค.    ์ฟ 

dgjinsu.tistory.com

 

 

 

 

 

 

 

์ปจํŠธ๋กค๋Ÿฌ๋ž€?

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ์ปจํŠธ๋กค๋Ÿฌ๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ํด๋Ÿฌ์Šคํ„ฐ์˜ ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ  ์›ํ•˜๋Š” ์ƒํƒœ๋กœ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ์ค‘์š”ํ•œ ๊ตฌ์„ฑ ์š”์†Œ์ด๋‹ค. ํ˜„์žฌ ํด๋Ÿฌ์Šคํ„ฐ์˜ ์ƒํƒœ๋ฅผ ์ง€์†์ ์œผ๋กœ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ , ์‚ฌ์šฉ์ž๊ฐ€ ์›ํ•˜๋Š” ์ƒํƒœ์™€ ๋น„๊ตํ•˜์—ฌ ์ฐจ์ด๋ฅผ ์กฐ์ •ํ•œ๋‹ค. 

 

์ปจํŠธ๋กค๋Ÿฌ์˜ ๊ธฐ๋Šฅ๋“ค์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  • Autho Healing
  • Software Update
  • Auto Sacling
  • Job

 

 

์ปจํŠธ๋กค๋Ÿฌ์—๋Š” ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ์ง€๋งŒ ์ด๋“ค ์ค‘ 4๊ฐ€์ง€๋งŒ ์•Œ์•„๋ณผ ์˜ˆ์ •์ด๋‹ค. 

  • ReplicaSet
  • Deployment
  • DaemonSet
  • Job / CronJob

 

 

 

 

1. ReplicaSet

๋ ˆํ”Œ๋ฆฌ์นด์…‹(ReplicaSet)์€ ํŒŒ๋“œ(Pod) ์ง‘ํ•ฉ์˜ ์‹คํ–‰์„ ์•ˆ์ •์ ์œผ๋กœ ์œ ์ง€ํ•˜๋Š”๋ฐ ๋ชฉ์ ์„ ๊ฐ–์ถ˜ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์›Œํฌ๋กœ๋“œ์ด๋‹ค. ๋ ˆํ”Œ๋ฆฌ์นด์…‹์€ ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•œ ๊ฐœ์ˆ˜๋งŒํผ ๋ณต์ œ ํŒŒ๋“œ๋ฅผ ์ƒ์„ฑํ•ด์ฃผ๊ณ  ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์ด์šฉํ•ด ํ•ด๋‹น ๊ฐœ์ˆ˜์˜ ๋ณต์ œ ํŒŒ๋“œ๊ฐ€ ์ •์ƒ ์‹คํ–‰ ์ค‘์ธ์ง€ ํ•ญ์ƒ ๊ฐ์‹œํ•œ๋‹ค. ํŒŒ๋“œ ํ•˜๋‚˜์— ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒจ ๋‹ค์šด๋˜๋ฉด ์ด๋ฅผ ๊ฐ์ง€ํ•ด ์ƒˆ ํŒŒ๋“œ๋ฅผ ๋ฐ”๋กœ ์ƒ์„ฑํ•ด๋‹ค.

 

์ฆ‰, Pod์˜ ๋ณต์ œ๋ณธ ์ˆ˜๋ฅผ ์œ ์ง€ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ์ด๋‹ค. ์ง€์ •๋œ ์ˆ˜์˜ Pod ๋ณธ์ œ๋ณธ์„ ์œ ์ง€ํ•˜๊ณ , Pod๊ฐ€ ์‚ญ์ œ๋˜๊ฑฐ๋‚˜ ์žฅ์• ๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒฝ์šฐ์ƒˆ๋กœ์šด Pod๋ฅผ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•œ๋‹ค.

 

 

ReplicaSet์ด ํ•ด์ฃผ๋Š” ๋ช‡ ๊ฐ€์ง€ ๊ธฐ๋Šฅ๋“ค์ด๋‹ค. 

 

๋จผ์ € Pod๊ฐ€ ์ฃฝ์œผ๋ฉด ์ด๋ฅผ ๊ฐ์ง€ํ•˜๊ณ  Pod๋ฅผ ์žฌ์ƒ์„ฑ ํ•ด์ค€๋‹ค. 

 

์ด๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋งŒ์•ฝ Pod์˜ Version Upgrade๋ฅผ ํ•˜๊ณ ์‹ถ๋‹ค๋ฉด Pod์˜ Template์„ ์ˆ˜์ •ํ•˜๊ณ  ๊ธฐ์กด์˜ ๋– ์žˆ๋Š” Pod๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค๋ฉด ์žฌ์ƒ์„ฑํ•  ๋•Œ ์ƒˆ ๋ฒ„์ „์˜ Pod๋ฅผ ๋„์šธ ์ˆ˜ ์žˆ๋‹ค. 

 

 

 

 

ReplicaSet์€ replicas์˜ ์ˆ˜ ๋งŒํผ Pod๋ฅผ ์œ ์ง€ํ•˜๋ ค๊ณ  ํ•œ๋‹ค.

๋”ฐ๋ผ์„œ ๋‹จ์ˆœํžˆ replicas์˜ ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒƒ ๋งŒ์œผ๋กœ๋„ Sacle Out์„ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

๋ณดํ†ต ๋”ฐ๋กœ controller์™€ Pod๋ฅผ ๋งŒ๋“ค์ง€ replicas๋ฅผ ์ด์šฉํ•ด Controller๋งŒ ๋งŒ๋“ค๊ณค ํ•œ๋‹ค. 

 

 

์•„๋ž˜๋Š” ์˜ˆ์ œ yml์ด๋‹ค.

apiVersion: v1
kind: ReplicationController
metadata:
 name: replication-1
spec:
 replicas: 1
 selector:
   type: web
 template:
   metadata:
     name: pod-1
     labels:
       type: web
   spec:
     containers:
     - name: container
       image: tmkube/app:v2

 

 

 

 

ReplicaSet์—์„  Pod๋ฅผ Selectํ•  ๋•Œ matchExpressions ๋˜ํ•œ ๊ฐ€๋Šฅํ•˜๋‹ค. 

๋ณดํ†ต Selector์€ key์™€ value๋ชจ๋‘ ๋™์ผํ•  ๋•Œ Pod๋ฅผ ์„ ํƒํ•˜๋Š”๋ฐ matchExpressions๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ์˜ต์…˜์„ ์ง€์ •ํ•˜์—ฌ ์กฐ๊ธˆ ๋” ์œ ์—ฐํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

์•„๋ž˜์™€ ๊ฐ™์ด yml์„ ์ƒ์„ฑํ•˜๋ฉด์„œ selector๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. 

apiVersion: apps/v1
kind: ReplicaSet
metadata:
 name: replica-1
spec:
 replicas: 3
 selector:
   matchLabels:
     type: web
   matchExpressions:
   - {key: ver, operator: Exists}
 template:
   metadata:
     name: pod
...

 

์œ„ ์˜ˆ์‹œ yml์—์„  operator ๊ฐ’์œผ๋กœ Exists๋ฅผ ์ง€์ •ํ–ˆ๋Š”๋ฐ ์ด๋Š” key๊ฐ€ ver์„ ๊ฐ€์ง€๋Š” Label์„ ๊ฐ€์ง„ Pod๋“ค์€ ์ „๋ถ€ ์„ ํƒํ•˜๊ฒ ๋‹ค๋Š” ๋œป์ด๋‹ค. 

 

operator์˜ ์ข…๋ฅ˜๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

 

 

 

 

 

 

 

 

2. Deployment

ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ๋Š” ์ œํ’ˆ์„ ๊ฐœ๋ฐœํ•ด ๋ฐฐํฌํ•˜๊ณ  ๋ฐฉ์น˜ํ•ด๋‘๊ณ ๋งŒ ์žˆ์ง€๋Š” ์•Š๋Š”๋‹ค. ๊ณ ๊ฐ์˜ ๋‹ˆ์ฆˆ์— ๋”ฐ๋ผ, ๋ฒ„๊ทธ์™€ ๊ฐ™์€ ์ƒˆ๋กœ์šด ์ด์Šˆ๊ฐ€ ๋œฐ ๋•Œ๋งˆ๋‹ค ์ œํ’ˆ์„ ์—…๋ฐ์ดํŠธํ•˜๋Š”๋ฐ, ์ด๋ฅผ ์žฌ๋ฐฐํฌํ•˜๊ธฐ ์œ„ํ•ด ์„œ๋ฒ„๋ฅผ ์ค‘๋‹จํ•˜๋Š” ๊ฒƒ์€ ํฐ ๋ฐ˜๋ฐœ์„ ๊ฐ€์ ธ์˜จ๋‹ค.

 

๋””ํ”Œ๋กœ์ด๋จผํŠธ(Deployment)๋Š” ํŒŒ๋“œ ๋˜๋Š” ๋ ˆํ”Œ๋ฆฌ์นด์…‹์˜ ์„ ์–ธ์  ์—…๋ฐ์ดํŠธ๋ฅผ ์ œ๊ณตํ•˜๋Š” ์›Œํฌ๋กœ๋“œ์ด๋‹ค.

 

 

๋ฐฐํฌ ์ „๋žต์—๋Š” Recreate, Rolling Update, Blue/Green, Canary ์ •๋„๊ฐ€ ์žˆ๋‹ค. 

 

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ๋””ํ”Œ๋กœ์ด๋จผํŠธ์—์„  ๊ธฐ๋ณธ์ ์œผ๋กœ Rolling Update ๋ฐฉ์‹์˜ ์ „๋žต์„ ๊ฐ–๋Š”๋‹ค. 

 

Recreate

 

Recreate๋Š” ๊ธฐ์กด ๋ฒ„์ „์˜ Pod๋“ค์„ ๋‚ด๋ฆฌ๊ณ  ์ƒˆ๋กœ์šด ๋ฒ„์ „์˜ Pod๋“ค์„ ์˜ฌ๋ฆฌ๋Š” ๋ฐฉ์‹์ด๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค์šดํƒ€์ž„์ด ๋ฐœ์ƒํ•œ๋‹ค. 

 

๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด Deployment์˜ template์„ ์—…๋ฐ์ดํŠธ ํ•˜๊ฒŒ๋˜๋ฉด ๋จผ์ € ๊ธฐ์กด์˜ ReplicaSet(์™ผ์ชฝ)์˜ replicas๊ฐ’์„ 0์œผ๋กœ ๋ณ€๊ฒฝํ•˜๊ฒŒ ๋œ๋‹ค. ์ดํ›„ ์ƒˆ๋กœ์šด ReplicaSet์„ ๋งŒ๋“ค๊ณ  ์—ฌ๊ธฐ์—” ์ƒˆ๋กญ๊ฒŒ ๋ณ€๊ฒฝ๋œ V2์˜ Pod Template์ด ๋“ค์–ด๊ฐ€๊ฒŒ ๋œ๋‹ค. 

 

์œ„ ๊ทธ๋ฆผ์— ํ•ด๋‹นํ•˜๋Š” yml ํŒŒ์ผ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-1
spec: 
  selector:
    matchLabels:
      type: app
  replicas: 2 
  strategy:
    type: Recreate
  revisionHistoryLimit: 1
template:
    metadata:
      labels:
        type: app
    spec:
      containers:
      - name: container
        image: tmkube/app:v1

 

 

 

 

Rolling Update (Default)

๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ์šฐ์„  ReplicaSet์„ ๋งŒ๋“œ๋Š”๋ฐ ์ฒ˜์Œ์—” replicas์˜ ๊ฐ’์€ 1์ด๋‹ค. ์ด ์ƒํ™ฉ์—์„  v1 2๊ฐœ์™€ v2 1๊ฐœ์˜ Pod๋กœ ํŠธ๋ž˜ํ”ฝ์ด ๋ถ„์‚ฐ๋œ๋‹ค. 

 

 

v2 1๊ฐœ ์ƒˆ๋กญ๊ฒŒ ์ž˜ ๋–ด๋‹ค๋ฉด v1์˜ replica๋Š” 1๋กœ ์ค„๊ฒŒ ๋˜๊ณ  ์œ„ ๊ณผ์ •์„ ๊ณ„์† ๋ฐ˜๋ณตํ•ด ํ•˜๋‚˜์”ฉ ํ•˜๋‚˜์”ฉ ์ƒˆ ๋ฒ„์ „์œผ๋กœ updateํ•ด๋‚˜๊ฐ„๋‹ค. 

 

 

์œ„ ๊ทธ๋ฆผ์— ํ•ด๋‹นํ•˜๋Š” yml ํŒŒ์ผ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-2
spec: 
  selector:
    matchLabels:
      type: app
  replicas: 2 
  strategy:
    type: RollingUpdate
  minReadySeconds: 10
  template:
    metadata:
      labels:
        type: app
    spec:
      containers:
      - name: container
        image: tmkube/app:v1

 

 

 

 

 

 

 

3. DaemonSet

DaemonSet์€ ํด๋Ÿฌ์Šคํ„ฐ ๋‚ด์˜ ๊ฐ ๋…ธ๋“œ์—์„œ ํŠน์ • ํŒŒ๋“œ๊ฐ€ ์‹คํ–‰๋˜๋„๋ก ๋ณด์žฅํ•˜๋Š” ๋ฆฌ์†Œ์Šค์ด๋‹ค. 

 

์ด๋Š” ๋กœ๊ทธ ์ˆ˜์ง‘, ๋ชจ๋‹ˆํ„ฐ๋ง ์—์ด์ „ํŠธ, ๋„คํŠธ์›Œํฌ ํ”Œ๋Ÿฌ๊ทธ์ธ ๋“ฑ ์‹œ์Šคํ…œ ์ˆ˜์ค€์˜ ์„œ๋น„์Šค๋ฅผ ๋ฐฐํฌํ•  ๋•Œ ์œ ์šฉํ•˜๋‹ค. 

 

DaemonSet์€ ํด๋Ÿฌ์Šคํ„ฐ์˜ ๋ชจ๋“  (๋˜๋Š” ์„ ํƒ๋œ) ๋…ธ๋“œ์— ํŒŒ๋“œ๋ฅผ ๋ฐฐํฌํ•˜๊ณ , ์ƒˆ๋กœ์šด ๋…ธ๋“œ๊ฐ€ ํด๋Ÿฌ์Šคํ„ฐ์— ์ถ”๊ฐ€๋  ๋•Œ๋งˆ๋‹ค ์ž๋™์œผ๋กœ ํŒŒ๋“œ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

 

 

DaemonSet์€ selector๋กœ Node๋ฅผ ์—ฐ๊ฒฐํ•œ๋‹ค. ๋งŒ์•ฝ centos์—์„œ๋งŒ ๋Œ์•„๊ฐ€๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ตฌ๋™ํ•ด์•ผํ•  ๋•Œ ubuntu os๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š” Node๋Š” ์ œ์™ธํ•˜๊ณ  ์„ ํƒํ•ด์•ผ ํ•œ๋‹ค. 

 

๊ทธ๋Ÿด๋• ์•„๋ž˜์™€ ๊ฐ™์ด nodeSelector๋ฅผ ์‚ฌ์šฉํ•ด์„œ Node1, Node2์— ๋Œ€ํ•ด์„œ๋งŒ Pod๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

์•„๋ž˜ ์ฝ”๋“œ์—์„œ hostPort๋ฅผ ๋ณด๋ฉด Pod๊ฐ€ ๋Œ์•„๊ฐ€๋Š” Host์— 18080์œผ๋กœ ์ ‘๊ทผํ•˜๋ฉด 8080 ์ปจํ…Œ์ด๋„ˆ๋กœ ์—ฐ๊ฒฐํ•ด์ค€๋‹ค. 

apiVersion: apps/v1
kind: DaemonSet
metadata:
 name: daemonset-1
spec:
 selector:
   matchLabels:
      type: app
 template:
   metadata:
     labels:
       type: app
 spec:
     nodeSelector:
       os: centos
     containers:
     - name: container
       image: tmkube/app
       ports:
       - containerPort: 8080
         hostPort: 18080

 

 

 

 

 

 

 

4. Job / CronJob

 

 

Job

Job์€ ๋‚ด๋ถ€์ ์œผ๋กœ Pod๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ๋˜๋Š”๋ฐ, Pod์˜ ์ƒํƒœ๊ฐ€ Running์ด ์•„๋‹Œ Completed๊ฐ€ ๋˜๋Š” ๊ฒƒ์ด ์ตœ์ข…์ƒํƒœ์ด๋‹ค. 

์‹คํŒจ ์‹œ ์žฌ์‹œ์ž‘, ์ž‘์—… ์ˆ˜ํ–‰ ํšŸ์ˆ˜ ์ง€์ •, ๋™์‹œ ์‹คํ–‰ ์ž‘์—… ์ˆ˜ ์ง€์ • ๋“ฑ์˜ ์„ธ๋ถ€ ์˜ต์…˜๋„ ์ œ๊ณตํ•œ๋‹ค.

 

 

 

Job์—” ๋ช‡ ๊ฐ€์ง€ ์˜ต์…˜์„ ์ค„ ์ˆ˜ ์žˆ๋‹ค. 

 

  • completions:
    • Job์ด ์™„๋ฃŒ๋˜๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ ํŒŒ๋“œ์˜ ์„ฑ๊ณต ํšŸ์ˆ˜๋ฅผ ์ง€์ •
  • parallelism:
    • ๋™์‹œ์— ์‹คํ–‰ํ•  ํŒŒ๋“œ์˜ ์ตœ๋Œ€ ์ˆ˜๋ฅผ ์ง€์ •
  • activeDeadlineSeconds:
    • Job์ด ์™„๋ฃŒ๋˜๊ธฐ ์ „๊นŒ์ง€์˜ ์ตœ๋Œ€ ์‹œ๊ฐ„์„ ์ดˆ ๋‹จ์œ„๋กœ ์ง€์ •

 

 

 

 

CronJob

CronJob์€ ์ฃผ๊ธฐ์ ์œผ๋กœ ํŠน์ • ๋™์ž‘์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ์ข…๋ฃŒํ•˜๋Š” ์ž‘์—…(๋ฐฐ์น˜ ์ž‘์—…)์„ ์ •์˜ํ•˜๊ธฐ ์œ„ํ•œ ๋ฆฌ์†Œ์Šค์ด๋‹ค. 

๋ฆฌ๋ˆ…์Šค ํฌ๋ก (Cron) ์Šค์ผ€์ฅด๋ง ๋ฐฉ๋ฒ•์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•œ๋‹ค. 

๋‚ด๋ถ€์ ์œผ๋กœ Job์„ ์ƒ์„ฑํ•˜์—ฌ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. (๊ทธ๋ฆฌ๊ณ  Job์€ ๋‚ด๋ถ€์ ์œผ๋กœ Pod๋ฅผ ๋งŒ๋“ ๋‹ค.) ์ฃผ๊ธฐ์ ์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐฑ์—…ํ•˜๊ฑฐ๋‚˜ ๋ฐ์ดํ„ฐ ์ ๊ฒ€ ๋ฐ ์•Œ๋ฆผ ์ „์†ก ๋“ฑ์˜ ๋ชฉ์ ์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค.

 

 

 

์œ„ ์‚ฌ์ง„์—์„  1๋ถ„ ๋งˆ๋‹ค Job์ด ์ƒ์„ฑ๋˜๊ณ  Job๋“ค์€ ๊ฐ๊ฐ ์ •์˜๋œ ๋™์ž‘์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. 

 

 

์•„๋ž˜๋Š” CronJob์„ ์ •์˜ํ•˜๋Š” yml ์˜ˆ์‹œ์ด๋‹ค. 

apiVersion: batch/v1
kind: CronJob
metadata:
  name: cron-job
spec:
  schedule: "*/1 * * * *"
  concurrencyPolicy: Allow
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: Never
          containers:
          - name: container
            image: tmkube/app

 

์—ฌ๊ธฐ์„œ ์‚ดํŽด๋ณผ ๊ฑด concurrencyPolicy ์˜ต์…˜์ธ๋ฐ ์ด๋Š” ์Šค์ผ€์ค„๋œ ์ž‘์—…์ด ์•„์ง ์‹คํ–‰ ์ค‘์ธ ์ƒํƒœ์—์„œ ์ƒˆ๋กœ์šด ์ž‘์—…์ด ์‹œ์ž‘๋  ๋•Œ์˜ ๋™์ž‘ ๋ฐฉ์‹์„ ์ •์˜ํ•œ๋‹ค. 

 

concurrencyPolicy ์˜ต์…˜์—” 3๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

 

  • Allow
    • ๊ธฐ๋ณธ๊ฐ’
    • ๋™์‹œ์— ์—ฌ๋Ÿฌ ์ž‘์—…์ด ์‹คํ–‰๋  ์ˆ˜ ์žˆ๋„๋ก ํ—ˆ์šฉ
    • ์ฆ‰, ์ด์ „ ์ž‘์—…์ด ์•„์ง ์ข…๋ฃŒ๋˜์ง€ ์•Š์•˜๋”๋ผ๋„ ์ƒˆ๋กœ์šด ์ž‘์—…์ด ์‹œ์ž‘๋จ
  • Forbid
    • ์ด์ „ ์ž‘์—…์ด ์•„์ง ์‹คํ–‰ ์ค‘์ธ ๊ฒฝ์šฐ, ์ƒˆ๋กœ์šด ์ž‘์—…์ด ์‹œ์ž‘๋˜์ง€ ์•Š๋Š”๋‹ค.
    • ์ด์ „ ์ž‘์—…์ด ์™„๋ฃŒ๋œ ํ›„์—๋งŒ ์ƒˆ๋กœ์šด ์ž‘์—…์ด ์‹œ์ž‘
    • ์ž‘์—…์ด ๊ฒน์น˜์ง€ ์•Š๋„๋ก ๋ณด์žฅ
  • Replace
    • ์ด์ „ ์ž‘์—…์ด ์•„์ง ์‹คํ–‰ ์ค‘์ธ ๊ฒฝ์šฐ, ์‹คํ–‰ ์ค‘์ธ ์ž‘์—…์„ ์ค‘๋‹จํ•˜๊ณ  ์ƒˆ๋กœ์šด ์ž‘์—…์œผ๋กœ ๊ต์ฒด