writing-skills
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
setup-service-meshDeploy and configure a service mesh (Istio or Linkerd) to enable secure service-to-service communication, traffic management, observability, and policy enforcement in Kubernetes clusters. Covers installation, mTLS configuration, traffic routing, circuit breaking, and integration with monitoring tools. Use when microservices need encrypted service-to-service…
Independent GitHub snapshot · Automated classification · Original documentation governs
釋配服網為安服間通、流管、察、策強。
全配與板見 Extended Examples。
擇並裝服網控面。
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
Linkerd:
curl -sL https://run.linkerd.io/install | sh
linkerd check --pre
linkerd install --ha | kubectl apply -f -
linkerd check
建服網配含資源限與追:
# 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
得:控面 pod 行於 istio-system 或 linkerd 名空。istioctl version 或 linkerd version 示客服合本。
敗:
kubectl logs -n istio-system -l app=istiod 或 kubectl logs -n linkerd -l linkerd.io/control-plane-component=controllerkubectl get crd | grep istio 或 kubectl get crd | grep linkerd配名空為自旁代注。
Istio:
# Label namespace for automatic injection
kubectl label namespace default istio-injection=enabled
kubectl get namespace -L istio-injection
Linkerd:
# Annotate namespace for injection
kubectl annotate namespace default linkerd.io/inject=enabled
測旁注樣釋:
# 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
施驗:
kubectl apply -f test-deployment.yaml
kubectl get pods -n default
# Expect 2/2 containers (app + proxy)
得:新 pod 示 2/2 容(應 + 旁代)。述出含 istio-proxy 或 linkerd-proxy 容。日示成代啟。
敗:
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 -啟雙 TLS 為安服間通。
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
Linkerd:
# Linkerd enforces mTLS by default for meshed pods
linkerd viz tap deploy/test-app -n default
# Check for 🔒 (lock) symbol
施驗:
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
得:諸網服間連示 mTLS 啟。Istio tls-check 示 STATUS 為「OK」。Linkerd tap 出示 🔒 於諸連。服日無 TLS 誤。
敗:
kubectl get certificates -Akubectl 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'配智流路、重、行斷。
# 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
Linkerd 流分:
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
施測:
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
得:流按定權分。行斷後續誤跳。重於暫敗發。Kiali/Linkerd 板示流可視。
敗:
kubectl get svc -n productionkubectl get pods -n production --show-labelskubectl logs -n istio-system -l app=istiodistioctl analyze -n production 查配連服網遙與察追系。
裝察附:
# 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 -
配自指與板:
# 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
達板:
istioctl dashboard grafana # or: linkerd viz dashboard
istioctl dashboard kiali
istioctl dashboard jaeger
得:板示服拓、請率、延分位、誤率。散追於 Jaeger 可。Prometheus 採網指成。自指現於詢。
敗:
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 enableTracing行全健察設續察。
# 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
建健察本與警:
#!/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
得:諸析察過無警。proxy-status 示諸代同步。mTLS 察確加密。指示流通。控面 pod 穩低資。
敗:
istioctl analyze 出之具題kubectl logs <pod> -c istio-proxy -n <namespace>kubectl logs -n istio-system deploy/istiod --tail=100kubectl rollout restart deploy/<deployment> -n <namespace>kubectl get certificate -A 察並設警kubectl rollout restart deploy/<name> -n <namespace>sampling: 1.0 於網配configure-ingress-networkingdeploy-to-kubernetessetup-prometheus-monitoringmanage-kubernetes-secretsenforce-policy-as-code