需要统一服务间 mTLS、流量切分、重试超时、熔断和可观测性,但不想在每个应用里重复实现。适合已经运行在 Kubernetes 上、服务数量较多且有多团队协作的场景。
istioctl 与集群版本匹配。http-8080、grpc-9000,否则协议识别可能出错。istioctl version
istioctl x precheck
istioctl install --set profile=default -y
kubectl -n istio-system get pods
资源紧张或希望降低 sidecar 开销时,可评估 ambient 模式;它使用 ztunnel 和 waypoint,不再为每个 Pod 注入 sidecar。
kubectl label namespace demo istio-injection=enabled
kubectl rollout restart deploy -n demo
kubectl get pods -n demo
Pod 应显示 2/2(应用容器 + istio-proxy)。
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
kubectl -n istio-system get svc istio-ingressgateway
kubectl apply -f - <<'EOF'
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: reviews
spec:
hosts: [reviews]
http:
- route:
- destination: {host: reviews, subset: v1}
weight: 90
- destination: {host: reviews, subset: v2}
weight: 10
EOF
kubectl apply -f - <<'EOF'
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: istio-system
spec:
mtls:
mode: STRICT
EOF
istioctl dashboard kiali
istioctl dashboard prometheus
istioctl dashboard grafana
istioctl analyze -A 无错误。istioctl proxy-status 中所有代理均为 SYNCED。kubectl exec 进入 Pod 后访问对端服务成功,且 istioctl authn tls-check 显示 mTLS 生效。PeerAuthentication 从 STRICT 改回 PERMISSIVE,避免旧服务突然中断。STRICT mTLS 上线过早,未注入 sidecar 的客户端会直接失败。holdApplicationUntilProxyStarts 和探针。REGISTRY_ONLY 或 ALLOW_ANY 的行为不同,跨命名空间访问要先确认。istioctl — 安装、诊断、代理状态与 dashboardkubectl — 注入标签、网关和策略管理kiali — 服务拓扑与流量观测prometheus — 指标查询