🌐 Quick Win: Service mesh provides traffic management, security, and observability without changing code. Perfect for microservices.
Microservices need traffic management. Service mesh provides it transparently.
🚀 Istio Setup
# ✅ Install Istio istioctl install --set profile=demo -y # ✅ Enable sidecar injection kubectl label namespace production istio-injection=enabled # ✅ Deploy with sidecar kubectl apply -f deployment.yaml -n production
💡 Traffic Management
# ✅ Virtual Service for traffic routing
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: order-service
namespace: production
spec:
hosts:
- order-service
http:
- match:
- headers:
version:
exact: v2
route:
- destination:
host: order-service
subset: v2
- route:
- destination:
host: order-service
subset: v1
weight: 90
- destination:
host: order-service
subset: v2
weight: 10
# ✅ Destination Rule for subsets
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: order-service
namespace: production
spec:
host: order-service
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
# ✅ Circuit Breaker
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: order-service-circuit-breaker
namespace: production
spec:
host: order-service
trafficPolicy:
connectionPool:
tcp:
maxConnections: 100
loadBalancer:
simple: ROUND_ROBIN
outlierDetection:
consecutiveErrors: 5
interval: 30s
baseEjectionTime: 30s
