-
Notifications
You must be signed in to change notification settings - Fork 16
Specify primary datacenter for root cert watch #368
Conversation
@@ -213,7 +216,8 @@ func (c *CertManager) Manage(ctx context.Context) error { | |||
c.logger.Trace("running cert manager") | |||
|
|||
rootWatch, err := watch.Parse(map[string]interface{}{ | |||
"type": "connect_roots", | |||
"datacenter": c.primaryDatacenter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every other change in this PR is to facilitate this one line where we specify the primary datacenter for our root cert watch. This is necessary for Gateways to work in the secondary datacenter of a federated setup.
Note We'll need a followup change in consul-k8s to provide the primary datacenter as a flag value to the controller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this flag in not set, does defaulting to empty string for this field infer the current datacenter and match existing behavior? (I'd expect it would be identical because of how Go would initialize the struct.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! You can see here that watch.Parse()
above just calls watch.ParseExempt()
which scans each value from the map into a variable on the &Plan{}
. In the case of datacenter
in particular, the zero value when not included in the map is ""
, not nil
, so the behavior doesn't change when your map includes {"datacenter": ""}
.
This is proven out by the conformance test run on this PR which does not set the primary-datacenter
flag but still functions as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending question about default behavior when the -primary-datacenter
flag isn't set and fixing the Consul Enterprise license to get CI tests passing.
@mikemorris thoughts on the release note added here? |
Fixes #361
Changes proposed in this PR:
In order to successfully watch root certs from a secondary datacenter, we must specify the name of the primary datacenter when setting up the watch. This requires that we accept the primary datacenter name as a flag when starting the controller. The other changes in this PR are just to plumb that value down into the watch initialization.
How I've tested this PR:
apiGateway.enabled: true
apiGateway.image: hashicorp/consul-api-gateway:0.4.0
global.imageK8S: hashicorpdev/consul-k8s-control-plane:f1a9304a
(build from server-acl-init: Create global ACL auth method for API Gateway in secondary dc consul-k8s#1481)Gateway
in the secondary cluster and apply routes targeting services in the same cluster (I use the stack from this Learn guide)Gateway
status and visithttps://<ip>:8443
Results from completing the above
How I expect reviewers to test this PR:
See above
Checklist: