Slide 15
Slide 15 text
Copyrights©3-shake Inc. All Rights Reserved. 15
KEP-753: Sidecar Containers
● サイドカーで使える設定
○ restartPolicy
○ Probe
○ Lifecycle Hook
● Init コンテナを間に挟める
apiVersion: v1
kind: Pod
metadata:
name: pod-with-sidecar
spec:
initContainers:
- name: init-1
image: cgr.dev/chainguard/wolfi-base:latest
command: ["ash", "-c", "echo Started; echo Sleep 5s; sleep 5; echo Terminated"]
- name: sidecar-1
image: cgr.dev/chainguard/wolfi-base:latest
restartPolicy: Always
command: ["ash", "-c", "trap 'echo Terminated; exit' TERM; echo Started; while true; do sleep 1; done"]
lifecycle:
preStop:
exec:
command: ["ash", "-c", "echo PreStop Executed > /proc/1/fd/1; sleep 5; echo PreStop Done > /proc/1/fd/1"]
- name: init-2
image: cgr.dev/chainguard/wolfi-base:latest
command: ["ash", "-c", "echo Started; echo Sleep 5s; sleep 5; echo Terminated"]
- name: sidecar-2
image: cgr.dev/chainguard/wolfi-base:latest
restartPolicy: Always
command: ["ash", "-c", "trap 'echo Terminated; exit' TERM; echo Started; while true; do sleep 1; done"]
containers:
- name: regular-1
image: cgr.dev/chainguard/wolfi-base:latest
command: ["ash", "-c", "trap 'echo Terminated; exit' TERM; echo Started; while true; do sleep 1; done"]
lifecycle:
postStart:
exec:
command: ["ash", "-c", "echo PostStart Executed > /proc/1/fd/1"]
※ 2023/7/19 時点の実装