Search code examples
dockerkubernetescontainersopenshift

How to restart init container


I have a requirement where need to restart only init container after applying changes, And make app container running. This process should be run every day at specific time. Can any one has any suggestion how to achieve this.


Solution

  • This isn't how initContainers work - you can't restart one independently of the main containers.

    Someone already suggested a daily cronJob.

    My suggestion to consider is that you create a sidecar container that sleeps for a day, then runs the workload, then sleeps again.

    If you ALSO need this to run before the main container first runs, duplicate it as an initContainer. If it's acceptable to have it run in parallel to the main container starting then the sidecar container could well be enough by itself.