Usually you have 1 service per Deployment/StatefulSet which runs in a single container. If you have any sidecars that need to run with it, you add it to the list. But do you add it before or after your service?
While the docs say that initContainers are run serially, no guarantee is made on how the main containers are run. There's an open issue to support dependencies between containers.
Right now, they're started serially, but there have already been attempts to start them in parallel.
The important parts are in kubelet/kuberuntime
,
specifically:
getting list of containers that need to change
and
starting containers in order.
This means that you probably want to start your sidecars first if you main service depends on it, for example starting GCP's cloudsql-proxy first so the service has a DB to connect to.
If you look a bit deeper, you'll notice the postStart hook is run synchronously as part of starting the container, so if that edge of starting first isn't enough, you could craft a blocking postStart hook to wait until the container is ready.