Provisioning Identity through SDS
This task shows how to enable SDS (secret discovery service)1 for Istio identity provisioning.
By default, the keys and certificates of Istio workloads are generated by Citadel and distributed to sidecars through secret-volume mounted files. This approach has the following minor drawbacks:
Performance regression during certificate rotation: When certificate rotation happens, Envoy is hot restarted to pick up the new key and certificate, causing performance regression.
Potential security vulnerability: The workload private keys are distributed through Kubernetes secrets, with known risks.
These issues can be addressed by enabling the SDS identity provision flow. This workflow can be described as follows:
The workload sidecar Envoy requests the key and certificates from the Citadel agent: The Citadel agent is a SDS server, which runs as per-node
DaemonSet
. In the request, Envoy passes a Kubernetes service account JWT to the agent.The Citadel agent generates a key pair and sends the CSR request to Citadel: Citadel verifies the JWT and issues the certificate to the Citadel agent.
The Citadel agent sends the key and certificate back to the workload sidecar.
The SDS approach has the following benefits:
The private key never leaves the node: It is only in the Citadel agent and Envoy sidecar’s memory.
The secret volume mount is no longer needed: The reliance on the Kubernetes secrets is eliminated.
The sidecar Envoy is able to dynamically renew the key and certificate through the SDS API: Certificate rotations no longer require Envoy to restart.
Before you begin
Follow the Istio installation guide2 to set up Istio with SDS and global mutual TLS enabled.
Service-to-service mutual TLS using key/certificate provisioned through SDS
Follow the authentication policy task3 to setup test services.
Verify all mutual TLS requests succeed:
Verifying no secret-volume mounted file is generated
To verify that no secret-volume mounted file is generated, access the deployed workload sidecar container:
As you can see there is no secret file mounted at /etc/certs
folder.
Securing SDS with pod security policies
The Istio Secret Discovery Service (SDS) uses the Citadel agent to distribute the certificate to the Envoy sidecar via a Unix domain socket. All pods running in the same Kubernetes node share the Citadel agent and Unix domain socket.
To prevent unexpected modifications to the Unix domain socket, enable the pod security policy6 to restrict the pod’s permission on the Unix domain socket. Otherwise, a malicious user who has the permission to modify the deployment could hijack the Unix domain socket to break the SDS service or steal the identity credentials from other pods running on the same Kubernetes node.
To enable the pod security policy, perform the following steps:
The Citadel agent fails to start unless it can create the required Unix domain socket. Apply the following pod security policy to only allow the Citadel agent to modify the Unix domain socket:
To stop other pods from modifying the Unix domain socket, change the
allowedHostPaths
configuration for the the path the Citadel agent uses for the Unix domain socket toreadOnly: true
.Enable pod security policies for your platform. Each supported platform enables pod security policies differently. Please refer to the pertinent documentation for your platform. If you are using the Google Kubernetes Engine (GKE), you must enable the pod security policy controller7.
Run the following command to restart the Citadel agents:
To verify that the Citadel agents work with the enabled pod security policy, wait a few seconds and run the following command to confirm the agents started successfully:
Run the following command to start a normal pod.
To verify that the normal pod works with the pod security policy enabled, wait a few seconds and run the following command to confirm the normal pod started successfully.
Start a malicious pod that tries to mount the Unix domain socket using a write permission.
To verify that the Unix domain socket is protected, run the following command to confirm the malicious pod failed to start due to the pod security policy:
Cleanup
Clean up the test services and the Istio control plane:
Disable the pod security policy in the cluster using the documentation of your platform. If you are using GKE, disable the pod security policy controller8.
Delete the pod security policy and the test deployments:
Caveats
Currently, the SDS identity provision flow has the following caveats:
SDS support is currently in Alpha.
Smoothly migrating a cluster from using secret volume mount to using SDS is a work in progress.