λͺ©μ°¨
Β Init Containers
Multi-Container Podμμ κ° μ»¨ν
μ΄λλ Podμ μλͺ
μ£ΌκΈ°λμ μ΄μ μμ΄μΌ νλ νλ‘μΈμ€λ₯Ό μ€νν κ²μΌλ‘ κΈ°λλλ€.
[CKA] 31. Multi-Container Pods μμ μ¬μ©λ μΉ μ ν리μΌμ΄μ
κ³Ό λ‘κΉ
μμ΄μ νΈκ° μ¬μ©λλ λ€μ€ 컨ν
μ΄λ νλλ λ 컨ν
μ΄λ λͺ¨λκ° νμ μ΄μ μμ΄μΌ νλ€. λ μ€ νλλΌλ Fail μνκ° λλ€λ©΄ Podλ μ¬μμλλ€.
νμ§λ§ λλλ‘ κ³μ μ€νλλ νλ‘μΈμ€κ° μλ ν λ²λ§ μ€νλκ³ μλ£λλ νλ‘μΈμ€λ₯Ό μ€νν νμκ° μλ€. μλ₯Ό λ€μ΄, μ£Όμ μΉ μ ν리μΌμ΄μ
μμ μ¬μ©ν μ½λλ λ°μ΄λ리λ₯Ό Repositoryμμ κ°μ Έμ€λ νλ‘μΈμ€κ° μλ€. λλ μ€μ μ ν리μΌμ΄μ
μ΄ μμλκΈ° μ μ μΈλΆ μλΉμ€λ λ°μ΄ν°λ² μ΄μ€κ° μ€λΉλ λκΉμ§ κΈ°λ€λ €μΌ νλ νλ‘μΈμ€κ° μμ μ μλ€. μ΄λ initContainersκ° νμνλ€.
Β Configure initContainer
initContainerλ λ€λ₯Έ 컨ν
μ΄λμ λ§μ°¬κ°μ§λ‘ Podμ ꡬμ±λμ§λ§, initContainers μΉμ
λ΄μ μ§μ λλ€.
# pod-definition.yaml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: busybox:1.28
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
initContainers:
- name: init-myservice
image: busybox
command: ['sh', '-c', 'git clone <some-repository-that-will-be-used-by-application> ; done;']
YAML
볡μ¬
Podκ° μ²μ μμ±λ λ initContainerκ° μ€νλλ©°, initContainerμ νλ‘μΈμ€κ° μλ£λμ΄μΌ μ€μ μ ν리μΌμ΄μ
μ νΈμ€ν
νλ 컨ν
μ΄λκ° μμλλ€.
Β Configure Multi-initContainers
μ¬λ¬ κ°μ initContainersλ₯Ό ꡬμ±ν μ μμΌλ©°, μ΄ κ²½μ° κ° initContainerλ μμ°¨μ μΌλ‘ νλμ© μ€νλλ€. initContainerκ° νλλΌλ μλ£λμ§ μμΌλ©΄, μΏ λ²λ€ν°μ€λ initContainerκ° μ±κ³΅ν λκΉμ§ Podλ₯Ό λ°λ³΅μ μΌλ‘ μ¬μμνλ€.
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp-container
image: busybox:1.28
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
initContainers:
- name: init-myservice
image: busybox:1.28
command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done;']
- name: init-mydb
image: busybox:1.28
command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;']
YAML
볡μ¬