writing-skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
setup-service-meshService-Mesh (Istio oder Linkerd) deployen und konfigurieren, um sichere Service-zu-Service-Kommunikation, Traffic-Management, Observability und Richtliniendurchsetzung in Kubernetes-Clustern zu aktivieren. Behandelt Installation, mTLS-Konfiguration, Traffic-Routing, Circuit-Breaking und Integration mit Monitoring-Tools. Einsatz wenn Microservices verschlue…
Independent GitHub snapshot · Automated classification · Original documentation governs
Service-Mesh fuer sichere Service-zu-Service-Kommunikation und erweitertes Traffic-Management deployen und konfigurieren.
Siehe Erweiterte Beispiele fuer vollstaendige Konfigurationsdateien und Vorlagen.
Control-Plane des Service-Meshs auswaehlen und installieren.
Fuer 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
Fuer Linkerd:
curl -sL https://run.linkerd.io/install | sh
linkerd check --pre
linkerd install --ha | kubectl apply -f -
linkerd check
Service-Mesh-Konfiguration mit Ressourcenlimits und Tracing erstellen:
# 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
Erwartet: Control-Plane-Pods laufen im istio-system- (Istio) oder linkerd- (Linkerd) Namespace. istioctl version oder linkerd version zeigt uebereinstimmende Client- und Server-Versionen.
Bei Fehler:
kubectl logs -n istio-system -l app=istiod oder kubectl logs -n linkerd -l linkerd.io/control-plane-component=controllerkubectl get crd | grep istio oder kubectl get crd | grep linkerdNamespaces fuer automatische Sidecar-Proxy-Injection konfigurieren.
Fuer Istio:
# Label namespace for automatic injection
kubectl label namespace default istio-injection=enabled
kubectl get namespace -L istio-injection
Fuer Linkerd:
# Annotate namespace for injection
kubectl annotate namespace default linkerd.io/inject=enabled
Sidecar-Injection mit Beispiel-Deployment testen:
# 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
Anwenden und pruefen:
kubectl apply -f test-deployment.yaml
kubectl get pods -n default
# Expect 2/2 containers (app + proxy)
Erwartet: Neue Pods zeigen 2/2 Container (Anwendung + Sidecar-Proxy). Describe-Ausgabe zeigt istio-proxy- oder linkerd-proxy-Container. Logs zeigen erfolgreichen Proxy-Start.
Bei Fehler:
kubectl get ns default -o yamlkubectl get mutatingwebhookconfigurationkubectl logs -n istio-system -l app=sidecar-injector (Istio)kubectl get deploy test-app -o yaml | istioctl kube-inject -f - | kubectl apply -f -Mutual TLS fuer sichere Service-zu-Service-Kommunikation aktivieren.
Fuer 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
Fuer Linkerd:
# Linkerd enforces mTLS by default for meshed pods
linkerd viz tap deploy/test-app -n default
# Check for 🔒 (lock) symbol
Anwenden und pruefen:
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
Erwartet: Alle Verbindungen zwischen gemeshten Services zeigen mTLS aktiviert. Istio tls-check zeigt STATUS "OK". Linkerd tap-Ausgabe zeigt Schloss-Symbol fuer alle Verbindungen. Service-Logs zeigen keine TLS-Fehler.
Bei Fehler:
kubectl get certificates -A (cert-manager)kubectl logs -n istio-system -l app=istiod | grep -i certkubectl get pods --all-namespaces -o json | jq '.items[] | select(.spec.containers | length == 1) | .metadata.name'Intelligentes Traffic-Routing, Retries und Circuit-Breaking konfigurieren.
Traffic-Management-Richtlinien erstellen:
# 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
Fuer 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
Anwenden und testen:
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
Erwartet: Traffic teilt sich gemaess definierten Gewichten auf. Circuit-Breaker loest nach aufeinanderfolgenden Fehlern aus. Retries erfolgen bei voruebertgehenden Fehlern. Kiali/Linkerd-Dashboard zeigt Traffic-Fluss-Visualisierung.
Bei Fehler:
kubectl get svc -n productionkubectl get pods -n production --show-labelskubectl logs -n istio-system -l app=istiodistioctl analyze zur Konfigurationspruefung verwenden: istioctl analyze -n productionService-Mesh-Telemetrie mit Monitoring- und Tracing-Systemen verbinden.
Observability-Addons installieren:
# 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 -
Benutzerdefinierte Metriken und Dashboards konfigurieren:
# 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
Dashboards aufrufen:
istioctl dashboard grafana # or: linkerd viz dashboard
istioctl dashboard kiali
istioctl dashboard jaeger
Erwartet: Dashboards zeigen Service-Topologie, Anfrage-Raten, Latenz-Perzentile, Fehlerraten. Verteilte Traces in Jaeger verfuegbar. Prometheus scraped Mesh-Metriken erfolgreich. Benutzerdefinierte Metriken erscheinen in Abfragen.
Bei Fehler:
kubectl get servicemonitor -Akubectl get pods -n istio-systemistioctl proxy-config log <pod-name> -n <namespace>kubectl get configmap istio -n istio-system -o yaml | grep -A 5 enableTracingUmfassende Gesundheitspruefungen durchfuehren und laufendes Monitoring einrichten.
# 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
Gesundheitspruef-Skript und Alerts erstellen:
#!/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
Erwartet: Alle Analysen bestehen ohne Warnungen. Proxy-Status zeigt alle Proxies synchronisiert. mTLS-Pruefung bestaetigt Verschluesselung. Metriken zeigen fliessenden Traffic. Control-Plane-Pods stabil mit geringem Ressourcenverbrauch.
Bei Fehler:
istioctl analyze-Ausgabe behebenkubectl logs <pod> -c istio-proxy -n <namespace>kubectl logs -n istio-system deploy/istiod --tail=100kubectl rollout restart deploy/<deployment> -n <namespace>Ressourcenerschoepfung: Service-Mesh fuegt 100-200 MB Speicher pro Pod fuer Sidecars hinzu. Sicherstellen, dass Cluster ausreichende Kapazitaet hat. Geeignete Ressourcenlimits in Injection-Konfiguration setzen.
Konfigurationskonflikte: Mehrere VirtualServices fuer denselben Host verursachen undefiniertes Verhalten. Einzelnen VirtualService pro Host mit mehreren Match-Bedingungen verwenden.
Zertifikats-Ablauf: mTLS-Zertifikate rotieren automatisch, aber CA-Root muss verwaltet werden. Zertifikats-Ablauf mit kubectl get certificate -A ueberwachen und Alerts einrichten.
Sidecar nicht injiziert: Pods vor Namespace-Beschriftung haben keine Sidecars. Muss neu erstellt werden: kubectl rollout restart deploy/<name> -n <namespace>.
DNS-Aufloesung: Service-Mesh fauengt DNS ab. Vollqualifizierte Namen verwenden (service.namespace.svc.cluster.local) fuer Cross-Namespace-Aufrufe.
Port-Benennungspflicht: Istio erfordert benannte Ports nach Protokoll-Namensmuster (z.B. http-web, tcp-db). Unbenannte Ports verwenden standardmaessig TCP-Passthrough.
Schrittweises Rollout erforderlich: STRICT mTLS nicht sofort in Produktion aktivieren. PERMISSIVE-Modus bei Migration verwenden, alle Services pruefen, dann zu STRICT wechseln.
Observability-Overhead: 100% Tracing-Sampling verursacht Leistungsprobleme. 1-10% fuer Produktion verwenden: sampling: 1.0 in Mesh-Konfiguration.
Gateway vs VirtualService Verwechslung: Gateway konfiguriert Ingress (Load-Balancer), VirtualService konfiguriert Routing. Beide fuer externen Traffic erforderlich.
Versionskompatibilitaet: Mesh-Version muss mit Kubernetes-Version kompatibel sein. Istio unterstuetzt n-1-Minor-Versionen, Linkerd typischerweise die letzten 3 Kubernetes-Versionen.
configure-ingress-networking - Gateway-Konfiguration ergaenzt Mesh-Ingressdeploy-to-kubernetes - Anwendungs-Deployment-Muster fuer Service-Meshsetup-prometheus-monitoring - Prometheus-Integration fuer Mesh-Metrikenmanage-kubernetes-secrets - Zertifikatsverwaltung fuer mTLSenforce-policy-as-code - OPA-Richtlinien neben Mesh-Autorisierung