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

Expose new options for API Gateway's High Availability feature #1261

Merged
merged 10 commits into from
Jun 13, 2022
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ IMPROVEMENTS:
* Enable the configuring of snapshot intervals in the client snapshot agent via `client.snapshotAgent.interval`. [[GH-1235](https://github.com/hashicorp/consul-k8s/pull/1235)]
* Enable configuring the pod topologySpreadConstraints for mesh, terminating, and ingress gateways. [[GH-1257](https://github.com/hashicorp/consul-k8s/pull/1257)]
* Present Consul server CA chain when using Vault secrets backend. [[GH-1251](https://github.com/hashicorp/consul-k8s/pull/1251)]
* API Gateway: Enable configuring of the new High Availability feature (requires Consul API Gateway v0.3.0+). [[GH-1261](https://github.com/hashicorp/consul-k8s/pull/1261)]
* Control Plane
* Bump Dockerfile base image for RedHat UBI `consul-k8s-control-plane` image to `ubi-minimal:8.6`. [[GH-1244](https://github.com/hashicorp/consul-k8s/pull/1244)]
* Add additional metadata to service instances registered via catalog sync. [[GH-447](https://github.com/hashicorp/consul-k8s/pull/447)]
Expand Down
4 changes: 4 additions & 0 deletions charts/consul/templates/api-gateway-gatewayclassconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ spec:
{{- else }}
http: 8500
{{- end }}
{{- with .Values.apiGateway.managedGatewayClass.deployment }}
deployment:
{{- toYaml . | nindent 4 }}
{{- end }}
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved
image:
consulAPIGateway: {{ .Values.apiGateway.image }}
envoy: {{ .Values.global.imageEnvoy }}
Expand Down
68 changes: 68 additions & 0 deletions charts/consul/test/unit/api-gateway-gatewayclassconfig.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bats

load _helpers

@test "apiGateway/GatewayClassConfig: disabled by default" {
cd `chart_dir`
assert_empty helm template \
-s templates/api-gateway-gatewayclassconfig.yaml \
.
}

@test "apiGateway/GatewayClassConfig: enabled with apiGateway.enabled=true" {
cd `chart_dir`
local actual=$(helm template \
-s templates/api-gateway-gatewayclassconfig.yaml \
--set 'apiGateway.enabled=true' \
--set 'apiGateway.image=foo' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "apiGateway/GatewayClassConfig: deployment config disabled by default" {
cd `chart_dir`
local actual=$(helm template \
-s templates/api-gateway-gatewayclassconfig.yaml \
--set 'apiGateway.enabled=true' \
--set 'apiGateway.image=foo' \
. | tee /dev/stderr |
yq '.spec | has("deployment") | not' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "apiGateway/GatewayClassConfig: deployment config enabled with defaultInstances=3" {
cd `chart_dir`
local actual=$(helm template \
-s templates/api-gateway-gatewayclassconfig.yaml \
--set 'apiGateway.enabled=true' \
--set 'apiGateway.image=foo' \
--set 'apiGateway.managedGatewayClass.deployment.defaultInstances=3' \
. | tee /dev/stderr |
yq '.spec.deployment.defaultInstances == 3' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "apiGateway/GatewayClassConfig: deployment config enabled with maxInstances=3" {
cd `chart_dir`
local actual=$(helm template \
-s templates/api-gateway-gatewayclassconfig.yaml \
--set 'apiGateway.enabled=true' \
--set 'apiGateway.image=foo' \
--set 'apiGateway.managedGatewayClass.deployment.maxInstances=3' \
. | tee /dev/stderr |
yq '.spec.deployment.maxInstances == 3' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "apiGateway/GatewayClassConfig: deployment config enabled with minInstances=3" {
cd `chart_dir`
local actual=$(helm template \
-s templates/api-gateway-gatewayclassconfig.yaml \
--set 'apiGateway.enabled=true' \
--set 'apiGateway.image=foo' \
--set 'apiGateway.managedGatewayClass.deployment.minInstances=3' \
. | tee /dev/stderr |
yq '.spec.deployment.minInstances == 3' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
14 changes: 14 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,20 @@ apiGateway:
# @type: string
service: null

# This value defines the number of pods to deploy for each Gateway as well as a min and max number of pods for all Gateways
#
# Example:
#
# ```yaml
# deployment:
# defaultInstances: 3
# maxInstances: 8
# minInstances: 1
Comment on lines +2716 to +2719
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does a user know what are all possible values for deployment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation is being added alongside our 0.3.0 release here.

The 3 listed above are all that's supported with our upcoming release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to link to those docs here? Because folks will also see this through https://www.consul.io/docs/k8s/helm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can link those, noting that the docs content in the PR linked above won't actually be there for about a week after the consul-k8s release containing this change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh understood. Yeah then we can add it later instead.

# ```
#
# @type: map
deployment: null

# Configuration for the ServiceAccount created for the api-gateway component
serviceAccount:
# This value defines additional annotations for the client service account. This should be formatted as a multi-line
Expand Down