-
Notifications
You must be signed in to change notification settings - Fork 326
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -199,11 +199,12 @@ func TestVault_WANFederationViaGateways(t *testing.T) { | |||||||||||
|
||||||||||||
// Get the address of the mesh gateway. | ||||||||||||
primaryMeshGWAddress := meshGatewayAddress(t, cfg, primaryCtx, consulReleaseName) | ||||||||||||
serverExtraConfig := fmt.Sprintf(`"{\"primary_gateways\":[\"%s\"]\,\"primary_datacenter\":\"dc1\"}"`, primaryMeshGWAddress) | ||||||||||||
secondaryConsulHelmValues := map[string]string{ | ||||||||||||
"global.datacenter": "dc2", | ||||||||||||
|
||||||||||||
"global.federation.enabled": "true", | ||||||||||||
"global.federation.enabled": "true", | ||||||||||||
"global.federation.primaryDatacenter": "dc1", | ||||||||||||
"global.federation.primaryGateways[0]": primaryMeshGWAddress, | ||||||||||||
|
||||||||||||
// TLS config. | ||||||||||||
"global.tls.enabled": "true", | ||||||||||||
|
@@ -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, | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: consul-k8s/acceptance/tests/mesh-gateway/mesh_gateway_test.go Lines 76 to 80 in ae206c9
|
||||||||||||
|
||||||||||||
// Vault config. | ||||||||||||
"global.secretsBackend.vault.enabled": "true", | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -492,4 +492,42 @@ load _helpers | |
. | tee /dev/stderr | | ||
yq '.data["connect-ca-config.json"] | contains("\"ca_file\": \"/consul/vault-ca/tls.crt\"")' | tee /dev/stderr) | ||
[ "${actual}" = "true" ] | ||
} | ||
|
||
@test "server/ConfigMap: doesn't add federation config by default" { | ||
cd `chart_dir` | ||
local actual=$(helm template \ | ||
-s templates/server-config-configmap.yaml \ | ||
. | tee /dev/stderr | | ||
yq '.data["federation-config.json"] | length > 0' | tee /dev/stderr) | ||
[ "${actual}" = "false" ] | ||
} | ||
|
||
@test "server/ConfigMap: adds empty federation config when global.federation.enabled is true" { | ||
cd `chart_dir` | ||
local actual=$(helm template \ | ||
-s templates/server-config-configmap.yaml \ | ||
--set 'global.federation.enabled=true' \ | ||
--set 'global.tls.enabled=true' \ | ||
--set 'meshGateway.enabled=true' \ | ||
--set 'connectInject.enabled=true' \ | ||
. | tee /dev/stderr | | ||
yq '.data["federation-config.json"]' | tee /dev/stderr) | ||
[ "${actual}" = '"{\n \"primary_datacenter\": \"\",\n \"primary_gateways\": []\n}"' ] | ||
} | ||
|
||
@test "server/ConfigMap: can set primary dc and gateways when global.federation.enabled is true" { | ||
cd `chart_dir` | ||
local actual=$(helm template \ | ||
-s templates/server-config-configmap.yaml \ | ||
--set 'global.federation.enabled=true' \ | ||
--set 'global.federation.primaryDatacenter=dc1' \ | ||
--set 'global.federation.primaryGateways[0]=1.1.1.1:443' \ | ||
--set 'global.federation.primaryGateways[1]=2.2.2.2:443' \ | ||
--set 'global.tls.enabled=true' \ | ||
--set 'meshGateway.enabled=true' \ | ||
--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}"' ] | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the behavior if the user sets this configuration using There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,6 +430,14 @@ global: | |
# `<helm-release-name>-consul-federation`. | ||
createFederationSecret: false | ||
|
||
# The name of the primary datacenter. | ||
primaryDatacenter: "" | ||
Comment on lines
+433
to
+434
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
# A list of addresses of the primary mesh gateways in the form <ip>:<port>. | ||
ishustava marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# (e.g. ["1.1.1.1:443", "2.3.4.5:443"] | ||
# @type: array<string> | ||
primaryGateways: [] | ||
|
||
# Configures metrics for Consul service mesh | ||
metrics: | ||
# Configures the Helm chart’s components | ||
|
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.
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.