forked from helm/charts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stable/nginx-ingress] Add Validation webhook for nginx ingress contr…
…oller (helm#17230) * Add Validation webhook for nginx ingress controller Signed-off-by: LucasBoisserie <lucas.boisserie@gmail.com> * add tests Signed-off-by: LucasBoisserie <lucas.boisserie@gmail.com> Signed-off-by: Ali Sattari <ali.sattari@gmail.com>
- Loading branch information
1 parent
fed022e
commit 301fa4f
Showing
19 changed files
with
448 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
stable/nginx-ingress/ci/deamonset-webhook-and-psp-values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
controller: | ||
kind: DaemonSet | ||
admissionWebhooks: | ||
enabled: true | ||
|
||
podSecurityPolicy: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
controller: | ||
kind: DaemonSet | ||
admissionWebhooks: | ||
enabled: true |
6 changes: 6 additions & 0 deletions
6
stable/nginx-ingress/ci/deployment-webhook-and-psp-values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
controller: | ||
admissionWebhooks: | ||
enabled: true | ||
|
||
podSecurityPolicy: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
controller: | ||
admissionWebhooks: | ||
enabled: true |
30 changes: 30 additions & 0 deletions
30
stable/nginx-ingress/templates/admission-webhooks/job-patch/clusterrole.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
rules: | ||
- apiGroups: | ||
- admissionregistration.k8s.io | ||
resources: | ||
- validatingwebhookconfigurations | ||
verbs: | ||
- get | ||
- update | ||
{{- if .Values.podSecurityPolicy.enabled }} | ||
- apiGroups: ['extensions'] | ||
resources: ['podsecuritypolicies'] | ||
verbs: ['use'] | ||
resourceNames: | ||
- {{ template "nginx-ingress.fullname" . }}-admission | ||
{{- end }} | ||
{{- end }} |
23 changes: 23 additions & 0 deletions
23
stable/nginx-ingress/templates/admission-webhooks/job-patch/clusterrolebinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} |
52 changes: 52 additions & 0 deletions
52
stable/nginx-ingress/templates/admission-webhooks/job-patch/job-createSecret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission-create | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
spec: | ||
ttlSecondsAfterFinished: 0 | ||
template: | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission-create | ||
{{- with .Values.controller.admissionWebhooks.patch.podAnnotations }} | ||
annotations: | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
spec: | ||
{{- if .Values.controller.admissionWebhooks.patch.priorityClassName }} | ||
priorityClassName: {{ .Values.controller.admissionWebhooks.patch.priorityClassName }} | ||
{{- end }} | ||
containers: | ||
- name: create | ||
image: {{ .Values.controller.admissionWebhooks.patch.image.repository }}:{{ .Values.controller.admissionWebhooks.patch.image.tag }} | ||
imagePullPolicy: {{ .Values.controller.admissionWebhooks.patch.image.pullPolicy }} | ||
args: | ||
- create | ||
- --host={{ template "nginx-ingress.controller.fullname" . }}-admission,{{ template "nginx-ingress.controller.fullname" . }}-admission.{{ .Release.Namespace }}.svc | ||
- --namespace={{ .Release.Namespace }} | ||
- --secret-name={{ template "nginx-ingress.fullname". }}-admission | ||
restartPolicy: OnFailure | ||
serviceAccountName: {{ template "nginx-ingress.fullname" . }}-admission | ||
{{- with .Values.controller.admissionWebhooks.patch.nodeSelector }} | ||
nodeSelector: | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 2000 | ||
{{- end }} |
54 changes: 54 additions & 0 deletions
54
stable/nginx-ingress/templates/admission-webhooks/job-patch/job-patchWebhook.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission-patch | ||
annotations: | ||
"helm.sh/hook": post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
spec: | ||
ttlSecondsAfterFinished: 0 | ||
template: | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission-patch | ||
{{- with .Values.controller.admissionWebhooks.patch.podAnnotations }} | ||
annotations: | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
spec: | ||
{{- if .Values.controller.admissionWebhooks.patch.priorityClassName }} | ||
priorityClassName: {{ .Values.controller.admissionWebhooks.patch.priorityClassName }} | ||
{{- end }} | ||
containers: | ||
- name: patch | ||
image: {{ .Values.controller.admissionWebhooks.patch.image.repository }}:{{ .Values.controller.admissionWebhooks.patch.image.tag }} | ||
imagePullPolicy: {{ .Values.controller.admissionWebhooks.patch.pullPolicy }} | ||
args: | ||
- patch | ||
- --webhook-name={{ template "nginx-ingress.fullname" . }}-admission | ||
- --namespace={{ .Release.Namespace }} | ||
- --patch-mutating=false | ||
- --secret-name={{ template "nginx-ingress.fullname". }}-admission | ||
- --patch-failure-policy={{ .Values.controller.admissionWebhooks.failurePolicy }} | ||
restartPolicy: OnFailure | ||
serviceAccountName: {{ template "nginx-ingress.fullname" . }}-admission | ||
{{- with .Values.controller.admissionWebhooks.patch.nodeSelector }} | ||
nodeSelector: | ||
{{ toYaml . | indent 8 }} | ||
{{- end }} | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 2000 | ||
{{- end }} |
39 changes: 39 additions & 0 deletions
39
stable/nginx-ingress/templates/admission-webhooks/job-patch/psp.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled .Values.podSecurityPolicy.enabled }} | ||
apiVersion: policy/v1beta1 | ||
kind: PodSecurityPolicy | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
spec: | ||
allowPrivilegeEscalation: false | ||
fsGroup: | ||
ranges: | ||
- max: 65535 | ||
min: 1 | ||
rule: MustRunAs | ||
requiredDropCapabilities: | ||
- ALL | ||
runAsUser: | ||
rule: MustRunAsNonRoot | ||
seLinux: | ||
rule: RunAsAny | ||
supplementalGroups: | ||
ranges: | ||
- max: 65535 | ||
min: 1 | ||
rule: MustRunAs | ||
volumes: | ||
- configMap | ||
- emptyDir | ||
- projected | ||
- secret | ||
- downwardAPI | ||
{{- end }} |
23 changes: 23 additions & 0 deletions
23
stable/nginx-ingress/templates/admission-webhooks/job-patch/role.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- get | ||
- create | ||
{{- end }} |
23 changes: 23 additions & 0 deletions
23
stable/nginx-ingress/templates/admission-webhooks/job-patch/rolebinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} |
15 changes: 15 additions & 0 deletions
15
stable/nginx-ingress/templates/admission-webhooks/job-patch/serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{- if and .Values.controller.admissionWebhooks.enabled .Values.controller.admissionWebhooks.patch.enabled }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade,post-install,post-upgrade | ||
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }} | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "{{ .Values.controller.name }}" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
{{- end }} |
31 changes: 31 additions & 0 deletions
31
stable/nginx-ingress/templates/admission-webhooks/validating-webhook.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{{- if .Values.controller.admissionWebhooks.enabled }} | ||
apiVersion: admissionregistration.k8s.io/v1beta1 | ||
kind: ValidatingWebhookConfiguration | ||
metadata: | ||
labels: | ||
app: {{ template "nginx-ingress.name" . }}-admission | ||
chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
component: "admission-webhook" | ||
heritage: {{ .Release.Service }} | ||
release: {{ .Release.Name }} | ||
name: {{ template "nginx-ingress.fullname" . }}-admission | ||
webhooks: | ||
- name: validate.nginx.ingress.kubernetes.io | ||
rules: | ||
- apiGroups: | ||
- extensions | ||
- networking.k8s.io | ||
apiVersions: | ||
- v1beta1 | ||
operations: | ||
- CREATE | ||
- UPDATE | ||
resources: | ||
- ingresses | ||
failurePolicy: Fail | ||
clientConfig: | ||
service: | ||
namespace: {{ .Release.Namespace }} | ||
name: {{ template "nginx-ingress.controller.fullname" . }}-admission | ||
path: /extensions/v1beta1/ingresses | ||
{{- end }} |
Oops, something went wrong.