Implementing Zero Trust with Traefik Mesh Automatic mTLS
Learn how Traefik Mesh automates mTLS for service-to-service security, including configuration for strict mode and how to troubleshoot sidecar injection failures.
02 May 2026, 17:04 UTC

Securing Service-to-Service Traffic with Automatic mTLS
The primary challenge in microservices security is ensuring that traffic between services is both encrypted and authenticated without forcing developers to manage certificates within the application code. Traefik Mesh solves this by implementing a transparent mutual TLS (mTLS) layer. The useful takeaway is that Traefik Mesh removes the certificate lifecycle from the application layer, handling issuance, rotation, and verification via a sidecar proxy and a built-in Certificate Authority (CA).
How Traefik Mesh mTLS Works
Traefik Mesh utilizes a sidecar pattern. When a pod is deployed with the mesh enabled, a proxy container is injected alongside the application. This proxy intercepts all incoming and outgoing network traffic. Instead of the application handling the TLS handshake, the proxy performs the following steps:
- Certificate Issuance: The Traefik Mesh controller acts as a root CA, issuing short-lived X.509 certificates to each sidecar proxy.
- Handshake: When Service A calls Service B, the sidecars perform a mutual handshake, verifying each other's certificates against the Mesh CA.
- Transparent Decryption: Once the secure tunnel is established, the receiving proxy decrypts the traffic and forwards it to the local application container over localhost, meaning the application still sees plain HTTP/TCP.
Configuration Example: Enforcing Strict mTLS
By default, Traefik Mesh can operate in different modes to allow for gradual migration. To ensure a Zero Trust posture, you must move from permissive to strict mode. In strict mode, any request that does not present a valid Mesh CA certificate is rejected.
To enforce strict mTLS for a specific namespace, you use a MeshTrafficTarget resource. Apply the following configuration using kubectl (requires cluster-admin permissions):
cat <<EOF | kubectl apply -f -
apiVersion: traefikmesh.io/v1alpha1
kind: MeshTrafficTarget
metadata:
name: backend-strict-mtls
namespace: production
spec:
target:
service: backend-service
mtlsMode: Strict
EOF
Expected Result: After applying this, the backend-service will only accept connections from other pods that have a Traefik Mesh sidecar injected. Any request from a pod without a sidecar—even within the same cluster—will result in a TLS handshake failure.
Verifying mTLS Connectivity
To verify that mTLS is functioning and enforcing security, perform these checks from a pod within the mesh:
- Test Successful Handshake: Exec into a frontend pod and attempt to call the backend service via HTTPS.
Check forkubectl exec -it frontend-pod-xyz -- curl -v https://backend-service.production.svc.cluster.local:8080SSL connection using TLSv1.3and successful peer verification in the verbose output. - Inspect Proxy Logs: Check the sidecar logs for CA confirmation.
Look for entries statingkubectl logs -l app=frontend -c traefik-mesh-proxy"TLS handshake completed"and"certificate issued by Mesh CA".
Limitations and Common Pitfalls
The "Missing Sidecar" Failure
The most common cause of "Connection Refused" or "TLS Handshake Error" in Traefik Mesh is a missing sidecar. If a pod is deployed without the traefikmesh.io/sidecar annotation, it cannot present a certificate. Because the target service is in Strict mode, the connection is dropped. Always verify injection using kubectl describe pod [pod-name] to ensure the traefik-mesh-proxy container is running.
Certificate Rotation Constraints
Traefik Mesh rotates certificates every 24 hours by default. A critical limitation is that the --cert-rotation-interval flag is set at the controller level. You cannot change this rotation frequency via pod annotations or per-service configurations. To change the rotation interval, you must redeploy the Traefik Mesh controller with the updated flag, which may cause a brief period of control-plane instability.
CA Conflicts with External Managers
If you are already using cert-manager for ingress certificates, be cautious. Running an external certificate manager in the same namespace as Traefik Mesh's internal CA can lead to conflicting Certificate objects if the naming conventions overlap. It is recommended to scope your external cert-manager to specific ingress namespaces and leave the internal service-to-service certificates to the Mesh controller.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.