Skip to content

Commit

Permalink
Merge pull request #39 from appuio/support-oke
Browse files Browse the repository at this point in the history
Only configure default node affinity to infra nodes for OCP
  • Loading branch information
simu committed May 15, 2024
2 parents ca702ed + 17ea1ca commit 08bca9e
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"template": "https://github.com/projectsyn/commodore-component-template.git",
"commit": "a4aff6a9d004c1aad085a875c7759c8f8f1e0d3d",
"commit": "b5c430d9f4b4a4542f8ee6debf5f06d8c6a98374",
"checkout": "main",
"context": {
"cookiecutter": {
"name": "openshift4-operators",
"slug": "openshift4-operators",
"parameter_key": "openshift4_operators",
"test_cases": "openshift-operators-redhat openshift-operators openshift-operators-custom operator-subscription affinity-override",
"test_cases": "openshift-operators-redhat openshift-operators openshift-operators-custom operator-subscription affinity-override operator-subscription-oke",
"add_lib": "y",
"add_pp": "n",
"add_golden": "y",
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- openshift-operators-custom
- operator-subscription
- affinity-override
- operator-subscription-oke
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
Expand All @@ -56,6 +57,7 @@ jobs:
- openshift-operators-custom
- operator-subscription
- affinity-override
- operator-subscription-oke
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile.vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ KUBENT_IMAGE ?= ghcr.io/doitintl/kube-no-trouble:latest
KUBENT_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) $(root_volume) --entrypoint=/app/kubent $(KUBENT_IMAGE)

instance ?= openshift-operators-redhat
test_instances = tests/openshift-operators-redhat.yml tests/openshift-operators.yml tests/openshift-operators-custom.yml tests/operator-subscription.yml tests/affinity-override.yml
test_instances = tests/openshift-operators-redhat.yml tests/openshift-operators.yml tests/openshift-operators-custom.yml tests/operator-subscription.yml tests/affinity-override.yml tests/operator-subscription-oke.yml
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
@@ -0,0 +1,34 @@
apiVersion: v1
kind: Namespace
metadata:
annotations:
openshift.io/node-selector: ''
labels:
name: operator-subscription-oke
openshift.io/cluster-monitoring: 'false'
openshift.io/user-monitoring: 'false'
name: operator-subscription-oke
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
annotations: {}
labels:
name: operator-subscription-oke
name: operator-subscription-oke
namespace: operator-subscription-oke
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
annotations: {}
labels:
name: foo
name: foo
namespace: operator-subscription-oke
spec:
channel: stable
installPlanApproval: Manual
name: foo
source: certified-operators
sourceNamespace: openshift-marketplace
14 changes: 14 additions & 0 deletions tests/operator-subscription-oke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
applications:
- openshift4-operators as operator-subscription-oke

parameters:
facts:
distribution: oke

operator_subscription_oke:
useCustomNamespace: true
subscription:
name: foo
channel: stable
spec:
installPlanApproval: Manual
3 changes: 3 additions & 0 deletions tests/operator-subscription.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ applications:
- openshift4-operators as operator-subscription

parameters:
facts:
distribution: openshift4

operator_subscription:
useCustomNamespace: true
subscription:
Expand Down

0 comments on commit 08bca9e

Please sign in to comment.