0
0
Kubernetesdevops~10 mins

Mutual TLS for service communication in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Mutual TLS for service communication
Service A wants to connect to Service B
Service A presents its client certificate
Service B verifies client certificate
Service B presents its server certificate
Service A verifies server certificate
Secure connection established with mutual trust
Data exchange happens
This flow shows how two services authenticate each other using certificates before exchanging data securely.
Execution Sample
Kubernetes
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
spec:
  mtls:
    mode: STRICT
This Kubernetes manifest enables strict mutual TLS for all services in the namespace.
Process Table
StepActionService A StateService B StateResult
1Service A initiates connectionSends client certificateWaiting for client certConnection attempt started
2Service B receives client certificateClient cert sentVerifies client certificateClient authenticated
3Service B sends server certificateWaiting for server certSends server certificateServer cert sent
4Service A verifies server certificateVerifies server certificateServer cert sentServer authenticated
5Mutual TLS handshake completesBoth certificates verifiedBoth certificates verifiedSecure connection established
6Data exchangeEncrypted data sentEncrypted data receivedSecure communication ongoing
💡 Mutual TLS handshake completes successfully, enabling encrypted and authenticated communication.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5Final
Service A CertificateNot sentSent to Service BSentWaiting for server certVerified server certMutual TLS establishedSecure communication
Service B CertificateNot sentWaiting for client certClient cert verifiedSent to Service ASentMutual TLS establishedSecure communication
Connection StateDisconnectedConnectingAuthenticating clientAuthenticating serverHandshake completeConnectedSecure connection
Key Moments - 3 Insights
Why does Service B verify Service A's certificate before sending its own?
Service B must confirm Service A is trusted before revealing its own identity to avoid exposing sensitive data. This is shown in step 2 and 3 of the execution_table.
What happens if Service A fails to verify Service B's certificate?
The mutual TLS handshake fails and the connection is not established, preventing insecure communication. This would stop the flow at step 4 in the execution_table.
Why is mutual TLS stronger than one-way TLS?
Because both services authenticate each other, not just the server. This prevents impersonation from either side, as seen in the mutual verification steps 2 and 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the state of Service A after step 3?
AClient certificate verified
BSecure connection established
CWaiting for server certificate
DDisconnected
💡 Hint
Check the 'Service A State' column at step 3 in the execution_table.
At which step does the mutual TLS handshake complete?
AStep 4
BStep 5
CStep 6
DStep 3
💡 Hint
Look for the row where both certificates are verified and connection is established.
If Service B does not verify Service A's certificate, what will happen?
AHandshake fails and connection stops
BService B sends server certificate anyway
CConnection proceeds without encryption
DService A retries sending certificate
💡 Hint
Refer to the key moment about verification failure and the execution_table step 2.
Concept Snapshot
Mutual TLS (mTLS) requires both client and server to present certificates.
In Kubernetes, enable mTLS via PeerAuthentication with mode STRICT.
Services verify each other's certificates before exchanging data.
This ensures encrypted, authenticated, and trusted communication.
If verification fails, connection is refused.
Use mTLS to secure service-to-service communication in clusters.
Full Transcript
Mutual TLS for service communication means both services prove their identity using certificates before talking. Service A starts by sending its client certificate to Service B. Service B checks this certificate to make sure Service A is trusted. Then Service B sends its own server certificate back. Service A verifies it. When both sides confirm each other's certificates, they establish a secure connection. This process is called a mutual TLS handshake. After the handshake, data is exchanged securely and encrypted. If either side fails to verify the other's certificate, the connection stops. In Kubernetes, you enable this by applying a PeerAuthentication resource with mtls mode set to STRICT. This setup helps keep service communication safe and trusted inside the cluster.