title: Do not allow two pods of the same application on same node in kubernetes
body: <p>We have a situation now when 2 pods of same type can run on the same node. Sometimes during restarts and rescheduling 2 pods happen to be on the same node and when this node itself is rescheduled all of our pods are gone for a while resulting in connection troubles (we have just 2 pods that are load balanced).</p>
  
  <p>I think the best way to fix it is to not allow 2 pods to run on the same node and to use inter-pod anti-affinity for that. </p>
  
  <p>Is this the correct solution to the problem? I tried to understand it but got a bit bogged down with <code>topologyKey</code> and the syntax. Can someone explain/give an example on how to achieve this?</p>