File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change 1
1
2
2
{{/* This cluster role and binding is necessary to allow the operator to automatically register ValidatingWebhookConfiguration. */}}
3
3
{{- if and .Values.operator.webhook.registerConfiguration .Values.operator.webhook.installClusterRole }}
4
- {{- $webhookClusterRoleName := printf "%s-%s-webhook" .Values.operator.name (include "mongodb-kubernetes-operator.namespace" .) }}
4
+ {{- $webhookClusterRoleName := printf "%s-%s-webhook-cr" .Values.operator.name (include "mongodb-kubernetes-operator.namespace" .) }}
5
+ {{- $webhookClusterRoleBindingName := printf "%s-%s-webhook-crb" .Values.operator.name (include "mongodb-kubernetes-operator.namespace" .) }}
5
6
{{- if not (lookup "rbac.authorization.k8s.io/v1" "ClusterRole" "" $webhookClusterRoleName) }}
6
7
---
7
8
kind : ClusterRole
35
36
kind : ClusterRoleBinding
36
37
apiVersion : rbac.authorization.k8s.io/v1
37
38
metadata :
38
- name : {{ .Values.operator.name }}-{{ include "mongodb-kubernetes-operator.namespace" . }}-webhook-binding
39
+ name : {{ $webhookClusterRoleBindingName }}
39
40
roleRef :
40
41
apiGroup : rbac.authorization.k8s.io
41
42
kind : ClusterRole
Original file line number Diff line number Diff line change 1
- suite : test webhook consistent clusterrole and binding namecomm
1
+ suite : test webhook consistent clusterrole and binding
2
2
templates :
3
3
- operator-roles-webhook.yaml
4
4
tests :
@@ -15,14 +15,17 @@ tests:
15
15
- isKind :
16
16
of : ClusterRoleBinding
17
17
documentIndex : 1
18
- # The key fix: both should use the same dynamic name
19
18
- equal :
20
19
path : metadata.name
21
- value : mongodb-kubernetes-operator-NAMESPACE-webhook
20
+ value : mongodb-kubernetes-operator-NAMESPACE-webhook-cr
22
21
documentIndex : 0
22
+ - equal :
23
+ path : metadata.name
24
+ value : mongodb-kubernetes-operator-NAMESPACE-webhook-crb
25
+ documentIndex : 1
23
26
- equal :
24
27
path : roleRef.name
25
- value : mongodb-kubernetes-operator-NAMESPACE-webhook
28
+ value : mongodb-kubernetes-operator-NAMESPACE-webhook-cr
26
29
documentIndex : 1
27
30
28
31
# Test that different installations get unique names (prevents conflicts)
@@ -35,12 +38,15 @@ tests:
35
38
release :
36
39
namespace : custom-ns
37
40
asserts :
38
- # Verify the naming pattern: {operator.name}-{namespace}-webhook
39
41
- equal :
40
42
path : metadata.name
41
- value : my-operator-custom-ns-webhook
43
+ value : my-operator-custom-ns-webhook-cr
42
44
documentIndex : 0
45
+ - equal :
46
+ path : metadata.name
47
+ value : my-operator-custom-ns-webhook-crb
48
+ documentIndex : 1
43
49
- equal :
44
50
path : roleRef.name
45
- value : my-operator-custom-ns-webhook
51
+ value : my-operator-custom-ns-webhook-cr
46
52
documentIndex : 1
You can’t perform that action at this time.
0 commit comments