From ed1a91c941ece2d0803d9f043b4ed0c52b4bc824 Mon Sep 17 00:00:00 2001 From: Fabian Fischer Date: Fri, 30 Jun 2023 11:26:14 +0200 Subject: [PATCH] Add option to define namespace labels and annotations This gives us some flexibilty and can be helpful in multiple situations. The main usecase currently is that we can schedule crossplane on infra nodes on OpenShift using the annotation `openshift.io/node-selector` --- class/defaults.yml | 3 +++ component/main.jsonnet | 7 ++++++- .../ROOT/pages/references/parameters.adoc | 16 ++++++++++++++++ .../crossplane/crossplane/00_namespace.yaml | 4 +++- tests/openshift4.yml | 6 +++++- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/class/defaults.yml b/class/defaults.yml index 45edae9..4f4bdef 100644 --- a/class/defaults.yml +++ b/class/defaults.yml @@ -1,6 +1,9 @@ parameters: crossplane: namespace: syn-crossplane + namespaceLabels: {} + namespaceAnnotations: {} + charts: crossplane: 1.11.0 images: diff --git a/component/main.jsonnet b/component/main.jsonnet index 79d3020..c9e1036 100644 --- a/component/main.jsonnet +++ b/component/main.jsonnet @@ -112,7 +112,12 @@ local namespace = ; { - '00_namespace': namespace, + '00_namespace': namespace { + metadata+: { + labels+: params.namespaceLabels, + annotations+: params.namespaceAnnotations, + }, + }, '01_rbac_finalizer_clusterrole': rbacFinalizerRole, '01_rbac_finalizer_clusterrolebinding': rbacFinalizerRoleBinding, [if std.length(providers) > 0 then '10_providers']: providers, diff --git a/docs/modules/ROOT/pages/references/parameters.adoc b/docs/modules/ROOT/pages/references/parameters.adoc index be3854c..b93555b 100644 --- a/docs/modules/ROOT/pages/references/parameters.adoc +++ b/docs/modules/ROOT/pages/references/parameters.adoc @@ -10,6 +10,22 @@ default:: `syn-crossplane` The namespace in which to deploy Crossplane. +== `namespaceLabels` + +[horizontal] +type:: dict +default:: `{}` + +Additional labels to add to the created namespace. + +== `namespaceAnnotations` + +[horizontal] +type:: dict +default:: `{}` + +Additional annotations to add to the created namespace. + == `providers` [horizontal] diff --git a/tests/golden/openshift4/crossplane/crossplane/00_namespace.yaml b/tests/golden/openshift4/crossplane/crossplane/00_namespace.yaml index b2bb7b8..7ff9f5f 100644 --- a/tests/golden/openshift4/crossplane/crossplane/00_namespace.yaml +++ b/tests/golden/openshift4/crossplane/crossplane/00_namespace.yaml @@ -1,7 +1,9 @@ apiVersion: v1 kind: Namespace metadata: - annotations: {} + annotations: + openshift.io/node-selector: node-role.kubernetes.io/infra= labels: + foo: bar name: syn-crossplane name: syn-crossplane diff --git a/tests/openshift4.yml b/tests/openshift4.yml index adaf146..a2b635c 100644 --- a/tests/openshift4.yml +++ b/tests/openshift4.yml @@ -1,4 +1,8 @@ parameters: facts: distribution: openshift4 - crossplane: {} + crossplane: + namespaceLabels: + foo: bar + namespaceAnnotations: + openshift.io/node-selector: node-role.kubernetes.io/infra=