Skip to content

Commit

Permalink
remove consul-sidecar from values.yaml and bats tests
Browse files Browse the repository at this point in the history
  • Loading branch information
curtbushko committed Oct 19, 2022
1 parent 6b7111e commit 62d1d90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 166 deletions.
141 changes: 0 additions & 141 deletions charts/consul/test/unit/connect-inject-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1075,147 +1075,6 @@ load _helpers
[ "${actual}" = "false" ]
}

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

@test "connectInject/Deployment: default consul sidecar container resources" {
cd `chart_dir`
local cmd=$(helm template \
-s templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command' | tee /dev/stderr)

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-request=25Mi"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-request=20m"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-limit=50Mi"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-limit=20m"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "connectInject/Deployment: consul sidecar container resources can be set" {
cd `chart_dir`
local cmd=$(helm template \
-s templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
--set 'global.consulSidecarContainer.resources.requests.memory=100Mi' \
--set 'global.consulSidecarContainer.resources.requests.cpu=100m' \
--set 'global.consulSidecarContainer.resources.limits.memory=200Mi' \
--set 'global.consulSidecarContainer.resources.limits.cpu=200m' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command' | tee /dev/stderr)

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-request=100Mi"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-request=100m"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-limit=200Mi"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-limit=200m"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "connectInject/Deployment: consul sidecar container resources can be set explicitly to 0" {
cd `chart_dir`
local cmd=$(helm template \
-s templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
--set 'global.consulSidecarContainer.resources.requests.memory=0' \
--set 'global.consulSidecarContainer.resources.requests.cpu=0' \
--set 'global.consulSidecarContainer.resources.limits.memory=0' \
--set 'global.consulSidecarContainer.resources.limits.cpu=0' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command' | tee /dev/stderr)

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-request=0"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-request=0"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-limit=0"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-limit=0"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "connectInject/Deployment: consul sidecar container resources can be individually set to null" {
cd `chart_dir`
local cmd=$(helm template \
-s templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
--set 'global.consulSidecarContainer.resources.requests.memory=null' \
--set 'global.consulSidecarContainer.resources.requests.cpu=null' \
--set 'global.consulSidecarContainer.resources.limits.memory=null' \
--set 'global.consulSidecarContainer.resources.limits.cpu=null' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command' | tee /dev/stderr)

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-request"))' | tee /dev/stderr)
[ "${actual}" = "false" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-request"))' | tee /dev/stderr)
[ "${actual}" = "false" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-limit"))' | tee /dev/stderr)
[ "${actual}" = "false" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-limit"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

@test "connectInject/Deployment: consul sidecar container resources can be set to null" {
cd `chart_dir`
local cmd=$(helm template \
-s templates/connect-inject-deployment.yaml \
--set 'connectInject.enabled=true' \
--set 'global.consulSidecarContainer.resources=null' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command' | tee /dev/stderr)

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-request"))' | tee /dev/stderr)
[ "${actual}" = "false" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-request"))' | tee /dev/stderr)
[ "${actual}" = "false" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-memory-limit"))' | tee /dev/stderr)
[ "${actual}" = "false" ]

local actual=$(echo "$cmd" |
yq 'any(contains("-default-consul-sidecar-cpu-limit"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

#--------------------------------------------------------------------
# sidecarProxy.resources

Expand Down
28 changes: 3 additions & 25 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -620,28 +620,6 @@ global:
# @type: boolean
enableGatewayMetrics: true

# For connect-injected pods, the consul sidecar is responsible for metrics merging. For ingress/mesh/terminating
# gateways, it additionally ensures the Consul services are always registered with their local Consul client.
# @type: map
consulSidecarContainer:
# Set default resources for consul sidecar. If null, that resource won't
# be set.
# These settings can be overridden on a per-pod basis via these annotations:
#
# - `consul.hashicorp.com/consul-sidecar-cpu-limit`
# - `consul.hashicorp.com/consul-sidecar-cpu-request`
# - `consul.hashicorp.com/consul-sidecar-memory-limit`
# - `consul.hashicorp.com/consul-sidecar-memory-request`
# @recurse: false
# @type: map
resources:
requests:
memory: "25Mi"
cpu: "20m"
limits:
memory: "50Mi"
cpu: "20m"

# The name (and tag) of the Envoy Docker image used for the
# connect-injected sidecar proxies and mesh, terminating, and ingress gateways.
# See https://www.consul.io/docs/connect/proxies/envoy for full compatibility matrix between Consul and Envoy.
Expand Down Expand Up @@ -2114,18 +2092,18 @@ connectInject:
# add a listener on the Envoy sidecar to expose metrics. The exposed
# metrics will depend on whether metrics merging is enabled:
# - If metrics merging is enabled:
# the Consul sidecar will run a merged metrics server
# the consul-dataplane will run a merged metrics server
# combining Envoy sidecar and Connect service metrics,
# i.e. if your service exposes its own Prometheus metrics.
# - If metrics merging is disabled:
# the listener will just expose Envoy sidecar metrics.
# This will inherit from `global.metrics.enabled`.
defaultEnabled: "-"
# Configures the Consul sidecar to run a merged metrics server
# Configures the consul-dataplane to run a merged metrics server
# to combine and serve both Envoy and Connect service metrics.
# This feature is available only in Consul v1.10.0 or greater.
defaultEnableMerging: false
# Configures the port at which the Consul sidecar will listen on to return
# Configures the port at which the consul-dataplane will listen on to return
# combined metrics. This port only needs to be changed if it conflicts with
# the application's ports.
defaultMergedMetricsPort: 20100
Expand Down

0 comments on commit 62d1d90

Please sign in to comment.