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 configurable server-acl-init and cleanup resource limits #2416

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .changelog/2416.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
helm: Adds `acls.resources` field which can be configured to override the `resource` settings for the `server-acl-init` and `server-acl-init-cleanup` Jobs.
```
9 changes: 3 additions & 6 deletions charts/consul/templates/server-acl-init-cleanup-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,10 @@ spec:
- -log-json={{ .Values.global.logJSON }}
- -k8s-namespace={{ .Release.Namespace }}
- {{ template "consul.fullname" . }}-server-acl-init
{{- if .Values.global.acls.resources }}
resources:
requests:
memory: "50Mi"
cpu: "50m"
limits:
memory: "50Mi"
cpu: "50m"
{{- toYaml .Values.global.acls.resources | nindent 12 }}
{{- end }}
{{- if .Values.global.acls.tolerations }}
tolerations:
{{ tpl .Values.global.acls.tolerations . | indent 8 | trim }}
Expand Down
9 changes: 3 additions & 6 deletions charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,10 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.global.acls.resources }}
resources:
requests:
memory: "50Mi"
cpu: "50m"
limits:
memory: "50Mi"
cpu: "50m"
{{- toYaml .Values.global.acls.resources | nindent 10 }}
{{- end }}
{{- if .Values.global.acls.tolerations }}
tolerations:
{{ tpl .Values.global.acls.tolerations . | indent 8 | trim }}
Expand Down
24 changes: 24 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 @@ -159,3 +159,27 @@ load _helpers
[ "${actualTemplateFoo}" = "bar" ]
[ "${actualTemplateBaz}" = "qux" ]
}

#--------------------------------------------------------------------
# resources

@test "serverACLInitCleanup/Job: resources defined 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 -rc '.spec.template.spec.containers[0].resources' | tee /dev/stderr)
[ "${actual}" = '{"limits":{"cpu":"50m","memory":"50Mi"},"requests":{"cpu":"50m","memory":"50Mi"}}' ]
}

@test "serverACLInitCleanup/Job: resources can be overridden" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-cleanup-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.acls.resources.foo=bar' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].resources.foo' | tee /dev/stderr)
[ "${actual}" = "bar" ]
}
24 changes: 24 additions & 0 deletions charts/consul/test/unit/server-acl-init-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2202,3 +2202,27 @@ load _helpers
[ "${actualTemplateFoo}" = "bar" ]
[ "${actualTemplateBaz}" = "qux" ]
}

#--------------------------------------------------------------------
# resources

@test "serverACLInit/Job: resources defined 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 -rc '.spec.template.spec.containers[0].resources' | tee /dev/stderr)
[ "${actual}" = '{"limits":{"cpu":"50m","memory":"50Mi"},"requests":{"cpu":"50m","memory":"50Mi"}}' ]
}

@test "serverACLInit/Job: resources can be overridden" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.acls.resources.foo=bar' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.containers[0].resources.foo' | tee /dev/stderr)
[ "${actual}" = "bar" ]
}
27 changes: 27 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,33 @@ global:
# @type: string
secretKey: null

# The resource requests (CPU, memory, etc.) for the server-acl-init and server-acl-init-cleanup pods.
# This should be a YAML map corresponding to a Kubernetes
# [`ResourceRequirements``](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#resourcerequirements-v1-core)
# object.
#
# Example:
#
# ```yaml
# resources:
# requests:
# memory: '200Mi'
# cpu: '100m'
# limits:
# memory: '200Mi'
# cpu: '100m'
# ```
#
# @recurse: false
# @type: map
resources:
requests:
memory: "50Mi"
cpu: "50m"
limits:
memory: "50Mi"
cpu: "50m"
thisisnotashwin marked this conversation as resolved.
Show resolved Hide resolved

# partitionToken references a Vault secret containing the ACL token to be used in non-default partitions.
# This value should only be provided in the default partition and only when setting
# the `global.secretsBackend.vault.enabled` value to true.
Expand Down