title: How to create a post-init container in Kubernetes?
body: <p>I'm trying to create a redis cluster on K8s. I need a sidecar container to create the cluster after the required number of redis containers are online.</p>
  
  <p>I've got 2 containers, <code>redis</code> and a sidecar. I'm running them in a <code>statefulset</code> with 6 replicas. I need the sidecar container to run just once for each replica then terminate. It's doing that, but K8s keeps rerunning the sidecar. </p>
  
  <p>I've tried setting a <code>restartPolicy</code> at the container level, but it's invalid. It seems K8s only supports this at the pod level. I can't use this though because I want the <code>redis</code> container to be restarted, just not the sidecar.</p>
  
  <p>Is there anything like a <code>post-init container</code>? My sidecar needs to run <strong>after</strong> the main <code>redis</code> container to make it join the cluster. So an <code>init container</code> is no use.</p>
  
  <p>What's the best way to solve this with K8s 1.6?</p>