Skip to content

Commit f599dfb

Browse files
authored
Allow specyfing if the namespace should be created (#13)
* Allow specyfing if the namespace should be created Signed-off-by: Jonasz Łasut-Balcerzak <jonasz.lasut@gmail.com> * Add default value for spec.parameters.namespace.name Signed-off-by: Jonasz Łasut-Balcerzak <jonasz.lasut@gmail.com> --------- Signed-off-by: Jonasz Łasut-Balcerzak <jonasz.lasut@gmail.com>
1 parent 4b9c66c commit f599dfb

File tree

8 files changed

+26
-14
lines changed

8 files changed

+26
-14
lines changed

apis/resourcestatemetrics/definition.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,20 @@ spec:
9898
type: object
9999
type: object
100100
namespace:
101-
description: Kubernetes namespace where the resource-state-metrics controller
102-
and related resources will be deployed.
103-
type: string
101+
description: Kubernetes namespace configuration.
102+
properties:
103+
name:
104+
type: string
105+
description: Kubernetes namespace where the resource-state-metrics controller and related resources will be deployed.
106+
default: resource-state-metrics-system
107+
create:
108+
type: boolean
109+
description: Should the kubernetes namespace be provisioned.
110+
default: true
111+
type: object
112+
default:
113+
name: resource-state-metrics-system
114+
create: true
104115
rbac:
105116
description: RBAC configuration for the controller.
106117
properties:

examples/xr-rsm.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ metadata:
44
name: rsm
55
spec:
66
parameters:
7-
namespace: resource-state-metrics
87
rbac:
98
allowedAPIGroups:
109
- apiextensions.crossplane.io
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# code: language=yaml
22
# yaml-language-server: $schema=../../.up/json/models/index.schema.json
33

4+
{{- if $xr.spec.parameters.namespace.create }}
45
---
56
apiVersion: v1
67
kind: Namespace
78
metadata:
8-
name: {{ $xr.spec.parameters.namespace }}
9+
name: {{ $xr.spec.parameters.namespace.name }}
910
annotations:
1011
{{ setResourceNameAnnotation "namespace" }}
1112
labels:
1213
app.kubernetes.io/name: resource-state-metrics
1314
app.kubernetes.io/managed-by: crossplane
15+
{{- end }}

functions/rsm/02-serviceaccount.yaml.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apiVersion: v1
66
kind: ServiceAccount
77
metadata:
88
name: resource-state-metrics
9-
namespace: {{ $xr.spec.parameters.namespace }}
9+
namespace: {{ $xr.spec.parameters.namespace.name }}
1010
annotations:
1111
{{ setResourceNameAnnotation "serviceaccount" }}
1212
labels:

functions/rsm/04-clusterrolebinding.yaml.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ roleRef:
2020
subjects:
2121
- kind: ServiceAccount
2222
name: resource-state-metrics
23-
namespace: {{ $xr.spec.parameters.namespace }}
23+
namespace: {{ $xr.spec.parameters.namespace.name }}

functions/rsm/05-deployment.yaml.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apiVersion: apps/v1
66
kind: Deployment
77
metadata:
88
name: resource-state-metrics
9-
namespace: {{ $xr.spec.parameters.namespace }}
9+
namespace: {{ $xr.spec.parameters.namespace.name }}
1010
annotations:
1111
{{ setResourceNameAnnotation "deployment" }}
1212
labels:

functions/rsm/06-service.yaml.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apiVersion: v1
66
kind: Service
77
metadata:
88
name: resource-state-metrics
9-
namespace: {{ $xr.spec.parameters.namespace }}
9+
namespace: {{ $xr.spec.parameters.namespace.name }}
1010
annotations:
1111
{{ setResourceNameAnnotation "service" }}
1212
labels:

tests/test-rsm/test.yaml.gotmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,12 @@ items:
521521
subjects:
522522
- kind: ServiceAccount
523523
name: resource-state-metrics
524-
namespace: resource-state-metrics
524+
namespace: resource-state-metrics-system
525525
- apiVersion: apps/v1
526526
kind: Deployment
527527
metadata:
528528
name: resource-state-metrics
529-
namespace: resource-state-metrics
529+
namespace: resource-state-metrics-system
530530
annotations:
531531
crossplane.io/composition-resource-name: deployment
532532
labels:
@@ -605,7 +605,7 @@ items:
605605
- apiVersion: v1
606606
kind: Namespace
607607
metadata:
608-
name: resource-state-metrics
608+
name: resource-state-metrics-system
609609
annotations:
610610
crossplane.io/composition-resource-name: namespace
611611
labels:
@@ -623,7 +623,7 @@ items:
623623
kind: Service
624624
metadata:
625625
name: resource-state-metrics
626-
namespace: resource-state-metrics
626+
namespace: resource-state-metrics-system
627627
annotations:
628628
crossplane.io/composition-resource-name: service
629629
labels:
@@ -654,7 +654,7 @@ items:
654654
automountServiceAccountToken: false
655655
metadata:
656656
name: resource-state-metrics
657-
namespace: resource-state-metrics
657+
namespace: resource-state-metrics-system
658658
annotations:
659659
crossplane.io/composition-resource-name: serviceaccount
660660
labels:

0 commit comments

Comments
 (0)