Skip to content

Commit fc3668d

Browse files
committed
Allow specyfing if the namespace should be created
Signed-off-by: Jonasz Łasut-Balcerzak <jonasz.lasut@gmail.com>
1 parent 761001c commit fc3668d

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

apis/resourcestatemetrics/definition.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,16 @@ spec:
8383
type: object
8484
type: object
8585
namespace:
86-
description: Kubernetes namespace where the resource-state-metrics controller
87-
and related resources will be deployed.
88-
type: string
86+
description: Kubernetes namespace configuration.
87+
properties:
88+
name:
89+
type: string
90+
description: Kubernetes namespace where the resource-state-metrics controller and related resources will be deployed.
91+
create:
92+
type: boolean
93+
description: Should the kubernetes namespace be provisioned.
94+
default: true
95+
type: object
8996
rbac:
9097
description: RBAC configuration for the controller.
9198
properties:

examples/xr-rsm.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ metadata:
44
name: rsm
55
spec:
66
parameters:
7-
namespace: resource-state-metrics
7+
namespace:
8+
name: resource-state-metrics
89
rbac:
910
allowedAPIGroups:
1011
- 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:

0 commit comments

Comments
 (0)