Skip to content

Commit

Permalink
Merge pull request #1 from appuio/feature/customize-component
Browse files Browse the repository at this point in the history
Added tests, default image and changed default namespace
  • Loading branch information
zugao authored Jan 14, 2022
2 parents b33ab28 + 97ca8cc commit 91735cc
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 7 deletions.
3 changes: 2 additions & 1 deletion class/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
openshift4_keepalived:
namespace: openshift-operator-community
namespace: openshift-keepalived-operator
channel: alpha
openshift_version: '4.9'
keepalived_groups: {}
8 changes: 6 additions & 2 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)
]
Expand All @@ -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,
}
8 changes: 8 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 used to set the corresesponding image tag for the KeepalivedGroup(s).

== `keepalived_groups`

[horizontal]
Expand Down
5 changes: 1 addition & 4 deletions tests/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand All @@ -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: ""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
annotations: {}
labels:
name: cluster-keepalived
name: cluster-keepalived
namespace: openshift-keepalived-operator
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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: ''

0 comments on commit 91735cc

Please sign in to comment.