Home > other >  Can we set any conditions in kubernetes init containers?
Can we set any conditions in kubernetes init containers?

Time:08-04

I have a container X and it should wait for the container Y to start however container Y has two modes and the init of X should select the mode which is active. how do I set init configuration of X to select the active one.

CodePudding user response:

One thing you can do very simply is use a ConfigMap in your cluster. This ConfigMap will have a key that denotes the mode you want to use. You will mount this ConfigMap in your container Y, which serves as an initContainer and depending on how it executes it will set the value of mode variable in the ConfigMap.

Later, when the container X starts, it will read the value of this mode variable from the ConfigMap it will mount as a volume (this can also be imported as an environment variable). This will allow the container X to execute based on the mode set by container Y.

  • Related