setup-service-mesh
정보
이 스킬은 Kubernetes에서 서비스 메시(Istio 또는 Linkerd)를 배포하고 구성하여 마이크로서비스 간의 안전한 암호화 통신과 고급 트래픽 관리를 제공합니다. 애플리케이션 코드 변경 없이 mTLS, 카나리 배포를 위한 트래픽 라우팅, 서킷 브레이킹, 가시성 등의 기능을 활성화합니다. 클러스터 전반에 걸쳐 서비스 간 통신에 대한 세밀한 제어, 일관된 정책 적용, 향상된 모니터링이 필요할 때 사용하세요.
빠른 설치
Claude Code
추천npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/setup-service-meshClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
Setup Service Mesh
Deploy and configure a service mesh for secure service-to-service communication and advanced traffic management.
When to Use
- Microservices architecture requires encrypted service-to-service communication
- Need fine-grained traffic control (canary deployments, A/B testing, traffic splitting)
- Require observability across all service interactions without application changes
- Enforce security policies (mTLS, authorization) at the infrastructure level
- Implement circuit breaking, retries, and timeouts consistently across services
- Need distributed tracing and service dependency mapping
Inputs
- Required: Kubernetes cluster with admin access
- Required: Choice of service mesh (Istio or Linkerd)
- Required: Namespace(s) to enable service mesh
- Optional: Monitoring stack (Prometheus, Grafana, Jaeger)
- Optional: Custom traffic management requirements
- Optional: Certificate authority configuration for mTLS
Procedure
See Extended Examples for complete configuration files and templates.
Step 1: Install Service Mesh Control Plane
Choose and install the service mesh control plane.
For Istio:
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.20.2 sh -
istioctl install --set profile=production -y
kubectl get pods -n istio-system
For Linkerd:
curl -sL https://run.linkerd.io/install | sh
linkerd check --pre
linkerd install --ha | kubectl apply -f -
linkerd check
Create a service mesh configuration with resource limits and tracing:
# service-mesh-config.yaml (abbreviated)
spec:
profile: production
meshConfig:
enableTracing: true
components:
pilot:
k8s:
resources: { requests: { cpu: 500m, memory: 2Gi } }
# See EXAMPLES.md Step 1 for complete configuration
Got: Control plane pods running in istio-system (Istio) or linkerd (Linkerd) namespace. istioctl version or linkerd version shows matching client and server versions.
If fail:
- Check cluster has sufficient resources (at least 4 CPU cores, 8GB RAM for production)
- Verify Kubernetes version compatibility (check mesh documentation)
- Review logs:
kubectl logs -n istio-system -l app=istiodorkubectl logs -n linkerd -l linkerd.io/control-plane-component=controller - Check for conflicting CRDs:
kubectl get crd | grep istioorkubectl get crd | grep linkerd
Step 2: Enable Automatic Sidecar Injection
Configure namespaces for automatic sidecar proxy injection.
For Istio:
# Label namespace for automatic injection
kubectl label namespace default istio-injection=enabled
kubectl get namespace -L istio-injection
For Linkerd:
# Annotate namespace for injection
kubectl annotate namespace default linkerd.io/inject=enabled
Test sidecar injection with a sample deployment:
# test-deployment.yaml (abbreviated)
apiVersion: apps/v1
kind: Deployment
spec:
replicas: 2
template:
spec:
containers:
- name: app
image: nginx:alpine
# See EXAMPLES.md Step 2 for complete test deployment
Apply and verify:
kubectl apply -f test-deployment.yaml
kubectl get pods -n default
# Expect 2/2 containers (app + proxy)
Got: New pods show 2/2 containers (application + sidecar proxy). Describe output shows istio-proxy or linkerd-proxy container. Logs show successful proxy startup.
If fail:
- Check namespace labels/annotations:
kubectl get ns default -o yaml - Verify mutating webhook is active:
kubectl get mutatingwebhookconfiguration - Review injection logs:
kubectl logs -n istio-system -l app=sidecar-injector(Istio) - Manually inject to test:
kubectl get deploy test-app -o yaml | istioctl kube-inject -f - | kubectl apply -f -
Step 3: Configure mTLS Policy
Enable mutual TLS for secure service-to-service communication.
For Istio:
# mtls-policy.yaml (abbreviated)
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: istio-system
spec:
mtls:
mode: STRICT
# See EXAMPLES.md Step 3 for per-namespace and permissive mode examples
For Linkerd:
# Linkerd enforces mTLS by default for meshed pods
linkerd viz tap deploy/test-app -n default
# Check for 🔒 (lock) symbol
Apply and verify:
kubectl apply -f mtls-policy.yaml
# Istio: verify mTLS status
istioctl authn tls-check $(kubectl get pod -n default -l app=test-app -o jsonpath='{.items[0].metadata.name}') -n default
Got: All connections between meshed services show mTLS enabled. Istio tls-check shows STATUS as "OK". Linkerd tap output shows 🔒 for all connections. Service logs show no TLS errors.
If fail:
- Check certificate issuance:
kubectl get certificates -A(cert-manager) - Verify CA is healthy:
kubectl logs -n istio-system -l app=istiod | grep -i cert - Test with PERMISSIVE mode first, then transition to STRICT
- Check for services without sidecars:
kubectl get pods --all-namespaces -o json | jq '.items[] | select(.spec.containers | length == 1) | .metadata.name'
Step 4: Implement Traffic Management Rules
Configure intelligent traffic routing, retries, and circuit breaking.
Create traffic management policies:
# traffic-management.yaml (abbreviated)
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
spec:
http:
- match:
- uri: { prefix: /api/v2 }
route:
- destination: { host: api-service, subset: v2 }
weight: 10
- destination: { host: api-service, subset: v1 }
weight: 90
retries: { attempts: 3, perTryTimeout: 2s }
# See EXAMPLES.md Step 4 for complete routing, circuit breaker, and gateway configs
For Linkerd traffic splitting:
apiVersion: split.smi-spec.io/v1alpha2
kind: TrafficSplit
spec:
service: api-service
backends:
- service: api-service-v1
weight: 900
- service: api-service-v2
weight: 100
Apply and test:
kubectl apply -f traffic-management.yaml
# Test traffic distribution
for i in {1..100}; do curl -s http://api.example.com/api/v2 | grep version; done | sort | uniq -c
# Monitor: istioctl dashboard kiali or linkerd viz dashboard
Got: Traffic splits according to defined weights. Circuit breaker trips after consecutive errors. Retries occur for transient failures. Kiali/Linkerd dashboard shows traffic flow visualization.
If fail:
- Verify destination hosts resolve:
kubectl get svc -n production - Check subset labels match pod labels:
kubectl get pods -n production --show-labels - Review pilot logs:
kubectl logs -n istio-system -l app=istiod - Test without circuit breaker first, then add incrementally
- Use
istioctl analyzeto check configuration:istioctl analyze -n production
Step 5: Integrate Observability Stack
Connect service mesh telemetry to monitoring and tracing systems.
Install observability addons:
# Istio: Prometheus, Grafana, Kiali, Jaeger
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.20/samples/addons/prometheus.yaml
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.20/samples/addons/grafana.yaml
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.20/samples/addons/kiali.yaml
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.20/samples/addons/jaeger.yaml
# Linkerd
linkerd viz install | kubectl apply -f -
linkerd jaeger install | kubectl apply -f -
Configure custom metrics and dashboards:
# service-monitor.yaml (abbreviated)
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: istio-mesh-metrics
spec:
selector: { matchLabels: { app: istiod } }
endpoints:
- port: http-monitoring
interval: 30s
# See EXAMPLES.md Step 5 for Grafana dashboards and telemetry config
Access dashboards:
istioctl dashboard grafana # or: linkerd viz dashboard
istioctl dashboard kiali
istioctl dashboard jaeger
Got: Dashboards show service topology, request rates, latency percentiles, error rates. Distributed traces available in Jaeger. Prometheus scraping mesh metrics successfully. Custom metrics appear in queries.
If fail:
- Verify Prometheus scraping:
kubectl get servicemonitor -A - Check addon pods are running:
kubectl get pods -n istio-system - Review telemetry configuration:
istioctl proxy-config log <pod-name> -n <namespace> - Verify mesh config has telemetry enabled:
kubectl get configmap istio -n istio-system -o yaml | grep -A 5 enableTracing - Check for port conflicts if port-forward fails
Step 6: Validate and Monitor Mesh Health
Perform comprehensive health checks and set up ongoing monitoring.
# Istio validation
istioctl analyze --all-namespaces
istioctl verify-install
istioctl proxy-status
# Linkerd validation
linkerd check
linkerd viz check
linkerd diagnostics policy
# Check proxy sync status
kubectl get pods -n production -o json | \
jq '.items[] | {name: .metadata.name, proxy: .status.containerStatuses[] | select(.name=="istio-proxy").ready}'
# Monitor control plane health
kubectl get pods -n istio-system -w
kubectl top pods -n istio-system
Create health check script and alerts:
#!/bin/bash
# mesh-health-check.sh (abbreviated)
echo "=== Service Mesh Health Check ==="
kubectl get pods -n istio-system
istioctl analyze --all-namespaces
# See EXAMPLES.md Step 6 for complete health check script and alert configs
Got: All analysis checks pass with no warnings. Proxy-status shows all proxies synced. mTLS check confirms encryption. Metrics show traffic flowing. Control plane pods stable with low resource usage.
If fail:
- Address specific issues from
istioctl analyzeoutput - Check proxy logs for individual pods:
kubectl logs <pod> -c istio-proxy -n <namespace> - Verify network policies are not blocking mesh traffic
- Review control plane logs for errors:
kubectl logs -n istio-system deploy/istiod --tail=100 - Restart problematic proxies:
kubectl rollout restart deploy/<deployment> -n <namespace>
Validation
- Control plane pods running and healthy (istiod/linkerd-controller)
- Sidecar proxies injected into all application pods (2/2 containers)
- mTLS enabled and functioning (verified with tls-check/tap)
- Traffic management rules routing requests correctly (verified with curl tests)
- Circuit breaker trips on repeated failures (tested with fault injection)
- Observability dashboards showing metrics (Grafana/Kiali/Linkerd Viz)
- Distributed traces captured in Jaeger for sample requests
- No configuration warnings from istioctl analyze/linkerd check
- Proxy sync status shows all proxies in sync
- Service-to-service communication encrypted (verified in logs/dashboards)
Pitfalls
-
Resource Exhaustion: Service mesh adds 100-200MB memory per pod for sidecars. Ensure cluster has sufficient capacity. Set appropriate resource limits in injection config.
-
Configuration Conflicts: Multiple VirtualServices for same host cause undefined behavior. Use single VirtualService per host with multiple match conditions instead.
-
Certificate Expiration: mTLS certificates auto-rotate but CA root must be managed. Monitor certificate expiry with:
kubectl get certificate -Aand set up alerts. -
Sidecar Not Injected: Pods created before namespace labeling won't have sidecars. Must recreate:
kubectl rollout restart deploy/<name> -n <namespace>. -
DNS Resolution Issues: Service mesh intercepts DNS. Use fully qualified names (service.namespace.svc.cluster.local) for cross-namespace calls.
-
Port Naming Requirement: Istio requires named ports following protocol-name pattern (e.g., http-web, tcp-db). Unnamed ports default to TCP passthrough.
-
Gradual Rollout Required: Don't enable STRICT mTLS immediately in production. Use PERMISSIVE mode during migration, verify all services meshed, then switch to STRICT.
-
Observability Overhead: 100% tracing sampling causes performance issues. Use 1-10% for production:
sampling: 1.0in mesh config. -
Gateway vs VirtualService Confusion: Gateway configures ingress (load balancer), VirtualService configures routing. Both required for external traffic.
-
Version Compatibility: Ensure mesh version compatible with Kubernetes version. Istio supports n-1 minor versions, Linkerd typically supports last 3 Kubernetes versions.
Related Skills
configure-ingress-networking- Gateway configuration complements mesh ingressdeploy-to-kubernetes- Application deployment patterns that work with service meshsetup-prometheus-monitoring- Prometheus integration for mesh metricsmanage-kubernetes-secrets- Certificate management for mTLSenforce-policy-as-code- OPA policies that work alongside mesh authorization
GitHub 저장소
연관 스킬
executing-plans
디자인executing-plans 스킬은 검토 체크포인트가 포함된 통제된 배치로 실행할 완전한 구현 계획이 있을 때 사용합니다. 이 스킬은 계획을 불러와 비판적으로 검토한 후, 소규모 배치(기본값 3개 작업)로 작업을 실행하면서 각 배치 사이에 진행 상황을 아키텍트 검토를 위해 보고합니다. 이를 통해 내재된 품질 관리 체크포인트를 갖춘 체계적인 구현이 보장됩니다.
requesting-code-review
디자인이 스킬은 코드 변경 사항을 요구 사항에 따라 분석하기 위해 코드 리뷰어 하위 에이전트를 호출합니다. 작업 완료 후, 주요 기능 구현 후, 또는 메인 브랜치에 병합하기 전에 사용해야 합니다. 이 리뷰는 현재 구현체와 원래 계획을 비교하여 문제를 조기에 발견하는 데 도움이 됩니다.
connect-mcp-server
디자인이 스킬은 개발자들이 HTTP, stdio 또는 SSE 전송 방식을 통해 MCP 서버를 Claude Code에 연결하는 포괄적인 가이드를 제공합니다. GitHub, Notion 및 사용자 정의 API와 같은 외부 서비스를 통합하기 위한 설치, 구성, 인증 및 보안을 다룹니다. MCP 통합 설정, 외부 도구 구성 또는 Claude의 모델 컨텍스트 프로토콜 작업 시 활용하세요.
web-cli-teleport
디자인이 스킬은 작업 분석을 기반으로 개발자가 Claude Code 웹 인터페이스와 CLI 인터페이스 중 선택할 수 있도록 돕고, 두 환경 간 원활한 세션 텔레포트를 가능하게 합니다. 웹, CLI 또는 모바일 환경 전환 시 세션 상태와 컨텍스트를 관리하여 워크플로를 최적화합니다. 다양한 단계에서 서로 다른 도구가 필요한 복잡한 프로젝트에 사용하세요.
