Code change:
The name of each app and init container in a Pod must be unique; a validation error is thrown for any container sharing a name with another. <del> #### API for sidecar containers {{< feature-state for_k8s_version="v1.28" state="alpha" >}} Starting with Kubernetes 1.28 in alpha, a feature gate named `SidecarContainers` allows you to specify a `restartPolicy` for init containers which is independent of the Pod and other init containers. Container [probes](/docs/concepts/workloads/pods/pod-lifecycle/#types-of-probe) can also be added to control their lifecycle. If an init container is created with its `restartPolicy` set to `Always`, it will start and remain running during the entire life of the Pod, which is useful for running supporting services separated from the main application containers. If a `readinessProbe` is specified for this init container, its result will be used to determine the `ready` state of the Pod. Since these containers are defined as init containers, they benefit from the same ordering and sequential guarantees as other init containers, allowing them to be mixed with other init containers into complex Pod initialization flows. Compared to regular init containers, sidecar-style init containers continue to run and the next init container can begin starting once the kubelet has set the `started` container status for the sidecar-style init container to true. That status either becomes true because there is a process running in the container and no startup probe defined, or as a result of its `startupProbe` succeeding. This feature can be used to implement the sidecar container pattern in a more robust way, as the kubelet always restarts a sidecar container if it fails. Here's an example of a Deployment with two containers, one of which is a sidecar: {{% code_sample language="yaml" file="application/deployment-sidecar.yaml" %}} This feature is also useful for running Jobs with sidecars, as the sidecar container will not prevent the Job from completing after the main container has finished. Here's an example of a Job with two containers, one of which is a sidecar: {{% code_sample language="yaml" file="application/job/job-sidecar.yaml" %}} #### Resource sharing within containers </del> <ins> ### Resource sharing within containers </ins> <del> Given the ordering and execution for init containers, the following rules </del> <ins> Given the order of execution for init, sidecar and app containers, the following rules </ins> for resource usage apply: * The highest of any particular resource request or limit defined on all init

Related discussion:
text: restartPolicy under initContainers is not allowing to create Jobs specified into the below documents Error Message: Job in version "v1" cannot be handled as a Job: strict decoding error: unknown field "[0].restartPolicy" Document Link:
Hi I believe the error message you are getting is because you might have used feild under the section. But it is not allowed under the . /language en
Page related to the issue: /sig docs /sig node
Hi , Below is the Job configuration:
Could you please provide the code block with proper indentation?
updated above section
The indentation should be corrected as below
/kind bug
mentions a feature gate, but doesn't make it explicitly clear that you need to enable it. The feature gate is named . The fix I recommend: add a brand new page edit to direct readers to that new page /remove-kind bug I don't think there is anything actually incorrect. /triage accepted /retitle Unclear documentation about sidecar containers
Is anybody working to fix this issue? If no, i can take it.
/assign
Feel free to involve me, if you need any help.
Sure, Thank you.
PR raised to fix the issue .
Also see
To learn more, you can read (but not plagiarize)
Hi, I also having this problem I tried to add restartPolicy as to under containers and init containers, but I get the same error. I do not got any errors for the restartPolicy, but and are gave the error mentioned at the top. Im using Minikube, and my CC: Your suggestions highly appriciatable
Looks like you are using 1.27, but this feature was in 1.28.
Thanks I updated my k8s Even though I can not use and in both places. ( and I put this marker in the above comment). It says,