Skip to content

Commit

Permalink
Allow use of custom namespace names for component
Browse files Browse the repository at this point in the history
  • Loading branch information
Aline Abler committed Mar 6, 2023
1 parent f380e8d commit b8702d5
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
instance:
- openshift-operators-redhat
- openshift-operators
- openshift-operators-custom
defaults:
run:
working-directory: ${{ env.COMPONENT_NAME }}
Expand All @@ -50,6 +51,7 @@ jobs:
instance:
- openshift-operators-redhat
- openshift-operators
- openshift-operators-custom
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
test_instances = tests/openshift-operators-redhat.yml tests/openshift-operators.yml tests/openshift-operators-custom.yml
1 change: 1 addition & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ parameters:
openshift.io/node-selector: node-role.kubernetes.io/infra=
defaultInstallPlanApproval: Automatic
defaultSourceNamespace: openshift-marketplace
useCustomNamespace: false

monitoring:
enabled: true
Expand Down
11 changes: 10 additions & 1 deletion docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type:: string
default:: `${_instance}`

The namespace to create for the component instance.
The component is implemented in such a way that only instances (and therefore namespaces) `openshift-operators` and `openshift-operators-redhat` can be created.
The component is implemented in such a way that only instances (and therefore namespaces) `openshift-operators` and `openshift-operators-redhat` can be created, unless `useCustomNamespace` is set to `true`.
Generally, it shouldn't be necessary to override this parameter.

== `namespaceAnnotations`
Expand Down Expand Up @@ -63,6 +63,15 @@ The component defaults to `certified-operators` for instance `openshift-operator
This source provides community-maintained operators which are certified by RedHat.
Alternatively, you can use `community-operators` for other community-maintained operators.

== `useCustomNamespace`

[horizontal]
type:: boolean
default:: `false`

Whether to allow non-standard namespace names for the OperatorGroup.
If this parameter is set to `true`, the component will allow using namespace names other than `openshift-operators` and `openshift-operators-redhat`.

== `monitoring`

This parameter allows users to enable the component's monitoring configuration.
Expand Down
4 changes: 3 additions & 1 deletion lib/openshift4-operators.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ local validateInstance(instance, checkTargets=false, checkSource='') =
'openshift-operators-redhat',
]);

local use_custom_namespace = instanceParams(instance).useCustomNamespace;

assert
std.setMember(instance, supported_instances) :
use_custom_namespace || std.setMember(instance, supported_instances) :
"\n Invalid instance '%s' for component openshift4-operators." % [
instance,
] +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
apiVersion: v1
kind: Namespace
metadata:
annotations: {}
labels:
monitoring.syn.tools/infra: 'true'
name: syn-monitoring-openshift4-operators
name: syn-monitoring-openshift4-operators
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
name: openshift-marketplace-operator
name: openshift-marketplace-operator
namespace: syn-monitoring-openshift4-operators
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
interval: 30s
metricRelabelings:
- action: drop
regex: etcd_(debugging|disk|request|server).*
sourceLabels:
- __name__
- action: drop
regex: (go_.*|process_.*|promhttp_.*)
sourceLabels:
- __name__
port: https-metrics
scheme: https
tlsConfig:
caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
serverName: marketplace-operator-metrics.openshift-marketplace.svc
namespaceSelector:
matchNames:
- openshift-marketplace
selector:
matchLabels:
name: marketplace-operator
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
name: openshift-catalog-operator
name: openshift-catalog-operator
namespace: syn-monitoring-openshift4-operators
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
interval: 30s
metricRelabelings:
- action: drop
regex: etcd_(debugging|disk|request|server).*
sourceLabels:
- __name__
- action: drop
regex: (go_.*|process_.*|promhttp_.*)
sourceLabels:
- __name__
port: https-metrics
scheme: https
tlsConfig:
caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
serverName: catalog-operator-metrics.openshift-operator-lifecycle-manager.svc
namespaceSelector:
matchNames:
- openshift-operator-lifecycle-manager
selector:
matchLabels:
app: catalog-operator
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
name: openshift-olm-operator
name: openshift-olm-operator
namespace: syn-monitoring-openshift4-operators
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
interval: 30s
metricRelabelings:
- action: drop
regex: etcd_(debugging|disk|request|server).*
sourceLabels:
- __name__
- action: drop
regex: (go_.*|process_.*|promhttp_.*)
sourceLabels:
- __name__
port: https-metrics
scheme: https
tlsConfig:
caFile: /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
serverName: olm-operator-metrics.openshift-operator-lifecycle-manager.svc
namespaceSelector:
matchNames:
- openshift-operator-lifecycle-manager
selector:
matchLabels:
app: olm-operator
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Namespace
metadata:
annotations:
openshift.io/node-selector: node-role.kubernetes.io/infra=
labels:
name: openshift-operators-custom
openshift.io/cluster-monitoring: 'false'
openshift.io/user-monitoring: 'false'
name: openshift-operators-custom
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
annotations: {}
labels:
name: openshift-operators-custom
name: openshift-operators-custom
namespace: openshift-operators-custom
15 changes: 15 additions & 0 deletions tests/openshift-operators-custom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
applications:
- prometheus

parameters:
kapitan:
dependencies:
- type: https
source: https://raw.githubusercontent.com/projectsyn/component-prometheus/master/lib/prometheus.libsonnet
output_path: vendor/lib/prometheus.libsonnet

prometheus:
defaultInstance: infra

openshift_operators_custom:
useCustomNamespace: true

0 comments on commit b8702d5

Please sign in to comment.