mtls-configuration — templates and worked examples
Templates
Template 1: Istio mTLS (Strict Mode)
# Enable strict mTLS mesh-wideapiVersion:security.istio.io/v1beta1kind:PeerAuthenticationmetadata:name:defaultnamespace:istio-systemspec:mtls:mode:STRICT---# Namespace-level override (permissive for migration)apiVersion:security.istio.io/v1beta1kind:PeerAuthenticationmetadata:name:defaultnamespace:legacy-namespacespec:mtls:mode:PERMISSIVE---# Workload-specific policyapiVersion:security.istio.io/v1beta1kind:PeerAuthenticationmetadata:name:payment-servicenamespace:productionspec:selector:matchLabels:app:payment-servicemtls:mode:STRICTportLevelMtls:8080:mode:STRICT9090:mode:DISABLE# Metrics port, no mTLS
Template 2: Istio Destination Rule for mTLS
apiVersion:networking.istio.io/v1beta1kind:DestinationRulemetadata:name:defaultnamespace:istio-systemspec:host:"*.local"trafficPolicy:tls:mode:ISTIO_MUTUAL---# TLS to external serviceapiVersion:networking.istio.io/v1beta1kind:DestinationRulemetadata:name:external-apispec:host:api.external.comtrafficPolicy:tls:mode:SIMPLEcaCertificates:/etc/certs/external-ca.pem---# Mutual TLS to external serviceapiVersion:networking.istio.io/v1beta1kind:DestinationRulemetadata:name:partner-apispec:host:api.partner.comtrafficPolicy:tls:mode:MUTUALclientCertificate:/etc/certs/client.pemprivateKey:/etc/certs/client-key.pemcaCertificates:/etc/certs/partner-ca.pem
Template 3: Cert-Manager with Istio
# Install cert-manager issuer for IstioapiVersion:cert-manager.io/v1kind:ClusterIssuermetadata:name:istio-caspec:ca:secretName:istio-ca-secret---# Create Istio CA secretapiVersion:v1kind:Secretmetadata:name:istio-ca-secretnamespace:cert-managertype:kubernetes.io/tlsdata:tls.crt:<base64-encoded-ca-cert>tls.key:<base64-encoded-ca-key>---# Certificate for workloadapiVersion:cert-manager.io/v1kind:Certificatemetadata:name:my-service-certnamespace:my-namespacespec:secretName:my-service-tlsduration:24hrenewBefore:8hissuerRef:name:istio-cakind:ClusterIssuercommonName:my-service.my-namespace.svc.cluster.localdnsNames:-my-service-my-service.my-namespace-my-service.my-namespace.svc-my-service.my-namespace.svc.cluster.localusages:-serverauth-clientauth
# Linkerd enables mTLS automatically# Verify with:# linkerd viz edges deployment -n my-namespace# For external services without mTLSapiVersion:policy.linkerd.io/v1beta1kind:Servermetadata:name:external-apinamespace:my-namespacespec:podSelector:matchLabels:app:my-appport:external-apiproxyProtocol:HTTP/1# or TLS for passthrough---# Skip TLS for specific portapiVersion:v1kind:Servicemetadata:name:my-serviceannotations:config.linkerd.io/skip-outbound-ports:"3306"# MySQL