플랫폼, 데브옵스와 클라우드

서비스 메시

meellon 2026. 7. 6. 05:40

학습 목표

서비스 메시K8s Service·Ingress다른 문제(L4/L7 내부 통신·보안·관측)를 해결하는지 설명할 수 있다.

sidecar 프록시control plane·data plane 역할구분할 수 있다.

mTLS(PeerAuthentication)로 서비스 암호화·신원적용하는 방식을 설명할 수 있다.

VirtualService·DestinationRuletraffic split·retry·timeout코드 없이 정책화할 수 있다.

canary 배포mesh 트래픽 분할연계하고 도입 트레이드오프평가할 수 있다.

문제 상황

  • 서비스 20개 retry·timeout·circuit breaker 라이브러리 제각각
  • 평문 ClusterIP 통신Pod 탈취 내부 API 전부 노출
  • 분산 트레이싱 불가요청 ID 전파 누락·로그 상관 실패
  • canary 10%Ingress weight조정·내부 서비스서비스 호출구버전 고정
  • gRPC·TCP 장기 연결Ingress 한계·L7 정책 부재
  • Well-Architected Security전송 암호화·최소 권한 미충족

앞서 Service·Ingress·배포 전략클러스터 라우팅릴리스 패턴다뤘다. Part 5 MSA 서비스 통신인프라 레이어일원화하는 서비스 메시다.

1. 서비스 메시란

Service mesh마이크로서비스 통신전담하는 인프라 레이어. 애플리케이션 코드 변경 없이 프록시(sidecar)가 트래픽가로채 정책적용.

  K8s Service Ingress Service mesh
범위 클러스터 내부 L4 클러스터 경계 L7 HTTP 서비스 L4/L7
로드밸런싱 kube-proxy Ingress controller envoy sidecar
mTLS 없음 TLS 종료(edge) 서비스 양방향
canary selector 교체 annotation weight VirtualService subset weight
관측 kubelet·cAdvisor access log 분산 trace·metric 표준

대표 구현Istio(envoy), Linkerd, Cilium Service Mesh. 본문은 Istio 용어·CRD 기준.

평면 구성 역할
Control plane istiod 설정 배포·인증서 발급·서비스 디스커버리
Data plane envoy sidecar 실제 프록시·mTLS·라우팅·메트릭

sidecar 주입namespace label istio-injection=enabled 또는 Pod annotation. Pod마다 envoy 컨테이너 자동 추가.

2. Sidecar Pod

Pod 애플리케이션 컨테이너 envoy모든 inbound/outbound 트래픽sidecar 경유.

경로 동작
Inbound 다른 Podenvoyapp localhost
Outbound appenvoy대상 서비스 envoy
iptables init container트래픽 리다이렉트 (istio-proxy)

리소스 — sidecar CPU·memory requests 필수. 소규모 Pod에도 고정 오버헤드노드 용량 계획 필요.

변경 없음HTTP 헤더 전파(x-request-idretrymesh 정책으로.

3. mTLS

Mutual TLS클라이언트·서버 양쪽 인증서 검증. IstioSPIFFE 형식 워크로드 ID서비스 신원 부여.

모드 PeerAuthentication  
DISABLE mTLS 마이그레이션 초기
PERMISSIVE 평문·mTLS 혼용 기본(레거시 호환)
STRICT mTLS 프로덕션 권장
# code/peerauthentication-strict.yaml
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: production
spec:
  mtls:
    mode: STRICT
범위  
Mesh-wide istio-system default PeerAuthentication
Namespace ·환경 분리
Workload selector특정 Deployment

인증서istiod짧은 TTL 인증서 자동 로테이션. 코드·Secret 수동 관리 불필요.

AuthorizationPolicy — mTLS 이후 L7 허용 규칙 (예: order payment 호출).

apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: payment-from-order
  namespace: production
spec:
  selector:
    matchLabels:
      app: payment
  action: ALLOW
  rules:
    - from:
        - source:
            principals: ["cluster.local/ns/production/sa/order"]

4. 트래픽 관리

VirtualService라우팅 규칙(host·subset·weight·fault).

DestinationRulesubset 정의(version label), loadBalancer, connectionPool, outlierDetection.

# code/virtualservice-canary.yaml
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: api
  namespace: production
spec:
  host: api.production.svc.cluster.local
  subsets:
    - name: stable
      labels:
        version: v1.3
    - name: canary
      labels:
        version: v1.4
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: api
  namespace: production
spec:
  hosts:
    - api.production.svc.cluster.local
  http:
    - route:
        - destination:
            host: api.production.svc.cluster.local
            subset: stable
          weight: 90
        - destination:
            host: api.production.svc.cluster.local
            subset: canary
          weight: 10
배포 전략 연계 mesh 이점
Canary 내부 호출동일 weightBFFAPI 일관
Blue-green subset 전환 CR
Fault injection chaos 테스트 without 코드

retry·timeoutDestinationRule·VirtualService 공통.

# code/destinationrule-retry.yaml
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: catalog
spec:
  hosts:
    - catalog
  http:
    - timeout: 2s
      retries:
        attempts: 3
        perTryTimeout: 500ms
        retryOn: 5xx,reset,connect-failure
      route:
        - destination:
            host: catalog
주의  
멱등 아닌 POST retry 위험idempotency-key 또는 retry 제외
retry 폭주 max attempts·budget 제한
타임아웃 중첩 timeout < mesh timeout 정렬

5. 관측성 연동

envoy표준 메트릭·액세스 로그·trace span 생성.

신호 활용
Prometheus istio_requests_total, latency histogram
Jaeger / Tempo 분산 트레이스서비스 그래프
Kiali topology·mTLS 상태·VirtualService 시각화
Grafana SLO 대시보드canary gate

Well-Architected Operational Excellence배포 error rate·p99mesh 메트릭으로 canary 판단 (13편 Argo Rollouts 대안·보완).

# sidecar 메트릭 (요지)
kubectl exec deploy/api -c istio-proxy -- \
  curl -s localhost:15000/stats/prometheus | head

6. 도입 트레이드오프

도입 보류 검토
서비스 10+· 분산 모놀리스 1~2 서비스
mTLS·정책 일원화 필수 NetworkPolicy·Ingress충분
canary·내부 트래픽 제어 단순 rolling
플랫폼 운영 역량 sidecar 장애 대응 인력 없음
대안  
Linkerd 경량 Rust proxy·단순 UX
Cilium eBPF·sidecar less 옵션
SDK Resilience4j 등 — 언어 중복
Gateway API 경계 L7내부 mTLS 별도

비용노드 CPU 10~15% sidecar 오버헤드(워크로드 따라 상이). istiod HA 3 replica 권장.

7. 실무 체크리스트

항목 권장
주입 프로덕션 namespace 선택 주입
mTLS PERMISSIVE검증STRICT 단계 전환
리소스 sidecar limits 명시OOM Pod 전체 영향
canary VirtualService weight + Prometheus SLO gate
디버깅 istioctl proxy-config·analyze 습관화
업그레이드 Istio 버전 = 클러스터 minor 호환 확인
# 설치·검증 (개발 클러스터)
istioctl install --set profile=demo -y
kubectl label namespace production istio-injection=enabled
istioctl analyze -n production

8. 정리

  • 서비스 메시MSA 통신·보안·관측sidecar분리
  • istiod + envoycontrol / data plane
  • mTLS STRICT + AuthorizationPolicyWell-Architected Security 보완
  • VirtualService weightcanary·내부 호출 일관
  • 오버헤드·운영 복잡도규모·요구 맞을 도입

다음에 다룰 것

  • 멀티클러스터페더레이션·cluster mesh·DR
  • GitOps 다중 클러스터 배포

해당 내용은 Istio Documentation 의 내용을 기반으로 합니다.

'플랫폼, 데브옵스와 클라우드' 카테고리의 다른 글

엣지와 분산 배포  (0) 2026.07.08
멀티클러스터  (0) 2026.07.07
Well-Architected  (0) 2026.07.05
관리형 서비스  (1) 2026.07.04
VPC와 네트워킹  (0) 2026.07.03