As an administrator, you can customize and improve control of the pod scheduling process.
You can constrain a pod so that it is restricted or preferred to run on particular
nodes.
About this task
You can restrict or prefer the pods to run on specific nodes by using
nodeAffinity
, podAffinity
, or podAntiAffinity
methods. For more information, see Assigning Pods to Nodes.
Procedure
- In the Red Hat® OpenShift® web console, from the side
navigation menu, click
and locate the custom resource that you want to customize.
- Click Instances and open the instance of
the custom resource that you want to work on.
- Click the YAML tab to open the
editor.
- If the
podTemplates
field does not exist, add
the podTemplates
field inside the spec
property.
- Add or change the pod entry according to your
requirement.
For example in the following sample code,
admin-dashboard
is the pod entry that is edited.
- Add the field
affinity
inside of which you can add
nodeAffinity
, podAffnitiy
, and podAntiAffinity
according to your requirements.
kind: Suite
apiVersion: core.mas.ibm.com/v1
metadata:
name: inst1
namespace: mas-inst1-core
labels:
mas.ibm.com/instanceId: inst1
spec:
podTemplates:
- name: admin-dashboard
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: runtimeType
operator: In
values:
- frontend
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: security
operator: In
values:
- S1
topologyKey: topology.kubernetes.io/zone
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: security
operator: In
values:
- S2
topologyKey: topology.kubernetes.io/zone
- Click Save. Wait for the operator to reconcile and apply your
changes.