How do I create a post-init container in Kubernet?
I am trying to create a redis cluster on K8s. I need a stroller container to create a cluster after the required number of redis containers are online.
I have 2 containers redis
and a stroller. I run them in statefulset
with 6 cues. I need the stroller container to start only once per replica and then terminate. He does so, but K8s continues to fiddle with the stroller.
I tried to install restartPolicy
at the container level but it is not valid. It seems K8s only supports this at the swap level. I cannot use this because I want the container to redis
be restarted, not the stroller.
Is there something like post-init container
? In order to join the cluster, my wheelchair needs to be started after the main container redis
. Therefore it is init container
useless.
What's the best way to solve this problem with K8s 1.6?
source to share
I advise you to use Kubernetes Jobs:
https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
This kind of task will work until it is completed once. In this task, you can try to determine if all the required nodes are available to form a cluster.
source to share