-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support to validating webhooks (#352)
* feat: add support to validating webhooks Signed-off-by: Jorge Turrado <[email protected]> * use static name for ValidatingWebhookConfiguration Signed-off-by: Jorge Turrado <[email protected]> * update values and readme Signed-off-by: Jorge Turrado <[email protected]> * apply feedback Signed-off-by: Jorge Turrado <[email protected]> Signed-off-by: Jorge Turrado <[email protected]> Signed-off-by: Jorge Turrado <[email protected]>
- Loading branch information
Showing
18 changed files
with
629 additions
and
60 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{- if .Values.certificates.autoGenerated }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
annotations: | ||
{{- toYaml .Values.additionalAnnotations | nindent 4 }} | ||
labels: | ||
app.kubernetes.io/name: {{ .Values.operator.name }} | ||
{{- include "keda.labels" . | indent 4 }} | ||
creationTimestamp: null | ||
name: {{ .Values.operator.name }} | ||
namespace: {{ .Release.Namespace }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
{{- end -}} |
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,20 @@ | ||
{{- if .Values.certificates.autoGenerated }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
annotations: | ||
{{- toYaml .Values.additionalAnnotations | nindent 4 }} | ||
labels: | ||
app.kubernetes.io/name: {{ .Values.operator.name }} | ||
{{- include "keda.labels" . | indent 4 }} | ||
name: {{ .Values.operator.name }} | ||
namespace: {{ .Release.Namespace }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ .Values.operator.name }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ .Values.serviceAccount.name }} | ||
namespace: {{ .Release.Namespace }} | ||
{{- end -}} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ .Values.webhooks.name }} | ||
namespace: {{ .Release.Namespace }} | ||
annotations: | ||
{{- toYaml .Values.additionalAnnotations | nindent 4 }} | ||
labels: | ||
app: {{ .Values.webhooks.name }} | ||
name: {{ .Values.webhooks.name }} | ||
app.kubernetes.io/name: {{ .Values.webhooks.name }} | ||
{{- include "keda.labels" . | indent 4 }} | ||
spec: | ||
replicas: {{ .Values.webhooks.replicaCount}} | ||
{{- with .Values.upgradeStrategy.webhooks }} | ||
strategy: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
app: {{ .Values.webhooks.name }} | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ .Values.webhooks.name }} | ||
name: {{ .Values.webhooks.name }} | ||
app.kubernetes.io/name: {{ .Values.webhooks.name }} | ||
{{- include "keda.labels" . | indent 8 }} | ||
annotations: | ||
{{- if .Values.podAnnotations.webhooks }} | ||
{{- toYaml .Values.podAnnotations.webhooks | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.additionalAnnotations }} | ||
{{- toYaml .Values.additionalAnnotations | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
{{- if .Values.priorityClassName }} | ||
priorityClassName: {{ .Values.priorityClassName | quote }} | ||
{{- end }} | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ .Values.serviceAccount.name }} | ||
automountServiceAccountToken: true | ||
securityContext: | ||
{{- if .Values.podSecurityContext.webhooks }} | ||
{{- toYaml .Values.podSecurityContext.webhooks | nindent 8 }} | ||
{{- else }} | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: {{ .Values.webhooks.name }} | ||
securityContext: | ||
{{- if .Values.securityContext.webhooks }} | ||
{{- toYaml .Values.securityContext.webhooks | nindent 12 }} | ||
{{- else }} | ||
{{- toYaml .Values.securityContext | nindent 12 }} | ||
{{- end }} | ||
image: "{{ .Values.image.webhooks.repository }}:{{ .Values.image.webhooks.tag | default .Chart.AppVersion }}" | ||
command: | ||
- /keda-admission-webhooks | ||
args: | ||
- "--zap-log-level={{ .Values.logging.webhooks.level }}" | ||
- "--zap-encoder={{ .Values.logging.webhooks.format }}" | ||
- "--zap-time-encoding={{ .Values.logging.webhooks.timeEncoding }}" | ||
- "--cert-dir={{ .Values.certificates.mountPath }}" | ||
{{- if .Values.prometheus.webhooks.enabled }} | ||
- --metrics-bind-address=:{{ .Values.prometheus.webhooks.port }} | ||
{{- end }} | ||
{{- range $key, $value := .Values.extraArgs.webhooks }} | ||
- --{{ $key }}={{ $value }} | ||
{{- end }} | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8081 | ||
initialDelaySeconds: 25 | ||
readinessProbe: | ||
httpGet: | ||
path: /readyz | ||
port: 8081 | ||
initialDelaySeconds: 20 | ||
ports: | ||
- containerPort: 9443 | ||
name: http | ||
protocol: TCP | ||
{{- if .Values.prometheus.webhooks.enabled }} | ||
- containerPort: {{ .Values.prometheus.webhooks.port }} | ||
name: metrics | ||
protocol: TCP | ||
{{- end }} | ||
env: | ||
- name: WATCH_NAMESPACE | ||
value: {{ .Values.watchNamespace | quote }} | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
{{- if .Values.env }} | ||
{{- toYaml .Values.env | nindent 12 -}} | ||
{{- end }} | ||
volumeMounts: | ||
- mountPath: {{ .Values.certificates.mountPath }} | ||
name: certificates | ||
readOnly: true | ||
{{- if .Values.volumes.webhooks.extraVolumeMounts }} | ||
{{- toYaml .Values.volumes.webhooks.extraVolumeMounts | nindent 12 }} | ||
{{- end }} | ||
resources: | ||
{{- if .Values.resources.webhooks }} | ||
{{- toYaml .Values.resources.webhooks | nindent 12 }} | ||
{{- else }} | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
{{- end }} | ||
volumes: | ||
- name: certificates | ||
secret: | ||
defaultMode: 420 | ||
secretName: {{ .Values.certificates.secretName }} | ||
{{- if .Values.volumes.webhooks.extraVolumes }} | ||
{{- toYaml .Values.volumes.webhooks.extraVolumes | nindent 8 }} | ||
{{- end }} | ||
nodeSelector: | ||
kubernetes.io/os: linux | ||
{{- with .Values.nodeSelector }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.webhooks.affinity }} | ||
affinity: | ||
{{- toYaml .Values.webhooks.affinity | nindent 8 }} | ||
{{- else if .Values.affinity }} | ||
affinity: | ||
{{- toYaml .Values.affinity | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.topologySpreadConstraints.webhooks }} | ||
topologySpreadConstraints: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} |
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,27 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
{{- if and .Values.prometheus.webhooks.enabled ( not .Values.prometheus.webhooks.serviceMonitor.enabled ) }} | ||
prometheus.io/scrape: "true" | ||
prometheus.io/port: {{ .Values.prometheus.webhooks.port | quote }} | ||
prometheus.io/path: "/metrics" | ||
{{- end }} | ||
labels: | ||
app.kubernetes.io/name: {{ .Values.webhooks.name }} | ||
{{- include "keda.labels" . | indent 4 }} | ||
name: {{ .Values.webhooks.name }} | ||
namespace: {{ .Release.Namespace }} | ||
spec: | ||
ports: | ||
- name: http | ||
port: 443 | ||
protocol: TCP | ||
targetPort: 9443 | ||
{{- if .Values.prometheus.webhooks.enabled }} | ||
- name: {{ .Values.prometheus.webhooks.serviceMonitor.port }} | ||
port: {{ .Values.prometheus.webhooks.port }} | ||
targetPort: {{ .Values.prometheus.webhooks.port }} | ||
{{- end }} | ||
selector: | ||
app: {{ .Values.webhooks.name }} |
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 or (or .Values.podDisruptionBudget.minAvailable .Values.podDisruptionBudget.maxUnavailable) .Values.podDisruptionBudget.webhooks }} | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
namespace: {{ .Release.Namespace }} | ||
name: {{ .Values.webhooks.name }} | ||
annotations: | ||
{{- toYaml .Values.additionalAnnotations | nindent 4 }} | ||
labels: | ||
app.kubernetes.io/name: {{ .Values.serviceAccount.name }} | ||
{{- include "keda.labels" . | indent 4 }} | ||
spec: | ||
{{- if .Values.podDisruptionBudget.minAvailable }} | ||
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} | ||
{{- end }} | ||
{{- if .Values.podDisruptionBudget.maxUnavailable }} | ||
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }} | ||
{{- end }} | ||
{{- if .Values.podDisruptionBudget.webhooks }} | ||
{{- if .Values.podDisruptionBudget.webhooks.minAvailable }} | ||
minAvailable: {{ .Values.podDisruptionBudget.webhooks.minAvailable }} | ||
{{- end }} | ||
{{- if .Values.podDisruptionBudget.webhooks.maxUnavailable }} | ||
maxUnavailable: {{ .Values.podDisruptionBudget.webhooks.maxUnavailable }} | ||
{{- end }} | ||
{{- end }} | ||
selector: | ||
matchLabels: | ||
app: {{ .Values.webhooks.name }} | ||
{{- end }} |
Oops, something went wrong.