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

Allow configuring primary DC and gateways via designated Helm values #1038

Merged
merged 2 commits into from
Feb 22, 2022

Conversation

ishustava
Copy link
Contributor

Changes proposed in this PR:

  • Add global.federation.primaryDatacenter and global.federation.primaryGateway to allow users to specify these values directly rather than via server.extraConfig or server.extraVolumes

Note that we will keep the existing behavior of create-federation-secret that generates the serverExtraConfig with those values for the time being and will re-assess it when the ACL work to switch out tokens for auth methods will be complete as it will likely affect it. So at the moment we will allow using both methods, and if the user provides these values via any of the server.extra* values, they will take precedence.

How I've tested this PR:
vault acceptance tests

How I expect reviewers to test this PR:
👀

Checklist:

  • Tests added
  • CHANGELOG entry added

    HashiCorp engineers only, community PRs should not add a changelog entry.
    Entries should use present tense (e.g. Add support for...)

@ishustava ishustava requested review from a team, curtbushko and t-eckert and removed request for a team and t-eckert February 18, 2022 22:29
@ishustava ishustava force-pushed the ishustava/wan-fed-helm-values branch 2 times, most recently from 346f5a3 to 8abf5c3 Compare February 18, 2022 22:36
@ishustava ishustava force-pushed the ishustava/wan-fed-helm-values branch from 8abf5c3 to 93e6f56 Compare February 18, 2022 22:45
Comment on lines +67 to +70
if t.EnterpriseLicense != "" {
setIfNotEmpty(helmValues, "global.enterpriseLicense.secretName", LicenseSecretName)
setIfNotEmpty(helmValues, "global.enterpriseLicense.secretKey", LicenseSecretKey)
}
Copy link
Contributor Author

@ishustava ishustava Feb 18, 2022

Choose a reason for hiding this comment

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

we only want to set it when enterprise is enabled. Otherwise, we will always set enterpriseLicense helm values which will now break when running with Vault.

@ishustava ishustava added the type/enhancement New feature or request label Feb 18, 2022
@@ -229,7 +230,6 @@ func TestVault_WANFederationViaGateways(t *testing.T) {
"server.extraVolumes[0].type": "secret",
"server.extraVolumes[0].name": vaultCASecretName,
"server.extraVolumes[0].load": "false",
"server.extraConfig": serverExtraConfig,
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if it would be worthwhile to keep a test where this is set via extra config, but I don't really think it is because at that point it would just be testing something that should be covered by the bats tests. So I think it's the right move to just modify the test.

Copy link
Contributor Author

@ishustava ishustava Feb 22, 2022

Choose a reason for hiding this comment

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

We do use server extra config (via volumes) in the mesh_gateway_test which doesn't use vault:

"server.extraVolumes[0].type": "secret",
"server.extraVolumes[0].name": federationSecretName,
"server.extraVolumes[0].load": "true",
"server.extraVolumes[0].items[0].key": "serverConfigJSON",
"server.extraVolumes[0].items[0].path": "config.json",

Comment on lines +433 to +434
# The name of the primary datacenter.
primaryDatacenter: ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Depending on how much context a user would have by the time they are setting this value, it may be valuable to note what the significance of the primary datacenter is to the behavior of federation. In the past, users have been capable of figuring this out and adding it via extra config, so it may not be a problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

It also may be worthwhile to add further context to the parent of this item linking the user to the federation documentation: https://www.consul.io/docs/k8s/installation/multi-cluster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think most users are familiar with the concept of datacenter in Consul and also that is the value they provide via global.datacenter Helm value in the primary. I don't know if it makes sense to reference this value here because their primary datacenter could be on VMs. wdyt?

--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq '.data["federation-config.json"]' | tee /dev/stderr)
[ "${actual}" = '"{\n \"primary_datacenter\": \"dc1\",\n \"primary_gateways\": [\"1.1.1.1:443\",\"2.2.2.2:443\"]\n}"' ]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the behavior if the user sets this configuration using serverExtraConfig and sets it using these flags? Is it worth testing that scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The server extraConfig will override these settings (this is also the case in the general with extraConfig: it'll override any settings we set in the helm chart). Good question about testing - I don't think so and it'll also be hard to test with helm templates because these are provided via separate flags to the consul agent command. And so we'll be testing that one flag is provided after the other, and I don't know if there's a lot of value in that.

Copy link
Contributor

@t-eckert t-eckert left a comment

Choose a reason for hiding this comment

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

This looks fantastic, Iryna. I had some hot cocoa and free time so I went ahead and gave this a look tonight.

My only concern is making sure we understand the behavior if the user sets primary_datacenter and primary_gateways using both serverExtraConfig and the new keys.

I made the relevant comment in the bats test, but it really makes more sense in the integration test. All the same, I think it's an edge case.

@ishustava ishustava merged commit dcac9ab into main Feb 22, 2022
@ishustava ishustava deleted the ishustava/wan-fed-helm-values branch February 22, 2022 18:35
@jmurret jmurret added the theme/federation Related to federating Consul datacenters label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/federation Related to federating Consul datacenters type/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants