Skip to content

Commit

Permalink
Merge pull request #1732 from hashicorp/as/dynamic-discovery-opt-in
Browse files Browse the repository at this point in the history
Add opt-in server discovery for API Gateway Controller
  • Loading branch information
Andrew Stucki authored Nov 17, 2022
2 parents a14f597 + de70298 commit 0d0333d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ IMPROVEMENTS:
* Allow addition of extra labels to Connect Inject pods. [[GH-1678](https://github.com/hashicorp/consul-k8s/pull/1678)]
* Add fields `localConnectTimeoutMs` and `localRequestTimeoutMs` to the `ServiceDefaults` CRD. [[GH-1647](https://github.com/hashicorp/consul-k8s/pull/1647)]
* API Gateway: Enable API Gateways to directly connect to Consul servers when running in the agentless configuration. [[GH-1694](https://github.com/hashicorp/consul-k8s/pull/1694)]
* API Gateway: Add support for using dynamic server discovery strings when running without agents. [[GH-1732](https://github.com/hashicorp/consul-k8s/pull/1732)]

BUG FIXES:
* Peering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ spec:
value: {{ .Values.global.adminPartitions.name }}
{{- end }}
{{- end }}
{{- if not .Values.client.enabled }}
- name: CONSUL_DYNAMIC_SERVER_DISCOVERY
value: "true"
{{- end }}
command:
- "/bin/sh"
- "-ec"
Expand Down
24 changes: 24 additions & 0 deletions charts/consul/test/unit/api-gateway-controller-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1346,3 +1346,27 @@ load _helpers
yq '.spec.template.spec.containers[0].env[6].value == "hashi"' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "apiGateway/Deployment: CONSUL_DYNAMIC_SERVER_DISCOVERY is set when not using clients" {
cd `chart_dir`
local actual=$(helm template \
-s templates/api-gateway-controller-deployment.yaml \
--set 'apiGateway.enabled=true' \
--set 'apiGateway.image=bar' \
--set 'client.enabled=false' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].env[3].value == "true"' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "apiGateway/Deployment: CONSUL_DYNAMIC_SERVER_DISCOVERY is not set when using clients" {
cd `chart_dir`
local actual=$(helm template \
-s templates/api-gateway-controller-deployment.yaml \
--set 'apiGateway.enabled=true' \
--set 'apiGateway.image=bar' \
--set 'client.enabled=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].env[3]' | tee /dev/stderr)
[ "${actual}" = "null" ]
}

0 comments on commit 0d0333d

Please sign in to comment.