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

Revert 1.12 TLS config to ensure 1.11 image is also supported. #1218

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

BREAKING CHANGES:
* Helm
* Using the Vault integration requires Consul 1.12.0+. [[GH-1213](https://github.com/hashicorp/consul-k8s/pull/1213)]
* Using the Vault integration requires Consul 1.12.0+. [[GH-1213](https://github.com/hashicorp/consul-k8s/pull/1213)], [[GH-1218](https://github.com/hashicorp/consul-k8s/pull/1218)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry not trying to be nitpicky here, but should we specify if this is Vault as the connect-ca, or the vault secrets backend or both?

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 who are using Vault for either will be ok migrating to 1.12 which is why this was left generic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool that makes sense!


IMPROVEMENTS:
* Helm
Expand All @@ -17,6 +17,7 @@ BUG FIXES:
* Add Admin Partitions support to Sync Catalog **(Consul Enterprise only)**. [[GH-1180](https://github.com/hashicorp/consul-k8s/pull/1180)]
* Correct webhook-cert-manager-clusterrole to utilize the web-cert-manager podsecuritypolicy rather than connect-injectors when `global.enablePodSecurityPolicies` is true. [[GH-1202](https://github.com/hashicorp/consul-k8s/pull/1202)]
* Enable Consul auto-reload-config only when Vault is enabled. [[GH-1213](https://github.com/hashicorp/consul-k8s/pull/1213)]
* Revert TLS config to be compatible with Consul 1.11. [[GH-1218](https://github.com/hashicorp/consul-k8s/pull/1218)]

## 0.43.0 (April 21, 2022)

Expand Down
14 changes: 7 additions & 7 deletions charts/consul/templates/client-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -285,22 +285,22 @@ spec:
-hcl='leave_on_terminate = true' \
{{- if .Values.global.tls.enabled }}
{{- if .Values.global.secretsBackend.vault.enabled }}
-hcl='tls { defaults { ca_file = "/vault/secrets/serverca.crt" }}' \
-hcl='ca_file = "/vault/secrets/serverca.crt"' \
{{- else }}
-hcl='tls { defaults { ca_file = "/consul/tls/ca/tls.crt" }}' \
-hcl='ca_file = "/consul/tls/ca/tls.crt"' \
{{- end }}
{{- if .Values.global.tls.enableAutoEncrypt }}
-hcl='auto_encrypt = {tls = true}' \
-hcl="auto_encrypt = {ip_san = [\"$HOST_IP\",\"$POD_IP\"]}" \
{{- else }}
-hcl='tls { defaults { cert_file = "/consul/tls/client/tls.crt" }}' \
-hcl='tls { defaults { key_file = "/consul/tls/client/tls.key" }}' \
-hcl='cert_file = "/consul/tls/client/tls.crt"' \
-hcl='key_file = "/consul/tls/client/tls.key"' \
{{- end }}
{{- if .Values.global.tls.verify }}
-hcl='tls { defaults { verify_outgoing = true }}' \
-hcl='verify_outgoing = true' \
{{- if not .Values.global.tls.enableAutoEncrypt }}
-hcl='tls { internal_rpc { verify_incoming = true }}' \
-hcl='tls { internal_rpc { verify_server_hostname = true }}' \
-hcl='verify_incoming_rpc = true' \
-hcl='verify_server_hostname = true' \
{{- end }}
{{- end }}
-hcl='ports { https = 8501 }' \
Expand Down
36 changes: 14 additions & 22 deletions charts/consul/templates/server-config-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,25 @@ data:
{{- if .Values.global.tls.enabled }}
tls-config.json: |-
{
"tls": {
{{- if .Values.global.tls.verify }}
"internal_rpc": {
"verify_incoming": true,
"verify_server_hostname": true
},
{{- end }}
"defaults": {
{{- if .Values.global.tls.verify }}
"verify_outgoing": true,
{{- end }}
{{- if .Values.global.secretsBackend.vault.enabled }}
"ca_file": "/vault/secrets/serverca.crt",
"cert_file": "/vault/secrets/servercert.crt",
"key_file": "/vault/secrets/servercert.key"
{{- else }}
"ca_file": "/consul/tls/ca/tls.crt",
"cert_file": "/consul/tls/server/tls.crt",
"key_file": "/consul/tls/server/tls.key"
{{- end }}
}
},
{{- if .Values.global.secretsBackend.vault.enabled }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be my browser but it looks like the indentation is off for these two blocks. I don't think it makes a functional difference tho with JSON?

"ca_file": "/vault/secrets/serverca.crt",
"cert_file": "/vault/secrets/servercert.crt",
"key_file": "/vault/secrets/servercert.key",
{{- else }}
"ca_file": "/consul/tls/ca/tls.crt",
"cert_file": "/consul/tls/server/tls.crt",
"key_file": "/consul/tls/server/tls.key",
{{- end }}
{{- if .Values.global.tls.enableAutoEncrypt }}
"auto_encrypt": {
"allow_tls": true
},
{{- end }}
{{- if .Values.global.tls.verify }}
"verify_incoming_rpc": true,
"verify_outgoing": true,
"verify_server_hostname": true,
{{- end }}
"ports": {
{{- if .Values.global.tls.httpsOnly }}
"http": -1,
Expand Down
6 changes: 3 additions & 3 deletions charts/consul/test/unit/client-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -903,13 +903,13 @@ load _helpers
yq '.spec.template.spec.containers[0].command | join(" ")' | tee /dev/stderr)

local actual
actual=$(echo $command | jq -r '. | contains("tls { internal_rpc { verify_incoming = true }}")' | tee /dev/stderr)
actual=$(echo $command | jq -r '. | contains("verify_incoming_rpc = true")' | tee /dev/stderr)
[ "${actual}" = "true" ]

actual=$(echo $command | jq -r '. | contains("tls { defaults { verify_outgoing = true }}")' | tee /dev/stderr)
actual=$(echo $command | jq -r '. | contains("verify_outgoing = true")' | tee /dev/stderr)
[ "${actual}" = "true" ]

actual=$(echo $command | jq -r '. | contains("tls { internal_rpc { verify_server_hostname = true }}")' | tee /dev/stderr)
actual=$(echo $command | jq -r '. | contains("verify_server_hostname = true")' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

Expand Down
25 changes: 14 additions & 11 deletions charts/consul/test/unit/server-config-configmap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -678,22 +678,22 @@ load _helpers
yq -r '.data["tls-config.json"]' | tee /dev/stderr)

local actual
actual=$(echo $config | jq -r .tls.defaults.ca_file | tee /dev/stderr)
actual=$(echo $config | jq -r .ca_file | tee /dev/stderr)
[ "${actual}" = "/consul/tls/ca/tls.crt" ]

actual=$(echo $config | jq -r .tls.defaults.cert_file | tee /dev/stderr)
actual=$(echo $config | jq -r .cert_file | tee /dev/stderr)
[ "${actual}" = "/consul/tls/server/tls.crt" ]

actual=$(echo $config | jq -r .tls.defaults.key_file | tee /dev/stderr)
actual=$(echo $config | jq -r .key_file | tee /dev/stderr)
[ "${actual}" = "/consul/tls/server/tls.key" ]

actual=$(echo $config | jq -r .tls.internal_rpc.verify_incoming | tee /dev/stderr)
actual=$(echo $config | jq -r .verify_incoming_rpc | tee /dev/stderr)
[ "${actual}" = "true" ]

actual=$(echo $config | jq -r .tls.defaults.verify_outgoing | tee /dev/stderr)
actual=$(echo $config | jq -r .verify_outgoing | tee /dev/stderr)
[ "${actual}" = "true" ]

actual=$(echo $config | jq -r .tls.internal_rpc.verify_server_hostname | tee /dev/stderr)
actual=$(echo $config | jq -r .verify_server_hostname | tee /dev/stderr)
[ "${actual}" = "true" ]

actual=$(echo $config | jq -c .ports | tee /dev/stderr)
Expand All @@ -710,10 +710,13 @@ load _helpers
yq -r '.data["tls-config.json"]' | tee /dev/stderr)

local actual
actual=$(echo $config | jq -r .tls.internal_rpc | tee /dev/stderr)
actual=$(echo $config | jq -r .verify_incoming_rpc | tee /dev/stderr)
[ "${actual}" = "null" ]

actual=$(echo $config | jq -r .tls.defaults.verify_outgoing | tee /dev/stderr)
actual=$(echo $config | jq -r .verify_outgoing | tee /dev/stderr)
[ "${actual}" = "null" ]

actual=$(echo $config | jq -r .verify_server_hostname | tee /dev/stderr)
[ "${actual}" = "null" ]
}

Expand Down Expand Up @@ -761,13 +764,13 @@ load _helpers
. | tee /dev/stderr |
yq -r '.data["tls-config.json"]' | tee /dev/stderr)

local actual=$(echo $object | jq -r .tls.defaults.ca_file | tee /dev/stderr)
local actual=$(echo $object | jq -r .ca_file | tee /dev/stderr)
[ "${actual}" = "/vault/secrets/serverca.crt" ]

local actual=$(echo $object | jq -r .tls.defaults.cert_file | tee /dev/stderr)
local actual=$(echo $object | jq -r .cert_file | tee /dev/stderr)
[ "${actual}" = "/vault/secrets/servercert.crt" ]

local actual=$(echo $object | jq -r .tls.defaults.key_file | tee /dev/stderr)
local actual=$(echo $object | jq -r .key_file | tee /dev/stderr)
[ "${actual}" = "/vault/secrets/servercert.key" ]
}

Expand Down