Skip to content

Commit

Permalink
add resource config for mesh gw service-init (#758)
Browse files Browse the repository at this point in the history
* Add resource settings for mesh gw service-init
  • Loading branch information
mark-vw authored Oct 5, 2021
1 parent 2443bff commit 57fc0c9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
10 changes: 3 additions & 7 deletions charts/consul/templates/mesh-gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,9 @@ spec:
mountPath: /consul/tls/ca
readOnly: true
{{- end }}
resources:
requests:
memory: "50Mi"
cpu: "50m"
limits:
memory: "50Mi"
cpu: "50m"
{{- if .Values.meshGateway.initServiceInitContainer.resources }}
resources: {{ toYaml .Values.meshGateway.initServiceInitContainer.resources | nindent 12 }}
{{- 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" ]
}

#--------------------------------------------------------------------
# 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 @@ -2004,6 +2004,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

0 comments on commit 57fc0c9

Please sign in to comment.