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 11
22{{/* This cluster role and binding is necessary to allow the operator to automatically register ValidatingWebhookConfiguration. */}}
33{{- 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" .) }}
56{{- if not (lookup "rbac.authorization.k8s.io/v1" "ClusterRole" "" $webhookClusterRoleName) }}
67---
78kind : ClusterRole
3536kind : ClusterRoleBinding
3637apiVersion : rbac.authorization.k8s.io/v1
3738metadata :
38- name : {{ .Values.operator.name }}-{{ include "mongodb-kubernetes-operator.namespace" . }}-webhook-binding
39+ name : {{ $webhookClusterRoleBindingName }}
3940roleRef :
4041 apiGroup : rbac.authorization.k8s.io
4142 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
22templates :
33 - operator-roles-webhook.yaml
44tests :
@@ -15,14 +15,17 @@ tests:
1515 - isKind :
1616 of : ClusterRoleBinding
1717 documentIndex : 1
18- # The key fix: both should use the same dynamic name
1918 - equal :
2019 path : metadata.name
21- value : mongodb-kubernetes-operator-NAMESPACE-webhook
20+ value : mongodb-kubernetes-operator-NAMESPACE-webhook-cr
2221 documentIndex : 0
22+ - equal :
23+ path : metadata.name
24+ value : mongodb-kubernetes-operator-NAMESPACE-webhook-crb
25+ documentIndex : 1
2326 - equal :
2427 path : roleRef.name
25- value : mongodb-kubernetes-operator-NAMESPACE-webhook
28+ value : mongodb-kubernetes-operator-NAMESPACE-webhook-cr
2629 documentIndex : 1
2730
2831 # Test that different installations get unique names (prevents conflicts)
@@ -35,12 +38,15 @@ tests:
3538 release :
3639 namespace : custom-ns
3740 asserts :
38- # Verify the naming pattern: {operator.name}-{namespace}-webhook
3941 - equal :
4042 path : metadata.name
41- value : my-operator-custom-ns-webhook
43+ value : my-operator-custom-ns-webhook-cr
4244 documentIndex : 0
45+ - equal :
46+ path : metadata.name
47+ value : my-operator-custom-ns-webhook-crb
48+ documentIndex : 1
4349 - equal :
4450 path : roleRef.name
45- value : my-operator-custom-ns-webhook
51+ value : my-operator-custom-ns-webhook-cr
4652 documentIndex : 1
You can’t perform that action at this time.
0 commit comments