Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
zugao committed Jan 6, 2022
1 parent 1b84e83 commit b33ab28
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 8 deletions.
5 changes: 3 additions & 2 deletions class/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
parameters:
openshift4_keepalived:
=_metadata: {}
namespace: syn-openshift4-keepalived
namespace: openshift-operator-community
channel: alpha
keepalived_groups: {}
30 changes: 29 additions & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
// main template for openshift4-keepalived
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;

// Define outputs below
local keepalived_groups = std.filter(
function(it) it != null,
[
local formated_name = kube.hyphenate(keepalived_object);
local keepalived_group = params.keepalived_groups[keepalived_object];
if keepalived_group != null then
kube._Object('redhatcop.redhat.io/v1alpha1', 'KeepalivedGroup', formated_name) {
metadata+: {
namespace: params.namespace,
},
} + com.makeMergeable(keepalived_group)
for keepalived_object in std.objectFields(params.keepalived_groups)
]
);

{
'00_operator_group': operatorlib.OperatorGroup('cluster-keepalived') {
metadata+: {
namespace: params.namespace,
},
},
'10_subscription': operatorlib.namespacedSubscription(
params.namespace,
'keepalived-operator',
params.channel,
'community-operators'
),
[if std.length(keepalived_groups) > 0 then '20_keepalived_groups']: keepalived_groups,
}
46 changes: 44 additions & 2 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,56 @@ The parent key for all of the following parameters is `openshift4_keepalived`.

[horizontal]
type:: string
default:: `syn-openshift4-keepalived`
default:: `openshift-operator-community`

The namespace in which to deploy this component.

== `channel`

[horizontal]
type:: string
default:: `alpha`

The channel from where the operator should be fetched.

== `keepalived_groups`

[horizontal]
type:: object
default:: `{}`

A dictionary holding the .spec for keepalived groups. The keys of the dict are used as names for the keepalived groups.

See the https://github.com/redhat-cop/keepalived-operator#how-it-works[Keepalived Operator docs] for available parameters.

To remove all keepalived groups, set to null.

== Example

[source,yaml]
----
namespace: example-namespace
parameters:
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: ""
blacklistRouterIDs:
- 1
- 2
group_2:
spec:
image: registry.redhat.io/openshift4/ose-keepalived-ipfailover
interface: ens4
nodeSelector:
node-role.kubernetes.io/nodeport: ""
blacklistRouterIDs:
- 3
- 4
group_3: null
----
39 changes: 36 additions & 3 deletions tests/defaults.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# Overwrite parameters here

# parameters: {...}
applications:
- openshift4-operators as openshift-operators-redhat
parameters:
openshift4_operators:
namespace: openshift-operators-redhat
defaultInstallPlanApproval: Automatic
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: ""
blacklistRouterIDs:
- 1
- 2
group_2:
spec:
image: registry.redhat.io/openshift4/ose-keepalived-ipfailover
interface: ens4
nodeSelector:
node-role.kubernetes.io/nodeport: ""
blacklistRouterIDs:
- 3
- 4
group_3: null
kapitan:
dependencies:
- type: https
source: https://raw.githubusercontent.com/appuio/component-openshift4-operators/master/lib/openshift4-operators.libsonnet
output_path: vendor/lib/openshift4-operators.libsonnet

0 comments on commit b33ab28

Please sign in to comment.