<p>I have a pod with 2 closely related services running as containers. I am running as a <code>StatefulSet</code> and have set replicas as 5. So 5 pods are created with each pod having both the containers.</p>
<p>Now My requirement is to have the second container run only in 1 pod. I don't want it to run in 5 pods. But my first service should still run in 5 pods.</p>
<p>Is there a way to define this in the deployment yaml file for Kubernetes? Please help.</p>

ckv
<p>a &quot;pod&quot; is the smallest entity that is managed by kubernetes, and one pod can contain multiple containers, but you can only specify one pod per deployment/statefulset, so there is no way to accomplish what you are asking for with only one deployment/statefulset.</p>
<p>however, if you want to be able to scale them independently of each other, you can create two deployments/statefulsets to accomplish this. this is imo the only way to do so.</p>
<p>see <a href="https://kubernetes.io/docs/concepts/workloads/pods/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/</a> for more information.</p>
