Skip to content

Commit

Permalink
Cleanup: remove consul-sidecar code, annotations and tests
Browse files Browse the repository at this point in the history
Cleanup: remove consul-sidecar code, annotations and tests
remove consul-sidecar from values.yaml and bats tests
  • Loading branch information
curtbushko committed Oct 19, 2022
1 parent f9fe189 commit 87630a7
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 2,077 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 @@ -590,28 +590,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 @@ -2089,18 +2067,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
5 changes: 0 additions & 5 deletions control-plane/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
cmdACLInit "github.com/hashicorp/consul-k8s/control-plane/subcommand/acl-init"
cmdConnectInit "github.com/hashicorp/consul-k8s/control-plane/subcommand/connect-init"
cmdConsulLogout "github.com/hashicorp/consul-k8s/control-plane/subcommand/consul-logout"
cmdConsulSidecar "github.com/hashicorp/consul-k8s/control-plane/subcommand/consul-sidecar"
cmdController "github.com/hashicorp/consul-k8s/control-plane/subcommand/controller"
cmdCreateFederationSecret "github.com/hashicorp/consul-k8s/control-plane/subcommand/create-federation-secret"
cmdDeleteCompletedJob "github.com/hashicorp/consul-k8s/control-plane/subcommand/delete-completed-job"
Expand Down Expand Up @@ -43,10 +42,6 @@ func init() {
return &cmdInjectConnect.Command{UI: ui}, nil
},

"consul-sidecar": func() (cli.Command, error) {
return &cmdConsulSidecar.Command{UI: ui}, nil
},

"consul-logout": func() (cli.Command, error) {
return &cmdConsulLogout.Command{UI: ui}, nil
},
Expand Down
6 changes: 0 additions & 6 deletions control-plane/connect-inject/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ const (
annotationSidecarProxyMemoryLimit = "consul.hashicorp.com/sidecar-proxy-memory-limit"
annotationSidecarProxyMemoryRequest = "consul.hashicorp.com/sidecar-proxy-memory-request"

// annotations for consul sidecar resource limits.
annotationConsulSidecarCPULimit = "consul.hashicorp.com/consul-sidecar-cpu-limit"
annotationConsulSidecarCPURequest = "consul.hashicorp.com/consul-sidecar-cpu-request"
annotationConsulSidecarMemoryLimit = "consul.hashicorp.com/consul-sidecar-memory-limit"
annotationConsulSidecarMemoryRequest = "consul.hashicorp.com/consul-sidecar-memory-request"

// annotations for sidecar volumes.
annotationConsulSidecarUserVolume = "consul.hashicorp.com/consul-sidecar-user-volume"
annotationConsulSidecarUserVolumeMount = "consul.hashicorp.com/consul-sidecar-user-volume-mount"
Expand Down
115 changes: 0 additions & 115 deletions control-plane/connect-inject/consul_sidecar.go

This file was deleted.

Loading

0 comments on commit 87630a7

Please sign in to comment.