Add validation/mutating webhook server for Fission custom resources (#2608)
* add webhook server * add metrics port * Add self-signed cert generation in helm chart for webhooks (#2611) * remove cert-manager installation * update fission webhook charts * remove extra cluster role * add mutating webhook for pkg creation * Service name and bundle fixes (#2614) * caBundle templating * Rename fission.svc to fission-webhook.svc * update package build status Co-authored-by: shaunak_deshmukh <shaunak@infracloud.io>
This commit is contained in:
co-authored by
shaunak_deshmukh
parent
31dfc3e4d3
commit
9a07d7d96b
@@ -0,0 +1,38 @@
|
||||
{{- $certManagerEnabled := .Values.webhook.certManager.enabled }}
|
||||
|
||||
{{- if not $certManagerEnabled }}
|
||||
kind: Secret
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: fission-webhook-certs
|
||||
labels:
|
||||
app.kubernetes.io/component: webhook-secret
|
||||
type: Opaque
|
||||
data:
|
||||
ca.crt: {{ b64enc (include "webhook.caBundleCertPEM" .) }}
|
||||
tls.crt: {{ b64enc (include "webhook.certPEM" .) }}
|
||||
tls.key: {{ b64enc (include "webhook.keyPEM" .) }}
|
||||
|
||||
{{- else }}
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Issuer
|
||||
metadata:
|
||||
name: fission-selfsigned-issuer
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
selfSigned: {}
|
||||
---
|
||||
apiVersion: cert-manager.io/v1
|
||||
kind: Certificate
|
||||
metadata:
|
||||
name: fission-webhook-cert
|
||||
namespace: {{ .Release.Namespace }}
|
||||
spec:
|
||||
secretName: fission-webhook-certs
|
||||
dnsNames:
|
||||
- "webhook-service.{{ .Release.Namespace }}.svc"
|
||||
- "webhook-service.{{ .Release.Namespace }}.svc.cluster.local "
|
||||
issuerRef:
|
||||
name: fission-selfsigned-issuer
|
||||
|
||||
{{- end }}
|
||||
@@ -0,0 +1,55 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: webhook
|
||||
labels:
|
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||
svc: webhook-service
|
||||
application: fission-webhook
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
svc: webhook-service
|
||||
application: fission-webhook
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
svc: webhook-service
|
||||
application: fission-webhook
|
||||
annotations:
|
||||
prometheus.io/scrape: "true"
|
||||
prometheus.io/path: "/metrics"
|
||||
prometheus.io/port: "8080"
|
||||
spec:
|
||||
{{- if .Values.webhook.securityContext.enabled }}
|
||||
securityContext: {{- omit .Values.webhook.securityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: webhook
|
||||
image: {{ include "fission-bundleImage" . | quote }}
|
||||
imagePullPolicy: {{ .Values.pullPolicy }}
|
||||
command: ["/fission-bundle"]
|
||||
args: ["--webhookPort", "9443"]
|
||||
volumeMounts:
|
||||
- mountPath: /tmp/k8s-webhook-server/serving-certs
|
||||
name: serving-certs
|
||||
readOnly: true
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
name: metrics
|
||||
volumes:
|
||||
- name: serving-certs
|
||||
secret:
|
||||
secretName: fission-webhook-certs
|
||||
serviceAccountName: fission-webhook
|
||||
{{- if .Values.priorityClassName }}
|
||||
priorityClassName: {{ .Values.priorityClassName }}
|
||||
{{- end }}
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.extraCoreComponentPodConfig }}
|
||||
{{ toYaml .Values.extraCoreComponentPodConfig | indent 6 -}}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: fission-webhook
|
||||
namespace: {{ .Release.Namespace }}
|
||||
@@ -0,0 +1,22 @@
|
||||
{{- if .Values.serviceMonitor.enabled }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: webhook-monitor
|
||||
{{- if .Values.serviceMonitor.namespace }}
|
||||
namespace: {{ .Values.serviceMonitor.namespace }}
|
||||
{{- end }}
|
||||
{{- with .Values.serviceMonitor.additionalServiceMonitorLabels }}
|
||||
labels:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- {{ .Release.Namespace }}
|
||||
selector:
|
||||
matchLabels:
|
||||
svc: webhook-service
|
||||
endpoints:
|
||||
- targetPort: 8080
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: webhook-service
|
||||
labels:
|
||||
svc: webhook-service
|
||||
application: fission-webhook
|
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||
spec:
|
||||
type: {{ .Values.serviceType }}
|
||||
ports:
|
||||
- port: 443
|
||||
targetPort: 9443
|
||||
selector:
|
||||
svc: webhook-service
|
||||
@@ -0,0 +1,203 @@
|
||||
---
|
||||
{{- $caCert := include "webhook.caBundleCertPEM" . -}}
|
||||
{{- $crtPEM := include "webhook.certPEM" . -}}
|
||||
{{- $keyPEM := include "webhook.keyPEM" . -}}
|
||||
|
||||
{{- $certManagerEnabled := $.Values.webhook.certManager.enabled }}
|
||||
{{- $caBundleValue := "" -}}
|
||||
{{- if $certManagerEnabled }}
|
||||
{{- $caBundleValue = "Cg==" -}}
|
||||
{{- else }}
|
||||
{{- $caBundleValue = ternary (b64enc $caCert) (b64enc (trim $crtPEM)) (empty $crtPEM) -}}
|
||||
{{- end }}
|
||||
|
||||
---
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: MutatingWebhookConfiguration
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: mutating-webhook-configuration
|
||||
{{- if $certManagerEnabled }}
|
||||
annotations:
|
||||
cert-manager.io/inject-ca-from: "{{ .Release.Namespace }}/fission-webhook-cert"
|
||||
{{- end }}
|
||||
webhooks:
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
caBundle: {{ $caBundleValue }}
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /mutate-fission-io-v1-package
|
||||
failurePolicy: Fail
|
||||
name: mpackage.fission.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- fission.io
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- packages
|
||||
sideEffects: None
|
||||
---
|
||||
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: ValidatingWebhookConfiguration
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: validating-webhook-configuration
|
||||
{{- if $certManagerEnabled }}
|
||||
annotations:
|
||||
cert-manager.io/inject-ca-from: "{{ .Release.Namespace }}/fission-webhook-cert"
|
||||
{{- end }}
|
||||
webhooks:
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
caBundle: {{ $caBundleValue }}
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /validate-fission-io-v1-environment
|
||||
failurePolicy: Fail
|
||||
name: venvironment.fission.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- fission.io
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
resources:
|
||||
- environments
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
caBundle: {{ $caBundleValue }}
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /validate-fission-io-v1-function
|
||||
failurePolicy: Fail
|
||||
name: vfunction.fission.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- fission.io
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- functions
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
caBundle: {{ $caBundleValue }}
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /validate-fission-io-v1-httptrigger
|
||||
failurePolicy: Fail
|
||||
name: vhttptrigger.fission.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- fission.io
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- httptriggers
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
caBundle: {{ $caBundleValue }}
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /validate-fission-io-v1-kuberneteswatchtrigger
|
||||
failurePolicy: Fail
|
||||
name: vkuberneteswatchtrigger.fission.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- fission.io
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- kuberneteswatchtriggers
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
caBundle: {{ $caBundleValue }}
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /validate-fission-io-v1-messagequeuetrigger
|
||||
failurePolicy: Fail
|
||||
name: vmessagequeuetrigger.fission.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- fission.io
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- messagequeuetriggers
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
caBundle: {{ $caBundleValue }}
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /validate-fission-io-v1-package
|
||||
failurePolicy: Fail
|
||||
name: vpackage.fission.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- fission.io
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- packages
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1
|
||||
clientConfig:
|
||||
caBundle: {{ $caBundleValue }}
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: {{ .Release.Namespace }}
|
||||
path: /validate-fission-io-v1-timetrigger
|
||||
failurePolicy: Fail
|
||||
name: vtimetrigger.fission.io
|
||||
rules:
|
||||
- apiGroups:
|
||||
- fission.io
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
- UPDATE
|
||||
resources:
|
||||
- timetriggers
|
||||
sideEffects: None
|
||||
Reference in New Issue
Block a user