I'm curious about the differences and similarities between initContainers and sidecars in Kubernetes. Specifically, why not just use a spec.sideCar instead of having to set initContainers with a restartPolicy of always? From my understanding, setting an initContainer to restartPolicy: always means it keeps restarting on its own—am I missing something?
2 Answers
There was a lot of back-and-forth on this topic when they were designing the API. There really isn't a perfect solution because each option has its nuances and use cases.
So, with an init container set to restartPolicy: Always, it runs continuously for the pod's lifecycle. This can be useful for supporting services, but it's pretty much like a sidecar in that regard.

But how does this differ from just having another container running in the same pod?