{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/12862","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/12862/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/12862/comments","events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/12862/events","html_url":"https://github.com/kubernetes/kubernetes/issues/12862","id":101692094,"number":12862,"title":"Add a nodeSelector field to your pod configuration","user":{"login":"preillyme","id":51323,"avatar_url":"https://avatars.githubusercontent.com/u/51323?v=3","gravatar_id":"","url":"https://api.github.com/users/preillyme","html_url":"https://github.com/preillyme","followers_url":"https://api.github.com/users/preillyme/followers","following_url":"https://api.github.com/users/preillyme/following{/other_user}","gists_url":"https://api.github.com/users/preillyme/gists{/gist_id}","starred_url":"https://api.github.com/users/preillyme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/preillyme/subscriptions","organizations_url":"https://api.github.com/users/preillyme/orgs","repos_url":"https://api.github.com/users/preillyme/repos","events_url":"https://api.github.com/users/preillyme/events{/privacy}","received_events_url":"https://api.github.com/users/preillyme/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/kind/support","name":"kind/support","color":"eb6420"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/team/control-plane","name":"team/control-plane","color":"d2b48c"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/team/ux","name":"team/ux","color":"d2b48c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-18T16:11:28Z","updated_at":"2015-08-18T19:01:23Z","closed_at":null,"body":"We're having an issue getting nodeSelector to work as expected.\r\n\r\nWe'd like to have a pod run on a specific node. We've given each node a \"name\" label then used that in the pod spec but the pod is *not running* on the node matching the label.\r\n\r\n```\r\n# List running nodes\r\ndocker run -it --rm --volumes-from data levenson/kubectl get nodes\r\nNAME           LABELS                                            STATUS\r\n10.161.34.62   kubernetes.io/hostname=10.161.34.62               Ready\r\n10.161.34.65   kubernetes.io/hostname=10.161.34.65               Ready\r\n10.161.34.70   kubernetes.io/hostname=10.161.34.70               Ready\r\n\r\n\r\n# Label nodes with name key\r\ndocker run -it --rm --volumes-from data levenson/kubectl label nodes 10.161.34.62 name=node-1\r\ndocker run -it --rm --volumes-from data levenson/kubectl label nodes 10.161.34.65 name=node-2\r\ndocker run -it --rm --volumes-from data levenson/kubectl label nodes 10.161.34.70 name=node-3\r\n\r\n# Confirm labels applied to nodes\r\ndocker run -it --rm --volumes-from data levenson/kubectl get nodes\r\nNAME           LABELS                                            STATUS\r\n10.161.34.62   kubernetes.io/hostname=10.161.34.62,name=node-1   Ready\r\n10.161.34.65   kubernetes.io/hostname=10.161.34.65,name=node-2   Ready\r\n10.161.34.70   kubernetes.io/hostname=10.161.34.70,name=node-3   Ready\r\n\r\n# Create kafka-1 list,svc,pod.\r\ndocker run -it --rm --volumes-from data levenson/kubectl create -f /data/kafka-1.json\r\n\r\n{\r\n  \"kind\": \"List\",\r\n  \"apiVersion\": \"v1\",\r\n  \"id\": \"kafka\",\r\n  \"items\":[\r\n    {\r\n      \"kind\": \"Service\",\r\n      \"apiVersion\": \"v1\",\r\n      \"metadata\": {\r\n        \"name\": \"kafka-1\",\r\n        \"namespace\": \"realtime\",\r\n        \"labels\": {\r\n          \"name\": \"kafa-1\"\r\n        }\r\n      },\r\n      \"spec\": {\r\n        \"ports\": [\r\n          {\r\n            \"name\": \"service\",\r\n            \"port\": 9092,\r\n            \"targetPort\": 9092\r\n          },\r\n          {\r\n            \"name\": \"jmx\",\r\n            \"port\": 7203,\r\n            \"targetPort\": 7203\r\n          }\r\n        ],\r\n        \"selector\": {\r\n          \"server-id\": \"1\"\r\n        }\r\n      }\r\n    },\r\n    {\r\n      \"kind\": \"Pod\",\r\n      \"apiVersion\": \"v1\",\r\n      \"nodeSelector\": {\r\n          \"name\": \"node-1\"\r\n      },\r\n      \"metadata\": {\r\n        \"name\": \"kafka-1\",\r\n        \"namespace\": \"realtime\",\r\n        \"labels\": {\r\n          \"name\": \"kafka\",\r\n          \"server-id\": \"1\"\r\n        }\r\n      },\r\n      \"spec\": {\r\n        \"containers\": [\r\n          {\r\n            \"name\": \"server\",\r\n            \"image\": \"levenson/k8s-kafka\",\r\n            \"env\":[\r\n              { \"name\": \"KAFKA_SERVER_ID\", \"value\": \"1\" },\r\n              { \"name\": \"KAFKA_CLIENT_1_SERVICE_HOST\", \"value\": \"kafka-1.realtime.svc.kubernetes.io\" },\r\n              { \"name\": \"KAFKA_CLIENT_1_SERVICE_PORT\", \"value\": \"9093\" },\r\n              { \"name\": \"ZK_CLIENT_1_SERVICE_HOST\", \"value\": \"zookeeper.realtime.svc.kubernetes.io\" },\r\n              { \"name\": \"ZK_CLIENT_1_SERVICE_PORT\", \"value\": \"2181\" }\r\n            ],\r\n            \"volumeMounts\": [\r\n              {\r\n                \"name\": \"kafka-1-data\",\r\n                \"mountPath\": \"/data/\"\r\n              }\r\n            ],\r\n            \"ports\":[\r\n              {\r\n                \"containerPort\": 9092\r\n              },\r\n              {\r\n                \"containerPort\": 7203\r\n              }\r\n            ]\r\n          }\r\n        ],\r\n        \"volumes\": [\r\n          {\r\n            \"name\": \"kafka-1-data\",\r\n            \"hostPath\": {\r\n              \"path\": \"/data/kafka-1/data\"\r\n            }\r\n          }\r\n        ]\r\n      }\r\n    }\r\n  ]\r\n}\r\n\r\n# Confirm kafka-1 is running on node with label name=node-1 -- No it's running on node labelled name=node-2\r\ndocker run -it --rm --volumes-from data levenson/kubectl get pods kafka-1 -o wide --namespace=realtime\r\nNAME      READY     STATUS    RESTARTS   AGE       NODE\r\nkafka-1   1/1       Running   0          1h        10.161.34.65\r\n```\r\n\r\n/cc @lachie83"},"comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments/132319365","html_url":"https://github.com/kubernetes/kubernetes/issues/12862#issuecomment-132319365","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/12862","id":132319365,"user":{"login":"preillyme","id":51323,"avatar_url":"https://avatars.githubusercontent.com/u/51323?v=3","gravatar_id":"","url":"https://api.github.com/users/preillyme","html_url":"https://github.com/preillyme","followers_url":"https://api.github.com/users/preillyme/followers","following_url":"https://api.github.com/users/preillyme/following{/other_user}","gists_url":"https://api.github.com/users/preillyme/gists{/gist_id}","starred_url":"https://api.github.com/users/preillyme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/preillyme/subscriptions","organizations_url":"https://api.github.com/users/preillyme/orgs","repos_url":"https://api.github.com/users/preillyme/repos","events_url":"https://api.github.com/users/preillyme/events{/privacy}","received_events_url":"https://api.github.com/users/preillyme/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T19:01:22Z","updated_at":"2015-08-18T19:01:22Z","body":"Thanks @roberthbailey "}}