SDS — TLS cert rotation without restarts
Push certs into Envoy dynamically via xDS so rotation never requires a process restart.
Why static cert files don't cut it anymore
Modern PKI rotates fast:
- SPIFFE / SPIRE workload identities: 1-hour TTL.
- cert-manager + Let's Encrypt: 60-day rotation.
- Vault PKI: cert minted on demand per workload.
Restarting Envoy every rotation drops long-lived gRPC streams and breaks zero-downtime promises. SDS — Secret Discovery Service — solves this by delivering certs and keys to Envoy dynamically, over xDS, with atomic in-memory swap. No restart, no dropped connections.
Minimal envoy.yaml — listener that fetches certs over SDS
static_resources:
listeners:
- address: { socket_address: { address: 0.0.0.0, port_value: 8443 }}
filter_chains:
- transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext
common_tls_context:
tls_certificate_sds_secret_configs:
- name: server_cert
sds_config:
resource_api_version: V3
api_config_source:
api_type: GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc: { cluster_name: sds_server }
validation_context_sds_secret_config:
name: trusted_ca
sds_config:
resource_api_version: V3
api_config_source:
api_type: GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc: { cluster_name: sds_server }
filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
route_config:
virtual_hosts:
- name: vh
domains: ["*"]
routes:
- match: { prefix: "/" }
direct_response: { status: 200, body: { inline_string: "ok" }}
clusters:
- name: sds_server
type: STATIC
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicit_http_config: { http2_protocol_options: {} }
load_assignment:
cluster_name: sds_server
endpoints:
- lb_endpoints:
- endpoint:
address:
pipe: { path: "/var/run/sds/sds.sock" } # UDS
Most production deployments use a Unix domain socket for SDS. The SDS channel itself doesn't need TLS — kernel locality enforces trust.
The chicken-and-egg problem
If SDS is delivered over an mTLS gRPC channel, Envoy needs a cert to fetch its certs. Two ways out:
- Unix domain socket — most common. SPIRE Agent and Istio's pilot-agent expose SDS over a UDS that only locally-running Envoy pods can reach.
- Bootstrap secret — a small, long-lived cert loaded statically from disk, used only for the SDS connection itself. Workload certs then arrive over that bootstrap-mTLS channel.
UDS is simpler and what every reference implementation uses.
Three pitfalls
Listeners with tls_certificate_sds_secret_configs are not
ready until the first SDS push lands. Clients connecting before that
get TCP RST or hang. Tune initial_fetch_timeout and design
clients to retry with backoff at startup.
Replacing the trusted CA atomically seems safe — but any client whose chain validates only against the old CA starts failing the moment the swap lands. Always: add the new CA in push 1, let clients rotate over a window, then remove the old CA in push 2.
TLS sessions are pinned to the cert that established them. Rotating the
SDS cert affects new connections; existing streams keep going
with the previous identity until they end. This is usually what you
want — but if you need to forcibly invalidate an identity, use
connectionDraining on the listener or rely on short
session-resumption tickets.
Hands-on: rotate a cert without dropping a connection
-
Run SPIRE Server and Agent locally with Docker (the SPIRE quickstart works fine).
-
Register a workload selector that matches your Envoy container:
spire-server entry create \
-spiffeID spiffe://example.org/envoy \
-parentID spiffe://example.org/agent \
-selector docker:label:app:envoy
-
Configure Envoy with the listener above pointing at the agent's UDS (typically
/tmp/spire-agent/public/api.sock). -
Curl
https://localhost:8443with the SPIRE-issued client cert. -
Force a rotation:
spire-server entry update -ttl 60 ...
Watch
http://localhost:9901/stats?filter=secret.server_cert —
update_success increments without a process restart.
- Hold an open
nc -kTLS connection while the rotation happens. The session keeps going. New connections after the swap use the fresh cert.
Where SDS fits in the bigger picture
- Static config (Modules 1-4) — fine for learning.
- xDS (Lesson 16) — clusters and routes pushed dynamically.
- SDS (this lesson) — the same xDS pipeline, but for TLS material.
In a real Istio mesh, all of CDS / RDS / EDS / LDS / SDS flow over one ADS stream. The Envoy you've been writing by hand is also the Envoy your mesh is generating — just with everything dynamic.
What is the most common way to avoid the SDS-over-TLS bootstrap problem?