Skip to content

Instantly share code, notes, and snippets.

@elsonrodriguez
Last active March 29, 2016 16:08
Show Gist options
  • Save elsonrodriguez/60e53e2479dc3146447b to your computer and use it in GitHub Desktop.
Save elsonrodriguez/60e53e2479dc3146447b to your computer and use it in GitHub Desktop.
Quick and dirty node selection

Quick and Dirty Node Selection

So first, let's create our pod.

$ kubectl create -f https://gist.githubusercontent.com/elsonrodriguez/60e53e2479dc3146447b/raw/3b4d703855500c829ae58d70e386b4e41e4f7996/pod.yaml
pod "gputest" created

Now let's see it go:

$ kubectl get pod gputest
NAME      READY     STATUS    RESTARTS   AGE
gputest   0/1       Pending   0          17s

Well, it didn't go. Why?

$ kubectl describe pod gputest
....
Events:
  FirstSeen	LastSeen	Count	From			SubobjectPath	Type		Reason			Message
  ---------	--------	-----	----			-------------	--------	------			-------
  37s		22s		4	{default-scheduler }			Warning		FailedScheduling	pod (gputest) failed to fit in any node
fit failure on node (ip-172-20-0-16.us-west-1.compute.internal): MatchNodeSelector
fit failure on node (ip-172-20-0-14.us-west-1.compute.internal): MatchNodeSelector
fit failure on node (ip-172-20-0-15.us-west-1.compute.internal): MatchNodeSelector

No node matches the nodeSelector! Let's label a node. (replace $nodename with a node, use kubectl get nodes to see nodes)

$ kubectl label node $nodename gpu=true

Now let's see:

$ kubectl get pods gputest
NAME      READY     STATUS    RESTARTS   AGE
gputest   1/1       Running   0          2m

Success!

apiVersion: v1
kind: Pod
metadata:
name: gputest
labels:
app: gputest
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
resources:
limits:
memory: "256Mi"
cpu: ".5"
nodeSelector:
gpu: "true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment