Skip to content

Commit

Permalink
Only configure default node affinity to infra nodes for OCP
Browse files Browse the repository at this point in the history
  • Loading branch information
simu committed May 15, 2024
1 parent ca702ed commit 58679b4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/references/component-library.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This function creates a `subscriptions.operators.coreos.com` resource in a names

The result of this function can be used in the same way as resources created by `kube.libjsonnet`.

By default the components sets the nodeAffinity to infra nodes, this can be overwritten.
By default, if `facts.distribution` is set to `openshift4`, the component sets the nodeAffinity to infra nodes, this can be overwritten.
See https://docs.openshift.com/container-platform/latest/nodes/scheduling/nodes-scheduler-node-affinity.html#nodes-scheduler-node-affinity-configuring-required_nodes-scheduler-node-affinity[Official Documentation]

--
Expand Down
5 changes: 4 additions & 1 deletion lib/openshift4-operators.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ local instanceParams(instance) =

local apigroup = 'operators.coreos.com';

local is_ocp =
std.get(inv.parameters.facts, 'distribution', '') == 'openshift4';

/**
* \brief Validate instance
*
Expand Down Expand Up @@ -66,7 +69,7 @@ local subscription(name) =
kube._Object(apigroup + '/v1alpha1', 'Subscription', name) {
spec: {
name: name,
config: {
[if is_ocp then 'config']: {
affinity: {
nodeAffinity: {
requiredDuringSchedulingIgnoredDuringExecution: {
Expand Down
3 changes: 3 additions & 0 deletions tests/affinity-override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ applications:
- openshift4-operators as affinity-override

parameters:
facts:
distribution: openshift4

affinity_override:
useCustomNamespace: true
subscription:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ metadata:
namespace: operator-subscription
spec:
channel: stable
config:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/infra
operator: Exists
installPlanApproval: Manual
name: foo
source: certified-operators
Expand Down
4 changes: 3 additions & 1 deletion tests/openshift-operators-redhat.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
parameters: {}
parameters:
facts:
distribution: openshift4

0 comments on commit 58679b4

Please sign in to comment.