What if your services could instantly trust each other without you lifting a finger?
Why Mutual TLS for service communication in Kubernetes? - Purpose & Use Cases
Start learning this pattern below
Jump into concepts and practice - no test required
Imagine you have many services in your Kubernetes cluster talking to each other. Without protection, anyone could pretend to be a service and listen or send wrong data. You try to check identities manually by adding IP lists or passwords everywhere.
Manually managing who can talk to whom is slow and confusing. IPs change, passwords get leaked, and mistakes happen easily. This causes security holes and breaks communication, making your system unreliable and unsafe.
Mutual TLS (mTLS) automatically checks and confirms the identity of both services before they talk. It encrypts the messages so no one else can read or change them. This happens quietly and safely without you managing passwords or IPs.
curl http://serviceA/api --header 'Authorization: Bearer secret-token'curl https://serviceA/api --cert client.crt --key client.key --cacert ca.crt
With Mutual TLS, your services communicate securely and trust each other automatically, making your system safer and easier to manage.
In a shopping app, the payment service and order service use mTLS to ensure only they can exchange sensitive data like credit card info, preventing hackers from stealing it.
Manual identity checks are slow and risky.
Mutual TLS automates secure, trusted communication.
This protects data and simplifies service connections.
Practice
Solution
Step 1: Understand mTLS purpose
Mutual TLS encrypts data and verifies both client and server identities to secure communication.Step 2: Compare options
Only To encrypt data and verify identities between services correctly describes encryption and identity verification, others are incorrect or opposite.Final Answer:
To encrypt data and verify identities between services -> Option DQuick Check:
mTLS = encrypt + verify identities [OK]
- Thinking mTLS only encrypts but doesn't verify identity
- Confusing mTLS with disabling security
- Assuming mTLS speeds up communication
Solution
Step 1: Recall PeerAuthentication modes
STRICT enforces mTLS only, PERMISSIVE allows both mTLS and plain, DISABLE turns off mTLS.Step 2: Match mode to description
PERMISSIVE mode allows both encrypted and plain traffic, matching the question.Final Answer:
PERMISSIVE -> Option BQuick Check:
PERMISSIVE = both encrypted and plain allowed [OK]
- Confusing STRICT with PERMISSIVE
- Thinking DISABLE allows encrypted traffic
- Assuming ENFORCED is a valid mode
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: myapp
spec:
mtls:
mode: STRICT
What happens when a service in namespace
myapp receives plain HTTP traffic?Solution
Step 1: Analyze PeerAuthentication mode
The mode is STRICT, which enforces mTLS for all incoming traffic in the namespace.Step 2: Understand effect on plain HTTP
Plain HTTP traffic without mTLS will be rejected because encryption and identity verification are mandatory.Final Answer:
The traffic is rejected because mTLS is enforced -> Option AQuick Check:
STRICT mode rejects plain HTTP [OK]
- Assuming plain HTTP is accepted in STRICT mode
- Thinking traffic is redirected automatically
- Confusing logging with rejection
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: test
spec:
mtls:
mode: STRICT
What is the most likely reason?
Solution
Step 1: Check namespace scope
PeerAuthentication applies only to the specified namespace 'test'. If the service is outside, it won't be affected.Step 2: Understand effect on service
If the service is in another namespace, it won't enforce STRICT mode and may accept plain HTTP.Final Answer:
The service is in a different namespace than 'test' -> Option AQuick Check:
Namespace mismatch causes no mTLS enforcement [OK]
- Assuming STRICT mode allows plain HTTP
- Thinking selector is mandatory for namespace-wide policy
- Ignoring namespace differences
payments in namespace finance, but allow other services to accept plain traffic. Which PeerAuthentication config achieves this?Solution
Step 1: Understand requirement
Enforce mTLS STRICT only for 'payments' service, allow others to accept plain traffic.Step 2: Analyze options
apiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: name: payments-mtls namespace: finance spec: selector: matchLabels: app: payments mtls: mode: STRICTapplies STRICT mode with selector for 'payments' only.apiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: name: finance-wide namespace: finance spec: mtls: mode: STRICTenforces STRICT for whole namespace, not desired.apiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: name: permissive-all namespace: finance spec: mtls: mode: PERMISSIVEallows both for all services.apiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: name: payments-disable namespace: finance spec: selector: matchLabels: app: payments mtls: mode: DISABLEdisables mTLS for payments, opposite of requirement.Final Answer:
PeerAuthentication with selector for payments and STRICT mode -> Option CQuick Check:
Selector + STRICT = mTLS only for selected service [OK]
- Applying STRICT mode to whole namespace accidentally
- Using DISABLE mode when enforcement is needed
- Not using selector to target specific service
