Skip to content
Closed
61 changes: 34 additions & 27 deletions cmd/build/helmify/kustomize-for-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ spec:
- --exempt-namespace={{ .Release.Namespace }}
- --operation=webhook
- --enable-mutation={{ .Values.experimentalEnableMutation}}
- --disable-cert-rotation={{ not .Values.certificates.generate }}
- HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_DISABLED_BUILTIN
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.release }}"
Expand All @@ -80,6 +81,10 @@ spec:
HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_IMAGE_PULL_SECRETS: ""
hostNetwork: HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_HOST_NETWORK
priorityClassName: HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_PRIORITY_CLASS_NAME
volumes:
- name: cert
secret:
secretName: "{{ .Values.certificates.secretName }}"
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -133,29 +138,31 @@ metadata:
labels:
gatekeeper.sh/system: "yes"
name: gatekeeper-validating-webhook-configuration
annotations:
HELMSUBST_VALIDATING_WEBHOOK_ANNOTATIONS: ""
webhooks:
- clientConfig:
service:
name: gatekeeper-webhook-service
namespace: gatekeeper-system
path: /v1/admit
name: validation.gatekeeper.sh
timeoutSeconds: HELMSUBST_VALIDATING_WEBHOOK_TIMEOUT
rules:
- apiGroups:
- "*"
apiVersions:
- '*'
operations: HELMSUBST_VALIDATING_WEBHOOK_OPERATION_RULES
resources:
- '*'
- clientConfig:
service:
name: gatekeeper-webhook-service
namespace: gatekeeper-system
path: /v1/admitlabel
name: check-ignore-label.gatekeeper.sh
timeoutSeconds: HELMSUBST_VALIDATING_WEBHOOK_TIMEOUT
- clientConfig:
service:
name: gatekeeper-webhook-service
namespace: gatekeeper-system
path: /v1/admit
name: validation.gatekeeper.sh
timeoutSeconds: HELMSUBST_VALIDATING_WEBHOOK_TIMEOUT
rules:
- apiGroups:
- "*"
apiVersions:
- "*"
operations: HELMSUBST_VALIDATING_WEBHOOK_OPERATION_RULES
resources:
- "*"
- clientConfig:
service:
name: gatekeeper-webhook-service
namespace: gatekeeper-system
path: /v1/admitlabel
name: check-ignore-label.gatekeeper.sh
timeoutSeconds: HELMSUBST_VALIDATING_WEBHOOK_TIMEOUT
---
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
Expand All @@ -180,8 +187,8 @@ spec:
pods: HELMSUBST_RESOURCEQUOTA_POD_LIMIT
scopeSelector:
matchExpressions:
- operator: In
scopeName: PriorityClass
values:
- HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_PRIORITY_CLASS_NAME
- HELMSUBST_DEPLOYMENT_AUDIT_PRIORITY_CLASS_NAME
- operator: In
scopeName: PriorityClass
values:
- HELMSUBST_DEPLOYMENT_CONTROLLER_MANAGER_PRIORITY_CLASS_NAME
- HELMSUBST_DEPLOYMENT_AUDIT_PRIORITY_CLASS_NAME
4 changes: 4 additions & 0 deletions cmd/build/helmify/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func (ks *kindSet) Write() error {
obj = "{{- if .Values.experimentalEnableMutation }}\n" + obj + "{{- end }}\n"
}

if name == "gatekeeper-webhook-server-cert" && kind == "Secret" {
obj = "{{- if .Values.controllerManager.generateCertificate }}\n" + obj + "{{- end }}\n"
}

if kind == "Deployment" {
obj = strings.Replace(obj, " labels:", " labels:\n{{- include \"gatekeeper.podLabels\" . }}", 1)
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/build/helmify/replacements.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ var replacements = map[string]string{

"HELMSUBST_VALIDATING_WEBHOOK_TIMEOUT": `{{ .Values.validatingWebhookTimeoutSeconds }}`,

`HELMSUBST_VALIDATING_WEBHOOK_ANNOTATIONS: ""`: `{{- toYaml .Values.validatingWebhookAnnotations | trim | nindent 4 }}`,

`HELMSUBST_MUTATING_WEBHOOK_ANNOTATIONS: ""`: `{{- toYaml .Values.mutatingWebhookAnnotations | trim | nindent 4 }}`,

"HELMSUBST_RESOURCEQUOTA_POD_LIMIT": `{{ .Values.podCountLimit }}`,

"HELMSUBST_VALIDATING_WEBHOOK_OPERATION_RULES": `
Expand Down
90 changes: 47 additions & 43 deletions cmd/build/helmify/static/README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions cmd/build/helmify/static/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ constraintViolationsLimit: 20
auditFromCache: false
disableValidatingWebhook: false
validatingWebhookTimeoutSeconds: 3
validatingWebhookAnnotations: {}
enableDeleteOperations: false
experimentalEnableMutation: false
mutatingWebhookAnnotations: {}
auditChunkSize: 0
logLevel: INFO
logDenies: false
Expand All @@ -30,6 +32,9 @@ podAnnotations:
podLabels: {}
podCountLimit: 100
secretAnnotations: {}
certificates:
generate: true
secretName: gatekeeper-webhook-server-cert
controllerManager:
hostNetwork: false
priorityClassName: system-cluster-critical
Expand Down
15 changes: 7 additions & 8 deletions config/overlays/mutation_webhook/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TODO: this is a temporary kustomization for the mutation webhook
# It is kept separate until the mutation feature is stable enough,
# when the mutation webhook should be moved to config/webhooks/manifests.yaml
# when the mutation webhook should be moved to config/webhooks/manifests.yaml

namespace: gatekeeper-system

Expand All @@ -12,11 +12,10 @@ resources:
- mutations.gatekeeper.sh_assign.yaml
- mutations.gatekeeper.sh_assignmetadata.yaml


patchesJson6902:
- target:
group: rbac.authorization.k8s.io
version: v1
kind: ClusterRole
name: manager-role
path: webhook_permissions_patch.yaml
- target:
group: rbac.authorization.k8s.io
version: v1
kind: ClusterRole
name: manager-role
path: webhook_permissions_patch.yaml
46 changes: 24 additions & 22 deletions config/overlays/mutation_webhook/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@ kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: gatekeeper-mutating-webhook-configuration
annotations:
HELMSUBST_MUTATING_WEBHOOK_ANNOTATIONS: ""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HELMSUBST_ stuff should go under /helmify/

webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /v1/mutate
failurePolicy: Ignore
name: mutation.gatekeeper.sh
matchPolicy: Exact
rules:
- apiGroups:
- '*'
apiVersions:
- '*'
operations:
- CREATE
- UPDATE
resources:
- '*'
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /v1/mutate
failurePolicy: Ignore
name: mutation.gatekeeper.sh
matchPolicy: Exact
rules:
- apiGroups:
- "*"
apiVersions:
- "*"
operations:
- CREATE
- UPDATE
resources:
- "*"
sideEffects: None
Loading