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

Add tolerations and nodeSelector to Server ACL init jobs and nodeSelector to Webhook cert manager #1581

Merged
merged 10 commits into from
Oct 18, 2022
8 changes: 8 additions & 0 deletions charts/consul/templates/server-acl-init-cleanup-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ spec:
limits:
memory: "50Mi"
cpu: "50m"
{{- if .Values.global.acls.tolerations }}
tolerations:
{{ tpl .Values.global.acls.tolerations . | indent 8 | trim }}
{{- end }}
{{- if .Values.global.acls.nodeSelector }}
nodeSelector:
{{ tpl .Values.global.acls.nodeSelector . | indent 8 | trim }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ spec:
limits:
memory: "50Mi"
cpu: "50m"
{{- if .Values.global.acls.tolerations }}
tolerations:
{{ tpl .Values.global.acls.tolerations . | indent 8 | trim }}
{{- end }}
{{- if .Values.global.acls.nodeSelector }}
nodeSelector:
{{ tpl .Values.global.acls.nodeSelector . | indent 8 | trim }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ spec:
{{- if .Values.webhookCertManager.tolerations }}
tolerations:
{{ tpl .Values.webhookCertManager.tolerations . | indent 8 | trim }}
{{- end}}
{{- end }}
{{- if .Values.webhookCertManager.nodeSelector }}
nodeSelector:
{{ tpl .Values.webhookCertManager.nodeSelector . | indent 8 | trim }}
{{- end }}

{{- end }}
45 changes: 45 additions & 0 deletions charts/consul/test/unit/server-acl-init-cleanup-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,48 @@ load _helpers
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# global.acls.tolerations and global.acls.nodeSelector

@test "serverACLInitCleanup/Job: tolerations not set by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-cleanup-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.tolerations' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "serverACLInitCleanup/Job: tolerations can be set" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-cleanup-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.acls.tolerations=- key: value' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.tolerations[0].key' | tee /dev/stderr)
[ "${actual}" = "value" ]
}

@test "serverACLInitCleanup/Job: nodeSelector not set by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-cleanup-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.nodeSelector' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "serverACLInitCleanup/Job: nodeSelector can be set" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-cleanup-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.acls.nodeSelector=- key: value' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.nodeSelector[0].key' | tee /dev/stderr)
[ "${actual}" = "value" ]
}
45 changes: 45 additions & 0 deletions charts/consul/test/unit/server-acl-init-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,51 @@ load _helpers
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# global.acls.tolerations and global.acls.nodeSelector

@test "serverACLInit/Job: tolerations not set by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.tolerations' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "serverACLInit/Job: tolerations can be set" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.acls.tolerations=- key: value' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.tolerations[0].key' | tee /dev/stderr)
[ "${actual}" = "value" ]
}

@test "serverACLInit/Job: nodeSelector not set by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.nodeSelector' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "serverACLInit/Job: nodeSelector can be set" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.acls.nodeSelector=- key: value' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.nodeSelector[0].key' | tee /dev/stderr)
[ "${actual}" = "value" ]
}

#--------------------------------------------------------------------
# externalServers.enabled

Expand Down
23 changes: 23 additions & 0 deletions charts/consul/test/unit/webhook-cert-manager-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@ load _helpers
[ "${actual}" = "value" ]
}

@test "webhookCertManager/Deployment: no nodeSelector by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/webhook-cert-manager-deployment.yaml \
--set 'controller.enabled=true' \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.nodeSelector' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

@test "webhookCertManager/Deployment: nodeSelector can be set" {
cd `chart_dir`
local actual=$(helm template \
-s templates/webhook-cert-manager-deployment.yaml \
--set 'controller.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'webhookCertManager.nodeSelector=- key: value' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.nodeSelector[0].key' | tee /dev/stderr)
[ "${actual}" = "value" ]
}

#--------------------------------------------------------------------
# Vault

Expand Down
30 changes: 30 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,23 @@ global:
# @type: string
secretKey: null

# tolerations configures the taints and tolerations for the server-acl-init
# and server-acl-init-cleanup jobs. This should be a multi-line string matching the
# Tolerations (https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) array in a Pod spec.
tolerations: ""

# This value defines `nodeSelector` (https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector)
# labels for the server-acl-init and server-acl-init-cleanup jobs pod assignment, formatted as a multi-line string.
#
# Example:
#
# ```yaml
# nodeSelector: |
# beta.kubernetes.io/arch: amd64
# ```
#
# @type: string
nodeSelector: null

# [Enterprise Only] This value refers to a Kubernetes or Vault secret that you have created
# that contains your enterprise license. It is required if you are using an
Expand Down Expand Up @@ -3043,6 +3060,19 @@ webhookCertManager:
# @type: string
tolerations: null

# This value defines `nodeSelector` (https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector)
# labels for the webhook-cert-manager pod assignment, formatted as a multi-line string.
#
# Example:
#
# ```yaml
# nodeSelector: |
# beta.kubernetes.io/arch: amd64
# ```
#
# @type: string
nodeSelector: null

# Configures a demo Prometheus installation.
prometheus:
# When true, the Helm chart will install a demo Prometheus server instance
Expand Down