Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(helm): add options for hook jobs #2202

Merged
merged 3 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(helm): add options for hook jobs (fix #2200)
add resources, affinity, nodeSelector, tolerations

Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
  • Loading branch information
stek29 committed Aug 4, 2022
commit f0c0fe2a9648e844ab977c13916cb1ddab10e0f3
2 changes: 2 additions & 0 deletions cmd/build/helmify/static/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Output post install webhook probe container entry
{{- end }}
- "-v"
- "https://gatekeeper-webhook-service.{{ .Release.Namespace }}.svc/v1/admitlabel?timeout=2s"
resources:
{{- toYaml .Values.postInstall.resources | nindent 4 }}
securityContext:
{{- toYaml .Values.postInstall.securityContext | nindent 4 }}
volumeMounts:
Expand Down
12 changes: 10 additions & 2 deletions cmd/build/helmify/static/templates/namespace-post-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ spec:
{{- .Values.postInstall.labelNamespace.image.pullSecrets | toYaml | nindent 12 }}
{{- end }}
serviceAccount: gatekeeper-update-namespace-label
nodeSelector:
kubernetes.io/os: linux
{{- if .Values.postInstall.probeWebhook.enabled }}
volumes:
{{- include "gatekeeper.postInstallWebhookProbeVolume" . | nindent 8 }}
Expand All @@ -56,12 +54,22 @@ spec:
- {{ . }}
{{- end }}
- --overwrite
resources:
{{- toYaml .Values.postInstall.resources | nindent 12 }}
securityContext:
{{- if .Values.enableRuntimeDefaultSeccompProfile }}
seccompProfile:
type: RuntimeDefault
{{- end }}
{{- toYaml .Values.postInstall.securityContext | nindent 12 }}
{{- with .Values.postInstall }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
affinity:
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
12 changes: 10 additions & 2 deletions cmd/build/helmify/static/templates/namespace-post-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ spec:
{{- .Values.postUpgrade.labelNamespace.image.pullSecrets | toYaml | nindent 12 }}
{{- end }}
serviceAccount: gatekeeper-update-namespace-label-post-upgrade
nodeSelector:
kubernetes.io/os: linux
containers:
- name: kubectl-label
image: "{{ .Values.postUpgrade.labelNamespace.image.repository }}:{{ .Values.postUpgrade.labelNamespace.image.tag }}"
Expand All @@ -48,8 +46,18 @@ spec:
- {{ . }}
{{- end }}
- --overwrite
resources:
{{- toYaml .Values.postUpgrade.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.postUpgrade.securityContext | nindent 12 }}
{{- with .Values.postUpgrade }}
affinity:
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ spec:
imagePullSecrets:
{{- .Values.postInstall.probeWebhook.image.pullSecrets | toYaml | nindent 12 }}
{{- end }}
nodeSelector:
kubernetes.io/os: linux
volumes:
{{- include "gatekeeper.postInstallWebhookProbeVolume" . | nindent 8 }}
containers:
{{- include "gatekeeper.postInstallWebhookProbeContainer" . | nindent 8 }}
{{- with .Values.postInstall }}
affinity:
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
10 changes: 6 additions & 4 deletions cmd/build/helmify/static/templates/upgrade-crds-hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ spec:
type: RuntimeDefault
{{- end }}
{{- toYaml .Values.crds.securityContext | nindent 10 }}
{{- with .Values.crds }}
affinity:
{{- toYaml .Values.upgradeCRDs.affinity | nindent 8 }}
nodeSelector:
kubernetes.io/os: linux
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .Values.upgradeCRDs.tolerations | nindent 8 }}
{{- toYaml .tolerations | nindent 8 }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ spec:
{{- .Values.preUninstall.deleteWebhookConfigurations.image.pullSecrets | toYaml | nindent 12 }}
{{- end }}
serviceAccount: gatekeeper-delete-webhook-configs
nodeSelector:
kubernetes.io/os: linux
containers:
- name: kubectl-delete
image: "{{ .Values.preUninstall.deleteWebhookConfigurations.image.repository }}:{{ .Values.preUninstall.deleteWebhookConfigurations.image.tag }}"
Expand All @@ -46,12 +44,22 @@ spec:
{{- if not .Values.disableMutation }}
- mutatingwebhookconfiguration/gatekeeper-mutating-webhook-configuration
{{- end }}
resources:
{{- toYaml .Values.preUninstall.resources | nindent 10 }}
securityContext:
{{- if .Values.enableRuntimeDefaultSeccompProfile }}
seccompProfile:
type: RuntimeDefault
{{- end }}
{{- toYaml .Values.preUninstall.securityContext | nindent 10 }}
{{- with .Values.preUninstall }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
affinity:
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
19 changes: 16 additions & 3 deletions cmd/build/helmify/static/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ postUpgrade:
"pod-security.kubernetes.io/warn-version=latest",
"pod-security.kubernetes.io/enforce=restricted",
"pod-security.kubernetes.io/enforce-version=v1.24"]
affinity: {}
tolerations: []
nodeSelector: {kubernetes.io/os: linux}
resources: {}
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand All @@ -55,8 +59,8 @@ postUpgrade:
runAsUser: 1000
postInstall:
labelNamespace:
extraRules: []
enabled: true
extraRules: []
image:
repository: openpolicyagent/gatekeeper-crds
tag: v3.10.0-beta.0
Expand All @@ -79,6 +83,9 @@ postInstall:
waitTimeout: 60
httpTimeout: 2
insecureHTTPS: false
affinity: {}
tolerations: []
nodeSelector: {kubernetes.io/os: linux}
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand All @@ -97,6 +104,10 @@ preUninstall:
tag: v3.10.0-beta.0
pullPolicy: IfNotPresent
pullSecrets: []
affinity: {}
tolerations: []
nodeSelector: {kubernetes.io/os: linux}
resources: {}
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down Expand Up @@ -173,7 +184,6 @@ audit:
affinity: {}
tolerations: []
nodeSelector: {kubernetes.io/os: linux}
writeToRAMDisk: false
resources:
limits:
cpu: 1000m
Expand All @@ -194,8 +204,12 @@ audit:
fsGroup: 999
supplementalGroups:
- 999
writeToRAMDisk: false
extraRules: []
crds:
affinity: {}
tolerations: []
nodeSelector: {kubernetes.io/os: linux}
resources: {}
securityContext:
allowPrivilegeEscalation: false
Expand All @@ -215,7 +229,6 @@ psp:
enabled: true
upgradeCRDs:
enabled: true
tolerations: []
extraRules: []
rbac:
create: true
2 changes: 2 additions & 0 deletions manifest_staging/charts/gatekeeper/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Output post install webhook probe container entry
{{- end }}
- "-v"
- "https://gatekeeper-webhook-service.{{ .Release.Namespace }}.svc/v1/admitlabel?timeout=2s"
resources:
{{- toYaml .Values.postInstall.resources | nindent 4 }}
securityContext:
{{- toYaml .Values.postInstall.securityContext | nindent 4 }}
volumeMounts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ spec:
{{- .Values.postInstall.labelNamespace.image.pullSecrets | toYaml | nindent 12 }}
{{- end }}
serviceAccount: gatekeeper-update-namespace-label
nodeSelector:
kubernetes.io/os: linux
{{- if .Values.postInstall.probeWebhook.enabled }}
volumes:
{{- include "gatekeeper.postInstallWebhookProbeVolume" . | nindent 8 }}
Expand All @@ -56,12 +54,22 @@ spec:
- {{ . }}
{{- end }}
- --overwrite
resources:
{{- toYaml .Values.postInstall.resources | nindent 12 }}
securityContext:
{{- if .Values.enableRuntimeDefaultSeccompProfile }}
seccompProfile:
type: RuntimeDefault
{{- end }}
{{- toYaml .Values.postInstall.securityContext | nindent 12 }}
{{- with .Values.postInstall }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
affinity:
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ spec:
{{- .Values.postUpgrade.labelNamespace.image.pullSecrets | toYaml | nindent 12 }}
{{- end }}
serviceAccount: gatekeeper-update-namespace-label-post-upgrade
nodeSelector:
kubernetes.io/os: linux
containers:
- name: kubectl-label
image: "{{ .Values.postUpgrade.labelNamespace.image.repository }}:{{ .Values.postUpgrade.labelNamespace.image.tag }}"
Expand All @@ -48,8 +46,18 @@ spec:
- {{ . }}
{{- end }}
- --overwrite
resources:
{{- toYaml .Values.postUpgrade.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.postUpgrade.securityContext | nindent 12 }}
{{- with .Values.postUpgrade }}
affinity:
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ spec:
imagePullSecrets:
{{- .Values.postInstall.probeWebhook.image.pullSecrets | toYaml | nindent 12 }}
{{- end }}
nodeSelector:
kubernetes.io/os: linux
volumes:
{{- include "gatekeeper.postInstallWebhookProbeVolume" . | nindent 8 }}
containers:
{{- include "gatekeeper.postInstallWebhookProbeContainer" . | nindent 8 }}
{{- with .Values.postInstall }}
affinity:
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ spec:
type: RuntimeDefault
{{- end }}
{{- toYaml .Values.crds.securityContext | nindent 10 }}
{{- with .Values.crds }}
affinity:
{{- toYaml .Values.upgradeCRDs.affinity | nindent 8 }}
nodeSelector:
kubernetes.io/os: linux
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .Values.upgradeCRDs.tolerations | nindent 8 }}
{{- toYaml .tolerations | nindent 8 }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ spec:
{{- .Values.preUninstall.deleteWebhookConfigurations.image.pullSecrets | toYaml | nindent 12 }}
{{- end }}
serviceAccount: gatekeeper-delete-webhook-configs
nodeSelector:
kubernetes.io/os: linux
containers:
- name: kubectl-delete
image: "{{ .Values.preUninstall.deleteWebhookConfigurations.image.repository }}:{{ .Values.preUninstall.deleteWebhookConfigurations.image.tag }}"
Expand All @@ -46,12 +44,22 @@ spec:
{{- if not .Values.disableMutation }}
- mutatingwebhookconfiguration/gatekeeper-mutating-webhook-configuration
{{- end }}
resources:
{{- toYaml .Values.preUninstall.resources | nindent 10 }}
securityContext:
{{- if .Values.enableRuntimeDefaultSeccompProfile }}
seccompProfile:
type: RuntimeDefault
{{- end }}
{{- toYaml .Values.preUninstall.securityContext | nindent 10 }}
{{- with .Values.preUninstall }}
nodeSelector:
{{- toYaml .nodeSelector | nindent 8 }}
affinity:
{{- toYaml .affinity | nindent 8 }}
tolerations:
{{- toYaml .tolerations | nindent 8 }}
{{- end }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
Loading