From 148fdcc935e3ea1cbb425a721213439b9704033c Mon Sep 17 00:00:00 2001 From: Gabriel Saratura Date: Tue, 11 Jan 2022 12:16:31 +0200 Subject: [PATCH 1/4] Added tests --- tests/defaults.yml | 5 +-- .../00_operator_group.yaml | 8 +++++ .../10_subscription.yaml | 14 ++++++++ .../20_keepalived_groups.yaml | 33 +++++++++++++++++++ 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/00_operator_group.yaml create mode 100644 tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/10_subscription.yaml create mode 100644 tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/20_keepalived_groups.yaml diff --git a/tests/defaults.yml b/tests/defaults.yml index eaacd6a..85426f8 100644 --- a/tests/defaults.yml +++ b/tests/defaults.yml @@ -7,12 +7,9 @@ parameters: defaultSourceNamespace: openshift-marketplace defaultSource: redhat-operators openshift4_keepalived: - namespace: openshift-operator-community - channel: alpha keepalived_groups: group_1: spec: - image: registry.redhat.io/openshift4/ose-keepalived-ipfailover interface: ens3 nodeSelector: node-role.kubernetes.io/loadbalancer: "" @@ -21,7 +18,7 @@ parameters: - 2 group_2: spec: - image: registry.redhat.io/openshift4/ose-keepalived-ipfailover + image: registry.redhat.io/openshift4/ose-keepalived-ipfailover:latest interface: ens4 nodeSelector: node-role.kubernetes.io/nodeport: "" diff --git a/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/00_operator_group.yaml b/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/00_operator_group.yaml new file mode 100644 index 0000000..bbf77e8 --- /dev/null +++ b/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/00_operator_group.yaml @@ -0,0 +1,8 @@ +apiVersion: operators.coreos.com/v1 +kind: OperatorGroup +metadata: + annotations: {} + labels: + name: cluster-keepalived + name: cluster-keepalived + namespace: openshift-keepalived-operator diff --git a/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/10_subscription.yaml b/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/10_subscription.yaml new file mode 100644 index 0000000..3ac9ce5 --- /dev/null +++ b/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/10_subscription.yaml @@ -0,0 +1,14 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: Subscription +metadata: + annotations: {} + labels: + name: keepalived-operator + name: keepalived-operator + namespace: openshift-keepalived-operator +spec: + channel: alpha + installPlanApproval: Automatic + name: keepalived-operator + source: community-operators + sourceNamespace: openshift-marketplace diff --git a/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/20_keepalived_groups.yaml b/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/20_keepalived_groups.yaml new file mode 100644 index 0000000..4f18183 --- /dev/null +++ b/tests/golden/defaults/openshift4-keepalived/openshift4-keepalived/20_keepalived_groups.yaml @@ -0,0 +1,33 @@ +apiVersion: redhatcop.redhat.io/v1alpha1 +kind: KeepalivedGroup +metadata: + annotations: {} + labels: + name: group-1 + name: group-1 + namespace: openshift-keepalived-operator +spec: + blacklistRouterIDs: + - 1 + - 2 + image: registry.redhat.io/openshift4/ose-keepalived-ipfailover:v4.9 + interface: ens3 + nodeSelector: + node-role.kubernetes.io/loadbalancer: '' +--- +apiVersion: redhatcop.redhat.io/v1alpha1 +kind: KeepalivedGroup +metadata: + annotations: {} + labels: + name: group-2 + name: group-2 + namespace: openshift-keepalived-operator +spec: + blacklistRouterIDs: + - 3 + - 4 + image: registry.redhat.io/openshift4/ose-keepalived-ipfailover:latest + interface: ens4 + nodeSelector: + node-role.kubernetes.io/nodeport: '' From f4f0c819c2cfa41067691bb13e468aa256a1684f Mon Sep 17 00:00:00 2001 From: Gabriel Saratura Date: Tue, 11 Jan 2022 12:17:52 +0200 Subject: [PATCH 2/4] Added openshift_version default parameter --- class/defaults.yml | 1 + component/main.jsonnet | 8 ++++++-- docs/modules/ROOT/pages/references/parameters.adoc | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/class/defaults.yml b/class/defaults.yml index 919ab2e..2c2fbf7 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -2,4 +2,5 @@ parameters: openshift4_keepalived: namespace: openshift-operator-community channel: alpha + openshift_version: '4.9' keepalived_groups: {} diff --git a/component/main.jsonnet b/component/main.jsonnet index 9cfeeef..c7279af 100644 --- a/component/main.jsonnet +++ b/component/main.jsonnet @@ -1,11 +1,12 @@ // main template for openshift4-keepalived +local com = import 'lib/commodore.libjsonnet'; local kap = import 'lib/kapitan.libjsonnet'; local kube = import 'lib/kube.libjsonnet'; -local com = import 'lib/commodore.libjsonnet'; local operatorlib = import 'lib/openshift4-operators.libsonnet'; local inv = kap.inventory(); // The hiera parameters for the component local params = inv.parameters.openshift4_keepalived; +local image = 'registry.redhat.io/openshift4/ose-keepalived-ipfailover:v' + params.openshift_version; local keepalived_groups = std.filter( function(it) it != null, @@ -17,6 +18,9 @@ local keepalived_groups = std.filter( metadata+: { namespace: params.namespace, }, + spec+: { + image: image, + }, } + com.makeMergeable(keepalived_group) for keepalived_object in std.objectFields(params.keepalived_groups) ] @@ -33,6 +37,6 @@ local keepalived_groups = std.filter( 'keepalived-operator', params.channel, 'community-operators' - ), + ), [if std.length(keepalived_groups) > 0 then '20_keepalived_groups']: keepalived_groups, } diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index da9e6c4..110f7c9 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -18,6 +18,14 @@ default:: `alpha` The channel from where the operator should be fetched. +== `openshift_version` + +[horizontal] +type:: string +default:: `4.9` + +The openshift version which will be used as the image tag in KeepalivedGroup CRD. + == `keepalived_groups` [horizontal] From a1491e0d2021f2c0f09329aaa6b352cb028705eb Mon Sep 17 00:00:00 2001 From: Gabriel Saratura Date: Tue, 11 Jan 2022 12:18:18 +0200 Subject: [PATCH 3/4] Changed default namespace parameter --- class/defaults.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/defaults.yml b/class/defaults.yml index 2c2fbf7..29b3927 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -1,6 +1,6 @@ parameters: openshift4_keepalived: - namespace: openshift-operator-community + namespace: openshift-keepalived-operator channel: alpha openshift_version: '4.9' keepalived_groups: {} From 97ca8cc907ecc0985ac4d1eb2da9040c1506395d Mon Sep 17 00:00:00 2001 From: Gabriel Saratura <58511627+ZuGao@users.noreply.github.com> Date: Tue, 11 Jan 2022 12:20:17 +0200 Subject: [PATCH 4/4] Updated openshift_version parameter documentation Co-authored-by: Tobias Nehrlich --- docs/modules/ROOT/pages/references/parameters.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index 110f7c9..8d1ce29 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -24,7 +24,7 @@ The channel from where the operator should be fetched. type:: string default:: `4.9` -The openshift version which will be used as the image tag in KeepalivedGroup CRD. +The OpenShift version used to set the corresesponding image tag for the KeepalivedGroup(s). == `keepalived_groups`