Skip to content

Commit

Permalink
Populate primary dc flag for APIGW controller in secondary federated …
Browse files Browse the repository at this point in the history
…dc (#1511)

* Populate primary dc flag for APIGW controller in secondary federated dc

* Add test coverage for primary-datacenter flag

* Add changelog entry

* Update CHANGELOG.md

Co-authored-by: Kyle Schochenmaier <kschoche@gmail.com>

Co-authored-by: Kyle Schochenmaier <kschoche@gmail.com>
  • Loading branch information
nathancoleman and kschoche authored Sep 23, 2022
1 parent 5f0eb3e commit 2b2a8ed
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ BUG FIXES:
* Control plane
* Use global ACL auth method to provision ACL tokens for API Gateway in secondary datacenter [[GH-1481](https://github.com/hashicorp/consul-k8s/pull/1481)]

IMPROVEMENTS:
* Helm:
* API Gateway: Set primary datacenter flag when deploying controller into secondary datacenter with federation enabled [[GH-1511](https://github.com/hashicorp/consul-k8s/pull/1511)]

## 0.48.0 (September 01, 2022)

FEATURES:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if and .Values.global.federation.enabled .Values.global.federation.primaryDatacenter }}
-primary-datacenter={{ .Values.global.federation.primaryDatacenter }} \
{{- end }}
-log-level {{ default .Values.global.logLevel .Values.apiGateway.logLevel }} \
-log-json={{ .Values.global.logJSON }}
volumeMounts:
Expand Down
26 changes: 26 additions & 0 deletions charts/consul/test/unit/api-gateway-controller-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,32 @@ load _helpers
[ "${actual}" = "true" ]
}

@test "apiGateway/Deployment: primary-datacenter flag provided when federation enabled in non-primary datacenter" {
cd `chart_dir`
local object=$(helm template \
-s templates/api-gateway-controller-deployment.yaml \
--set 'apiGateway.enabled=true' \
--set 'apiGateway.image=foo' \
--set 'meshGateway.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'global.tls.enabled=true' \
--set 'global.tls.enableAutoEncrypt=true' \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.datacenter=dc2' \
--set 'global.federation.enabled=true' \
--set 'global.federation.primaryDatacenter=dc1' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[] | select(.name == "api-gateway-controller")' | tee /dev/stderr)

local actual=$(echo $object |
yq -r '.command | any(contains("consul-api-gateway server"))' | tee /dev/stderr)
[ "${actual}" = "true" ]

local actual=$(echo $object |
yq -r '.command | any(contains("-primary-datacenter=dc1"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "apiGateway/Deployment: init container is created when global.acls.manageSystemACLs=true and has correct command when federation enabled in non-primary datacenter" {
cd `chart_dir`
local object=$(helm template \
Expand Down

0 comments on commit 2b2a8ed

Please sign in to comment.