<p>We are having issues that rarely we will have a pod fail to be scheduled with an error that all 16 nodes failed due to affinity/anti-affinity.  We would not expect affinity to prevent any of the nodes from being scheduled.</p>
<p>I'd like to determine what the actual cause of the affinity failing in scheduling is, and for that I think I need to know what the affinities a pod was initialized with.  However, I can't look at chart configuration files since these particular pods are being scheduled programmatically at runtime.  Is there a kubectl command I can use to view what the pod's affinity was set to, or to determine why every node is failing its affinity checks?</p>

dsollen
<p>Figured this out on my own.  The command I used was:</p>
<pre><code>kubectl get pods &lt;pod_name&gt; -o json | jq '.spec.affinity'
</code></pre>
<p>I had to yum install jq for this to work.  if instead you wanted to look at affinity of all pods I think you need to remove the pod name and add a .items[] in front of the .spec for the jq command.</p>
<p>For those curious my affinity has this</p>
<pre><code>{ 
  &quot;key&quot;: &quot;host&quot;,
  &quot;operator&quot;: &quot;In&quot;,
  &quot;values&quot;: [
     &quot;yes&quot;
  ]
}
</code></pre>
<p>That &quot;yes&quot; doesn't seem quite right to me.  So yeah something funky is happening in our pod creation.</p>
