Member-only story

Forcing Pods To Run On A Particular Node in OpenShift 3.11

Vinayak Pandey
Nov 13, 2020

In this post,we’ll see how we can force a pod to run on a particualt node in OpenShift 3.11.

Step 1: Add a taint to the node where you want your pods to be running.

oc adm taint nodes <nodename> app=latest:NoSchedule

Step 2: Add a label to the node where you want your pods to be running.

oc label nodes <nodename> app=latest

Step 3: Now go to the project and edit the DeploymentConfig to use taints and node affinity.

oc project <project_name>

oc edit dc <dc_name>

Now under spec.template.spec section, add following lines

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: app
operator: In
values:
- latest
tolerations:
- effect: NoSchedule
key: app
operator: Equal
value: latest

Now check your pods using oc get pods -o wide -w command and you’ll see that your pods are getting created under designated node.

--

--

Vinayak Pandey
Vinayak Pandey

Written by Vinayak Pandey

Experienced Cloud Engineer with a knack of automation. Linkedin profile: https://www.linkedin.com/in/vinayakpandeyit/

No responses yet