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
2424
2525 If ` watchNamespace ` is set to the empty string value ` "" ` , all namespaces will be watched.
2626
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+
2733Afterwards, deploy the operator using:
2834
29351 . 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
6161 { { default " default" .Values.serviceAccount.name } }
6262{ {- end -} }
6363{ {- 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 4545 periodSeconds : 3
4646 env :
4747 - name : WATCH_NAMESPACE
48- value : {{ .Values. watchNamespace }}
48+ value : {{ template "kubernetes-secret-generator. watchNamespace" . }}
4949 - name : POD_NAME
5050 valueFrom :
5151 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
5252# Namespace that are watched for secret generation
5353# Accepts a comma-separated list of namespaces: ns1,ns2
5454# 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)
5556watchNamespace : " "
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