Service Mesh
Service Mesh
Manages communication between microservices. Istio, Linkerd. Sidecar pattern.
Service Mesh
Manages communication between microservices. Istio, Linkerd. Sidecar pattern.
Service Mesh is an infrastructure layer that manages network communication between microservices. It provides traffic management, security, and observability between services without modifying application code, resolving the complexity of the microservice architecture.
A Service Mesh mainly uses the sidecar pattern to place a proxy (e.g., Envoy) alongside each service Pod. This proxy intercepts all inbound/outbound traffic and handles routing, load balancing, mTLS encryption, circuit breakers, retry logic, and more. Representative implementations include Istio, Linkerd, and Consul Connect, each with strengths in functionality, simplicity, and multi-cloud support.
# virtualservice.yaml - ์นด๋๋ฆฌ ๋ฐฐํฌ ํธ๋ํฝ ๋ถํ
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: product-service
namespace: production
spec:
hosts:
- product-service
http:
- match:
- headers:
x-canary:
exact: "true"
route:
- destination:
host: product-service
subset: v2
- route:
- destination:
host: product-service
subset: v1
weight: 90
- destination:
host: product-service
subset: v2
weight: 10
retries:
attempts: 3
perTryTimeout: 2s
timeout: 10s
---
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: product-service
namespace: production
spec:
host: product-service
trafficPolicy:
connectionPool:
tcp:
maxConnections: 100
http:
h2UpgradePolicy: UPGRADE
http1MaxPendingRequests: 100
outlierDetection:
consecutive5xxErrors: 5
interval: 30s
baseEjectionTime: 30s
maxEjectionPercent: 50
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
# peer-authentication.yaml - ์๋น์ค ๊ฐ mTLS ๊ฐ์
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: production
spec:
mtls:
mode: STRICT
---
# authorization-policy.yaml - ์ธ๋ฐํ ์ ๊ทผ ์ ์ด
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: product-service-policy
namespace: production
spec:
selector:
matchLabels:
app: product-service
action: ALLOW
rules:
- from:
- source:
principals:
- "cluster.local/ns/production/sa/order-service"
- "cluster.local/ns/production/sa/cart-service"
to:
- operation:
methods: ["GET", "POST"]
paths: ["/api/products/*"]