株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

lifecycle.poststart

  • spec.containers.lifecycle.postStartを利用することで、コマンド実行可能
  • Podの起動、ENTRYPOINT、COMMANDなどと同時タイミング(非同期処理)で実行される
    • 順番がある処理があるとまずい

yamlファイル

        lifecycle:
          postStart:
            exec:
              command:
                - sh
                - -c
                - "echo test > /tmp/test.txt"
app.yaml
    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

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)