【kubernetes】kubernetesでPod起動時にコマンドを実行する

spec.containers.lifecycle.postStart
を利用することで、コマンド実行可能 lifecycle:
postStart:
exec:
command:
- sh
- -c
- "echo test > /tmp/test.txt"
spec:
containers:
image: apline:latest
imagePullPolicy: Always
tty: true
lifecycle:
postStart:
exec:
command:
- sh
- -c
- "echo test > /tmp/test.txt"
出力
[root@sample-app-bc5b49978-4sr5j /]# cat /tmp/test.txt
test
[root@sample-app-bc5b49978-4sr5j /]#
https://qiita.com/petitviolet/items/41aa9abe106a29ba4667