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 resource config for ServiceInit #758

Merged
merged 7 commits into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 7 additions & 6 deletions charts/consul/templates/mesh-gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,14 @@ spec:
mountPath: /consul/tls/ca
readOnly: true
{{- end }}
mark-vw marked this conversation as resolved.
Show resolved Hide resolved
{{- if .Values.meshGateway.initServiceInitContainer.resources }}
resources:
requests:
memory: "50Mi"
cpu: "50m"
limits:
memory: "50Mi"
cpu: "50m"
{{- if eq (typeOf .Values.meshGateway.initServiceInitContainer.resources) "string" }}
{{ tpl .Values.meshGateway.initServiceInitContainer.resources . | nindent 12 | trim }}
{{- else }}
{{- toYaml .Values.meshGateway.initServiceInitContainer.resources | nindent 12 }}
{{- end }}
{{- end }}
containers:
- name: mesh-gateway
image: {{ .Values.global.imageEnvoy | quote }}
Expand Down
44 changes: 44 additions & 0 deletions charts/consul/test/unit/mesh-gateway-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,50 @@ key2: value2' \
[ "${actual}" = "cpu2" ]
}

#--------------------------------------------------------------------
# service-init container resources

@test "meshGateway/Deployment: init service-init container has default resources" {
cd `chart_dir`
local actual=$(helm template \
-s templates/mesh-gateway-deployment.yaml \
--set 'meshGateway.enabled=true' \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.initContainers[1].resources' | tee /dev/stderr)

[ $(echo "${actual}" | yq -r '.requests.memory') = "50Mi" ]
[ $(echo "${actual}" | yq -r '.requests.cpu') = "50m" ]
[ $(echo "${actual}" | yq -r '.limits.memory') = "50Mi" ]
[ $(echo "${actual}" | yq -r '.limits.cpu') = "50m" ]
}

@test "meshGateway/Deployment: init service-init container resources can be set" {
cd `chart_dir`
local object=$(helm template \
-s templates/mesh-gateway-deployment.yaml \
--set 'meshGateway.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'meshGateway.initServiceInitContainer.resources.requests.memory=memory' \
--set 'meshGateway.initServiceInitContainer.resources.requests.cpu=cpu' \
--set 'meshGateway.initServiceInitContainer.resources.limits.memory=memory2' \
--set 'meshGateway.initServiceInitContainer.resources.limits.cpu=cpu2' \
. | tee /dev/stderr |
yq -r '.spec.template.spec.initContainers[1].resources' | tee /dev/stderr)

local actual=$(echo $object | yq -r '.requests.memory' | tee /dev/stderr)
[ "${actual}" = "memory" ]

local actual=$(echo $object | yq -r '.requests.cpu' | tee /dev/stderr)
[ "${actual}" = "cpu" ]

local actual=$(echo $object | yq -r '.limits.memory' | tee /dev/stderr)
[ "${actual}" = "memory2" ]

local actual=$(echo $object | yq -r '.limits.cpu' | tee /dev/stderr)
[ "${actual}" = "cpu2" ]
}
mark-vw marked this conversation as resolved.
Show resolved Hide resolved

#--------------------------------------------------------------------
# consul sidecar resources

Expand Down
12 changes: 12 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,18 @@ meshGateway:
memory: "150Mi"
cpu: "50m"

# Resource settings for the `service-init` init container.
# @recurse: false
# @type: map
initServiceInitContainer:
resources:
requests:
memory: "50Mi"
cpu: "50m"
limits:
memory: "50Mi"
cpu: "50m"

# By default, we set an anti-affinity so that two gateway pods won't be
# on the same node. NOTE: Gateways require that Consul client agents are
# also running on the nodes alongside each gateway pod.
Expand Down