Chart: Make admission webhook patch job RBAC configurable. (#11376)
* Add an option to skip rbac resources creation in helm chart for admission-webhooks (#11375) Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com> * Add an option to skip rbac resources creation in helm chart update README (#11375) Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com> * Add an option to skip serviceAccount resources creation in helm chart for admission-webhooks (#11375) Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com> * Add helm chart tests for admission-webhooks (#11375) Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com> * Chart make admission webhook patch job RBAC configurable (#11375) Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com> * Update charts/ingress-nginx/tests/admission-webhooks/job-patch/clusterrole_test.yaml Co-authored-by: Marco Ebert <marco_ebert@icloud.com> * Update charts/ingress-nginx/tests/admission-webhooks/job-patch/clusterrolebinding_test.yaml Co-authored-by: Marco Ebert <marco_ebert@icloud.com> * Update charts/ingress-nginx/tests/admission-webhooks/job-patch/role_test.yaml Co-authored-by: Marco Ebert <marco_ebert@icloud.com> * Update charts/ingress-nginx/tests/admission-webhooks/job-patch/rolebinding_test.yaml Co-authored-by: Marco Ebert <marco_ebert@icloud.com> * Update charts/ingress-nginx/tests/admission-webhooks/job-patch/serviceaccount_test.yaml Co-authored-by: Marco Ebert <marco_ebert@icloud.com> --------- Signed-off-by: Reddysekhar Gaduputi <gsekhar73@gmail.com> Co-authored-by: Marco Ebert <marco_ebert@icloud.com>
This commit is contained in:
parent
82c4d78a2f
commit
0c17748c44
15 changed files with 131 additions and 10 deletions
|
@ -263,7 +263,13 @@ As of version `1.26.0` of this chart, by simply not providing any clusterIP valu
|
|||
| controller.admissionWebhooks.patch.nodeSelector."kubernetes.io/os" | string | `"linux"` | |
|
||||
| controller.admissionWebhooks.patch.podAnnotations | object | `{}` | |
|
||||
| controller.admissionWebhooks.patch.priorityClassName | string | `""` | Provide a priority class name to the webhook patching job # |
|
||||
| controller.admissionWebhooks.patch.rbac | object | `{"create":true}` | Admission webhook patch job RBAC |
|
||||
| controller.admissionWebhooks.patch.rbac.create | bool | `true` | Create RBAC or not |
|
||||
| controller.admissionWebhooks.patch.securityContext | object | `{}` | Security context for secret creation & webhook patch pods |
|
||||
| controller.admissionWebhooks.patch.serviceAccount | object | `{"automountServiceAccountToken":true,"create":true,"name":""}` | Admission webhook patch job service account |
|
||||
| controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken | bool | `true` | Auto-mount service account token or not |
|
||||
| controller.admissionWebhooks.patch.serviceAccount.create | bool | `true` | Create a service account or not |
|
||||
| controller.admissionWebhooks.patch.serviceAccount.name | string | `""` | Custom service account name |
|
||||
| controller.admissionWebhooks.patch.tolerations | list | `[]` | |
|
||||
| controller.admissionWebhooks.patchWebhookJob.name | string | `"patch"` | |
|
||||
| controller.admissionWebhooks.patchWebhookJob.resources | object | `{}` | |
|
||||
|
|
|
@ -167,6 +167,17 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
|
|||
{{- printf "%s-%s" (include "ingress-nginx.fullname" .) .Values.controller.admissionWebhooks.name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the admission webhook patch job service account to use
|
||||
*/}}
|
||||
{{- define "ingress-nginx.admissionWebhooks.patch.serviceAccountName" -}}
|
||||
{{- if .Values.controller.admissionWebhooks.patch.serviceAccount.create -}}
|
||||
{{ default (include "ingress-nginx.admissionWebhooks.fullname" .) .Values.controller.admissionWebhooks.patch.serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.controller.admissionWebhooks.patch.serviceAccount.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified admission webhook secret creation job name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled .Values.controller.admissionWebhooks.patch.rbac.create (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled .Values.controller.admissionWebhooks.patch.rbac.create (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
|
@ -18,6 +18,6 @@ roleRef:
|
|||
name: {{ include "ingress-nginx.admissionWebhooks.fullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "ingress-nginx.admissionWebhooks.fullname" . }}
|
||||
name: {{ include "ingress-nginx.admissionWebhooks.patch.serviceAccountName" . }}
|
||||
namespace: {{ include "ingress-nginx.namespace" . }}
|
||||
{{- end }}
|
||||
|
|
|
@ -66,7 +66,7 @@ spec:
|
|||
resources: {{ toYaml .Values.controller.admissionWebhooks.createSecretJob.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
restartPolicy: OnFailure
|
||||
serviceAccountName: {{ include "ingress-nginx.admissionWebhooks.fullname" . }}
|
||||
serviceAccountName: {{ include "ingress-nginx.admissionWebhooks.patch.serviceAccountName" . }}
|
||||
{{- if .Values.controller.admissionWebhooks.patch.nodeSelector }}
|
||||
nodeSelector: {{ toYaml .Values.controller.admissionWebhooks.patch.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -68,7 +68,7 @@ spec:
|
|||
resources: {{ toYaml .Values.controller.admissionWebhooks.patchWebhookJob.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
restartPolicy: OnFailure
|
||||
serviceAccountName: {{ include "ingress-nginx.admissionWebhooks.fullname" . }}
|
||||
serviceAccountName: {{ include "ingress-nginx.admissionWebhooks.patch.serviceAccountName" . }}
|
||||
{{- if .Values.controller.admissionWebhooks.patch.nodeSelector }}
|
||||
nodeSelector: {{ toYaml .Values.controller.admissionWebhooks.patch.nodeSelector | nindent 8 }}
|
||||
{{- end }}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled .Values.controller.admissionWebhooks.patch.rbac.create (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled .Values.controller.admissionWebhooks.patch.rbac.create (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
|
@ -19,6 +19,6 @@ roleRef:
|
|||
name: {{ include "ingress-nginx.admissionWebhooks.fullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "ingress-nginx.admissionWebhooks.fullname" . }}
|
||||
name: {{ include "ingress-nginx.admissionWebhooks.patch.serviceAccountName" . }}
|
||||
namespace: {{ include "ingress-nginx.namespace" . }}
|
||||
{{- end }}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled .Values.controller.admissionWebhooks.patch.serviceAccount.create (not .Values.controller.admissionWebhooks.certManager.enabled) -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "ingress-nginx.admissionWebhooks.fullname" . }}
|
||||
name: {{ include "ingress-nginx.admissionWebhooks.patch.serviceAccountName" . }}
|
||||
namespace: {{ include "ingress-nginx.namespace" . }}
|
||||
annotations:
|
||||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade
|
||||
|
@ -13,4 +13,5 @@ metadata:
|
|||
{{- with .Values.controller.admissionWebhooks.patch.labels }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
automountServiceAccountToken: {{ .Values.controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken }}
|
||||
{{- end }}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
suite: Admission Webhooks > Patch Job > ClusterRole
|
||||
templates:
|
||||
- admission-webhooks/job-patch/clusterrole.yaml
|
||||
|
||||
tests:
|
||||
- it: should not create a ClusterRole if `controller.admissionWebhooks.patch.rbac.create` is false
|
||||
set:
|
||||
controller.admissionWebhooks.patch.rbac.create: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
|
@ -0,0 +1,11 @@
|
|||
suite: Admission Webhooks > Patch Job > ClusterRoleBinding
|
||||
templates:
|
||||
- admission-webhooks/job-patch/clusterrolebinding.yaml
|
||||
|
||||
tests:
|
||||
- it: should not create a ClusterRoleBinding if `controller.admissionWebhooks.patch.rbac.create` is false
|
||||
set:
|
||||
controller.admissionWebhooks.patch.rbac.create: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
|
@ -0,0 +1,11 @@
|
|||
suite: Admission Webhooks > Patch Job > Role
|
||||
templates:
|
||||
- admission-webhooks/job-patch/role.yaml
|
||||
|
||||
tests:
|
||||
- it: should not create a Role if `controller.admissionWebhooks.patch.rbac.create` is false
|
||||
set:
|
||||
controller.admissionWebhooks.patch.rbac.create: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
|
@ -0,0 +1,11 @@
|
|||
suite: Admission Webhooks > Patch Job > RoleBinding
|
||||
templates:
|
||||
- admission-webhooks/job-patch/rolebinding.yaml
|
||||
|
||||
tests:
|
||||
- it: should not create a RoleBinding if `controller.admissionWebhooks.patch.rbac.create` is false
|
||||
set:
|
||||
controller.admissionWebhooks.patch.rbac.create: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
|
@ -0,0 +1,47 @@
|
|||
suite: Admission Webhooks > Patch Job > ServiceAccount
|
||||
templates:
|
||||
- admission-webhooks/job-patch/serviceaccount.yaml
|
||||
|
||||
tests:
|
||||
- it: should not create a ServiceAccount if `controller.admissionWebhooks.patch.serviceAccount.create` is false
|
||||
set:
|
||||
controller.admissionWebhooks.patch.serviceAccount.create: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: should create a ServiceAccount if `controller.admissionWebhooks.patch.serviceAccount.create` is true
|
||||
set:
|
||||
controller.admissionWebhooks.patch.serviceAccount.create: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- isKind:
|
||||
of: ServiceAccount
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: ingress-nginx-admission
|
||||
|
||||
- it: should create a ServiceAccount with specified name if `controller.admissionWebhooks.patch.serviceAccount.name` is set
|
||||
set:
|
||||
controller.admissionWebhooks.patch.serviceAccount.name: ingress-nginx-admission-test-sa
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- isKind:
|
||||
of: ServiceAccount
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: ingress-nginx-admission-test-sa
|
||||
|
||||
- it: should create a ServiceAccount with token auto-mounting disabled if `controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken` is false
|
||||
set:
|
||||
controller.admissionWebhooks.patch.serviceAccount.automountServiceAccountToken: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- isKind:
|
||||
of: ServiceAccount
|
||||
- equal:
|
||||
path: automountServiceAccountToken
|
||||
value: false
|
|
@ -822,6 +822,18 @@ controller:
|
|||
labels: {}
|
||||
# -- Security context for secret creation & webhook patch pods
|
||||
securityContext: {}
|
||||
# -- Admission webhook patch job RBAC
|
||||
rbac:
|
||||
# -- Create RBAC or not
|
||||
create: true
|
||||
# -- Admission webhook patch job service account
|
||||
serviceAccount:
|
||||
# -- Create a service account or not
|
||||
create: true
|
||||
# -- Custom service account name
|
||||
name: ""
|
||||
# -- Auto-mount service account token or not
|
||||
automountServiceAccountToken: true
|
||||
# Use certmanager to generate webhook certs
|
||||
certManager:
|
||||
enabled: false
|
||||
|
|
Loading…
Reference in a new issue