Skip to content

Commit 6536354

Browse files
committed
fix: reload Connect API and UI TLS certificate when rotated
By using SDS to define the certificate secrets, Envoy will watch the directory for changes, and reload when certificates are rotated. Note that the SDS resources cannot be in static_resources, which is why we use a separate file as a dynamic SDS configuration source. See example 3 in [1]. [1] https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret#key-rotation Fixes: cofide/cofide-connect#1383
1 parent aee255f commit 6536354

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

charts/cofide-connect-ui/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.4
18+
version: 0.1.5
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/cofide-connect-ui/templates/configmap-envoy.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ metadata:
55
labels:
66
{{- include "cofide-connect-ui.labels" . | nindent 4 }}
77
data:
8+
# envoy.yaml is the main Envoy configuration file.
89
envoy.yaml: |
910
node:
1011
id: connect-ui-envoy-proxy
@@ -34,11 +35,11 @@ data:
3435
common_tls_context:
3536
alpn_protocols:
3637
- h2
37-
tls_certificates:
38-
- certificate_chain:
39-
filename: /etc/envoy/tls/tls.crt
40-
private_key:
41-
filename: /etc/envoy/tls/tls.key
38+
tls_certificate_sds_secret_configs:
39+
- name: connect_ui_tls_cert
40+
sds_config:
41+
path_config_source:
42+
path: /etc/envoy/envoy-sds.yaml
4243
filters:
4344
- name: envoy.filters.network.http_connection_manager
4445
typed_config:
@@ -102,3 +103,18 @@ data:
102103
socket_address:
103104
address: 127.0.0.1
104105
port_value: 9901
106+
107+
# envoy-sds.yaml is a Secret Discovery Service (SDS) configuration file.
108+
# This is used as an SDS dynamic configuration source, supporting automatic
109+
# certificate rotation by ensuring that a filesystem watch is used for the
110+
# certificate and key. See example 3 in
111+
# https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret#key-rotation
112+
envoy-sds.yaml: |
113+
resources:
114+
- "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret"
115+
name: connect_ui_tls_cert
116+
tls_certificate:
117+
certificate_chain:
118+
filename: /etc/envoy/tls/tls.crt
119+
private_key:
120+
filename: /etc/envoy/tls/tls.key

charts/cofide-connect/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.11.4
18+
version: 0.11.5
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/cofide-connect/templates/configmap-envoy.yaml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ kind: ConfigMap
33
metadata:
44
name: connect-api-envoy-config
55
data:
6+
# envoy.yaml is the main Envoy configuration file.
67
envoy.yaml: |
78
node:
89
id: connect-api-envoy-proxy
@@ -96,11 +97,11 @@ data:
9697
common_tls_context:
9798
alpn_protocols:
9899
- h2
99-
tls_certificates:
100-
- certificate_chain:
101-
filename: /etc/envoy/tls/tls.crt
102-
private_key:
103-
filename: /etc/envoy/tls/tls.key
100+
tls_certificate_sds_secret_configs:
101+
- name: connect_api_tls_cert
102+
sds_config:
103+
path_config_source:
104+
path: /etc/envoy/envoy-sds.yaml
104105
filters:
105106
- name: envoy.filters.network.http_connection_manager
106107
typed_config:
@@ -366,3 +367,18 @@ data:
366367
socket_address:
367368
address: 127.0.0.1
368369
port_value: 9901
370+
371+
# envoy-sds.yaml is a Secret Discovery Service (SDS) configuration file.
372+
# This is used as an SDS dynamic configuration source, supporting automatic
373+
# certificate rotation by ensuring that a filesystem watch is used for the
374+
# certificate and key. See example 3 in
375+
# https://www.envoyproxy.io/docs/envoy/latest/configuration/security/secret#key-rotation
376+
envoy-sds.yaml: |
377+
resources:
378+
- "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret"
379+
name: connect_api_tls_cert
380+
tls_certificate:
381+
certificate_chain:
382+
filename: /etc/envoy/tls/tls.crt
383+
private_key:
384+
filename: /etc/envoy/tls/tls.key

0 commit comments

Comments
 (0)