Search code examples
kubernetesinitializationsleepexecution

Kubernetes how to create a sidecar which runs initialization and terminate


I need a sidecar in kubernetes cluster which runs initialization script and then terminates or sleep forever. I can't do this in postStart as postStart does not guarantee the CMD / ENTRYPOINT in main container has started. Any advice and insight is appreciated.


Solution

  • I use Job to accomplish the task.

    apiVersion: batch/v1
    kind: Job