<p>I'm trying to set node affinity using nodeSelector as discussed here: <a href="https://kubernetes.io/docs/user-guide/node-selection/" rel="nofollow noreferrer">https://kubernetes.io/docs/user-guide/node-selection/</a></p>

<p>However, no matter if I use a Pod, a Replication Controller or a Deployment, I can't get the kubectl create to work properly. This is the error I get, and it happens with everything similarly:</p>

<blockquote>
  <p>Error from server (BadRequest): error when creating "test-pod.yaml": Pod in version "v1" cannot be handled as a Pod: [pos 222]: json: expect char '"' but got char 't'</p>
</blockquote>

<p>Substitute "Deployment" or "ReplicationController" for "Pod" and it's the same error everywhere. Here is my yaml file for the test pod:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    ingress: yes
</code></pre>

<p>If I remove the nodeSelector part of the file, the pod builds successfully. This also works with Deployments and Replication Controllers as well. I made sure that the proper label was added to the node.</p>

<p>Any help would be appreciated!</p>

<p>In yaml, the token <code>yes</code> evaluates to a boolean <code>true</code> (<a href="http://yaml.org/type/bool.html" rel="nofollow noreferrer">http://yaml.org/type/bool.html</a>)</p>

<p>Internally, <code>kubectl</code> converts yaml to json as a preprocessing step. Your node selector is converting to <code>"nodeSelector":{"ingress":true}</code>, which fails when trying to decode into a string-to-string map.</p>

<p>You can quote the string like this to force it to be treated as a string: 
<code>ingress: "yes"</code></p>
