Skip to content

Commit

Permalink
Don't take over ownership of OpenShift-managed namespace `openshift-o…
Browse files Browse the repository at this point in the history
…perators`
  • Loading branch information
simu committed Mar 8, 2023
1 parent 607470a commit ef328cf
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 37 deletions.
52 changes: 32 additions & 20 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,44 @@
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local operatorlib = import 'lib/openshift4-operators.libsonnet';
local po = import 'lib/patch-operator.libsonnet';

local inv = kap.inventory();
local params = inv.parameters.openshift4_operators;


local namespace = operatorlib.validateInstance(params.namespace);

{
[namespace]: [
kube.Namespace(namespace) {
metadata+: {
annotations+: std.prune(params.namespaceAnnotations),
labels+: {
// enable cluster monitoring when instantiating to manage
// namespace openshift-operators-redhat
'openshift.io/cluster-monitoring':
'%s' % [ namespace == 'openshift-operators-redhat' ],
// ignore namespace by user-workload monitoring
'openshift.io/user-monitoring': 'false',
},
},
local nsmeta = {
metadata+: {
annotations+: std.prune(params.namespaceAnnotations),
labels+: {
// enable cluster monitoring when instantiating to manage
// namespace openshift-operators-redhat
'openshift.io/cluster-monitoring':
'%s' % [ namespace == 'openshift-operators-redhat' ],
// ignore namespace by user-workload monitoring
'openshift.io/user-monitoring': 'false',
},
// Create cluster-scoped OperatorGroup
operatorlib.OperatorGroup(namespace) {
metadata+: {
namespace: namespace,
},
},
};
local ns = kube.Namespace(namespace) + nsmeta;

local operatorgroup =
// Create cluster-scoped OperatorGroup
operatorlib.OperatorGroup(namespace) {
metadata+: {
namespace: namespace,
},
],
};

local nspatch = po.Patch(ns, nsmeta);

{
[namespace]:
if namespace != 'openshift-operators' then [
ns,
operatorgroup,
]
else nspatch,
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
apiVersion: v1
kind: Namespace
apiVersion: redhatcop.redhat.io/v1alpha1
kind: Patch
metadata:
annotations:
openshift.io/node-selector: node-role.kubernetes.io/infra=
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
labels:
name: openshift-operators
openshift.io/cluster-monitoring: 'false'
openshift.io/user-monitoring: 'false'
name: openshift-operators
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
annotations: {}
labels:
name: openshift-operators
name: openshift-operators
namespace: openshift-operators
name: namespace-openshift-operators-29c692296e708c9
name: namespace-openshift-operators-29c692296e708c9
namespace: syn-patch-operator
spec:
patches:
namespace-openshift-operators-29c692296e708c9-patch:
patchTemplate: |-
"metadata":
"annotations":
"openshift.io/node-selector": "node-role.kubernetes.io/infra="
"labels":
"openshift.io/cluster-monitoring": "false"
"openshift.io/user-monitoring": "false"
patchType: application/strategic-merge-patch+json
targetObjectRef:
apiVersion: v1
kind: Namespace
name: openshift-operators
serviceAccountRef:
name: patch-sa
12 changes: 11 additions & 1 deletion tests/openshift-operators.yml
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
parameters: {}
parameters:
kapitan:
dependencies:
- type: https
source: https://raw.githubusercontent.com/projectsyn/component-patch-operator/v1.1.0/lib/patch-operator.libsonnet
output_path: vendor/lib/patch-operator.libsonnet

patch_operator:
namespace: syn-patch-operator
patch_serviceaccount:
name: patch-sa

0 comments on commit ef328cf

Please sign in to comment.