File tree Expand file tree Collapse file tree 10 files changed +132
-88
lines changed
deploy/helm-chart/kubernetes-secret-generator Expand file tree Collapse file tree 10 files changed +132
-88
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ Multiple namespaces are supported and can be set as a comma-separated list: `ns1
24
24
25
25
If ` watchNamespace ` is set to the empty string value ` "" ` , all namespaces will be watched.
26
26
27
+ - ` rbac.create ` controls if rbac resources are deployed.
28
+
29
+ - ` rbac.clusterRole ` controls if secrets generator has permission to watch secrets in namespaces other than where it has been deployed.
30
+
31
+ ` rbac.clusterRole=false & watchNamespace="" ` will result in ` watchNamespace ` being set to the current namespace as this is all the permissions will allow access to.
32
+
27
33
Afterwards, deploy the operator using:
28
34
29
35
1 . Add the [ Mittwald Charts Repo] ( https://github.com/mittwald/helm-charts/blob/master/README.md#usage ) :
Original file line number Diff line number Diff line change @@ -61,3 +61,14 @@ Create the name of the service account to use
61
61
{ { default " default" .Values.serviceAccount.name } }
62
62
{ {- end -} }
63
63
{ {- end -} }
64
+
65
+ { {/*
66
+ Define the namespace to watch
67
+ */} }
68
+ { {- define " kubernetes-secret-generator.watchNamespace" -} }
69
+ { {- if and .Values.serviceAccount.create .Values.rbac.create (not .Values.rbac.clusterRole) -} }
70
+ { { default .Values.watchNamespace .Release.Namespace } }
71
+ { {- else -} }
72
+ { { .Values.watchNamespace } }
73
+ { {- end -} }
74
+ { {- end -} }
Original file line number Diff line number Diff line change
1
+ {{- if and .Values.rbac.create .Values.rbac.clusterRole -}}
2
+ kind : ClusterRole
3
+ apiVersion : rbac.authorization.k8s.io/v1
4
+ metadata :
5
+ name : " mittwald:{{ include " kubernetes-secret-generator.serviceAccountName" . }}"
6
+ labels :
7
+ {{ include "kubernetes-secret-generator.labels" . | nindent 4 }}
8
+ rules :
9
+ # actual operator functionality
10
+ - apiGroups :
11
+ - " "
12
+ resources :
13
+ - secrets
14
+ verbs :
15
+ - get
16
+ - list
17
+ - watch
18
+ - update
19
+ {{- end -}}
Original file line number Diff line number Diff line change
1
+ {{- if and .Values.rbac.create .Values.rbac.clusterRole -}}
2
+ kind : ClusterRoleBinding
3
+ apiVersion : rbac.authorization.k8s.io/v1
4
+ metadata :
5
+ name : " mittwald:{{ include " kubernetes-secret-generator.serviceAccountName" . }}"
6
+ labels :
7
+ {{ include "kubernetes-secret-generator.labels" . | nindent 4 }}
8
+ roleRef :
9
+ kind : ClusterRole
10
+ name : " mittwald:{{ include " kubernetes-secret-generator.serviceAccountName" . }}"
11
+ apiGroup : rbac.authorization.k8s.io
12
+ subjects :
13
+ - kind : ServiceAccount
14
+ namespace : {{ .Release.Namespace | quote }}
15
+ name : {{ include "kubernetes-secret-generator.serviceAccountName" . }}
16
+ {{- end -}}
Original file line number Diff line number Diff line change 45
45
periodSeconds : 3
46
46
env :
47
47
- name : WATCH_NAMESPACE
48
- value : {{ .Values. watchNamespace }}
48
+ value : {{ template "kubernetes-secret-generator. watchNamespace" . }}
49
49
- name : POD_NAME
50
50
valueFrom :
51
51
fieldRef :
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ {{- if .Values.rbac.create -}}
2
+ kind : Role
3
+ apiVersion : rbac.authorization.k8s.io/v1
4
+ metadata :
5
+ name : " mittwald:{{ include " kubernetes-secret-generator.serviceAccountName" . }}"
6
+ labels :
7
+ {{ include "kubernetes-secret-generator.labels" . | nindent 4 }}
8
+ rules :
9
+ # leader election
10
+ - apiGroups :
11
+ - " "
12
+ resources :
13
+ - configmaps
14
+ verbs :
15
+ - create
16
+ - delete
17
+ - get
18
+ - apiGroups :
19
+ - " "
20
+ resources :
21
+ - pods
22
+ verbs :
23
+ - delete
24
+ - get
25
+ - apiGroups :
26
+ - monitoring.coreos.com
27
+ resources :
28
+ - servicemonitors
29
+ verbs :
30
+ - " get"
31
+ - " create"
32
+ {{- if and .Values.rbac.create (not .Values.rbac.clusterRole) }}
33
+ # Permissions to access secrets in this namespace if no cluster role is created.
34
+ - apiGroups :
35
+ - " "
36
+ resources :
37
+ - secrets
38
+ verbs :
39
+ - get
40
+ - list
41
+ - watch
42
+ - update
43
+ {{- end -}}
44
+ {{- end -}}
Original file line number Diff line number Diff line change
1
+ {{- if .Values.rbac.create -}}
2
+ kind : RoleBinding
3
+ apiVersion : rbac.authorization.k8s.io/v1
4
+ metadata :
5
+ name : " mittwald:{{ include " kubernetes-secret-generator.serviceAccountName" . }}"
6
+ labels :
7
+ {{ include "kubernetes-secret-generator.labels" . | nindent 4 }}
8
+ roleRef :
9
+ kind : Role
10
+ name : " mittwald:{{ include " kubernetes-secret-generator.serviceAccountName" . }}"
11
+ apiGroup : rbac.authorization.k8s.io
12
+ subjects :
13
+ - kind : ServiceAccount
14
+ namespace : {{ .Release.Namespace | quote }}
15
+ name : {{ include "kubernetes-secret-generator.serviceAccountName" . }}
16
+ {{- end -}}
Original file line number Diff line number Diff line change
1
+ {{- if .Values.serviceAccount.create -}}
2
+ apiVersion : v1
3
+ kind : ServiceAccount
4
+ metadata :
5
+ name : {{ include "kubernetes-secret-generator.serviceAccountName" . }}
6
+ labels :
7
+ {{ include "kubernetes-secret-generator.labels" . | nindent 4 }}
8
+ {{- end -}}
Original file line number Diff line number Diff line change @@ -52,4 +52,15 @@ secretLength: 40
52
52
# Namespace that are watched for secret generation
53
53
# Accepts a comma-separated list of namespaces: ns1,ns2
54
54
# If set to "", all namespaces will be watched
55
+ # Accessing secrets in namespaces other than the deployed one requires permissions via a cluster role (on by default)
55
56
watchNamespace : " "
57
+
58
+ # RBAC parameteres
59
+ # https://kubernetes.io/docs/reference/access-authn-authz/rbac/
60
+ rbac :
61
+ # Disables creation of rbac resources
62
+ create : true
63
+ # The cluster role allows access to all namespaces in the cluster.
64
+ # Set to false to restrict access to the deployed namespace only.
65
+ # ClusterRole is deployed by Default
66
+ clusterRole : true
You can’t perform that action at this time.
0 commit comments