重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
npx skills add https://github.com/personamanagmentlayer/pcl --skill istio-expert您是一位 Istio 服务网格专家,深谙流量管理、安全性、可观测性和生产运维。您利用 Istio 的控制平面和数据平面,设计和管理安全、可观测的微服务架构。
组件:
控制平面 (istiod):
├── Pilot (流量管理)
├── Citadel (证书管理)
├── Galley (配置验证)
└── Mixer (在 1.7+ 版本中已弃用)
数据平面:
├── Envoy 代理 (边车)
├── 自动边车注入
└── 网关代理
使用 istioctl 安装:
# 下载 Istio
curl -L https://istio.io/downloadIstio | sh -
cd istio-1.20.0
export PATH=$PWD/bin:$PATH
# 使用默认配置文件安装
istioctl install --set profile=default -y
# 使用自定义配置文件安装
istioctl install --set profile=production -y
# 验证安装
istioctl verify-install
# 为命名空间启用边车注入
kubectl label namespace default istio-injection=enabled
IstioOperator 自定义资源:
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
name: production-istio
namespace: istio-system
spec:
profile: production
meshConfig:
accessLogFile: /dev/stdout
enableTracing: true
defaultConfig:
tracing:
sampling: 100.0
zipkin:
address: zipkin.istio-system:9411
components:
pilot:
k8s:
resources:
requests:
cpu: 500m
memory: 2Gi
limits:
cpu: 1000m
memory: 4Gi
hpaSpec:
minReplicas: 2
maxReplicas: 5
ingressGateways:
- name: istio-ingressgateway
enabled: true
k8s:
resources:
requests:
cpu: 1000m
memory: 1Gi
limits:
cpu: 2000m
memory: 2Gi
service:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
name: http2
- port: 443
targetPort: 8443
name: https
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
基础 VirtualService:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: reviews
namespace: default
spec:
hosts:
- reviews
http:
- match:
- headers:
end-user:
exact: jason
route:
- destination:
host: reviews
subset: v2
- route:
- destination:
host: reviews
subset: v1
高级流量分割(金丝雀发布):
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: reviews-canary
namespace: default
spec:
hosts:
- reviews.default.svc.cluster.local
http:
- match:
- headers:
x-canary:
exact: "true"
route:
- destination:
host: reviews
subset: v2
weight: 100
- route:
- destination:
host: reviews
subset: v1
weight: 90
- destination:
host: reviews
subset: v2
weight: 10
URL 重写和重定向:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: api-rewrite
spec:
hosts:
- api.example.com
http:
# 将 HTTP 重定向到 HTTPS
- match:
- port: 80
redirect:
uri: /
authority: api.example.com
scheme: https
redirectCode: 301
# URL 重写
- match:
- uri:
prefix: /v1/
rewrite:
uri: /api/v1/
route:
- destination:
host: api-service
port:
number: 8080
# 超时和重试
- route:
- destination:
host: api-service
timeout: 10s
retries:
attempts: 3
perTryTimeout: 2s
retryOn: 5xx,reset,connect-failure
子集和负载均衡:
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: reviews-destination
namespace: default
spec:
host: reviews
trafficPolicy:
loadBalancer:
consistentHash:
httpHeaderName: x-user-id
connectionPool:
tcp:
maxConnections: 100
http:
http1MaxPendingRequests: 50
http2MaxRequests: 100
maxRequestsPerConnection: 2
outlierDetection:
consecutive5xxErrors: 5
interval: 30s
baseEjectionTime: 30s
maxEjectionPercent: 50
minHealthPercent: 40
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
- name: v3
labels:
version: v3
trafficPolicy:
loadBalancer:
simple: LEAST_REQUEST
熔断:
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: circuit-breaker
spec:
host: backend.prod.svc.cluster.local
trafficPolicy:
connectionPool:
tcp:
maxConnections: 100
http:
http1MaxPendingRequests: 10
http2MaxRequests: 100
maxRequestsPerConnection: 1
outlierDetection:
consecutiveGatewayErrors: 5
consecutive5xxErrors: 5
interval: 5s
baseEjectionTime: 30s
maxEjectionPercent: 100
minHealthPercent: 0
入口网关:
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: web-gateway
namespace: default
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: example-com-tls
hosts:
- "*.example.com"
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: web-route
spec:
hosts:
- "app.example.com"
gateways:
- web-gateway
http:
- match:
- uri:
prefix: /api
route:
- destination:
host: api-service
port:
number: 8080
- match:
- uri:
prefix: /
route:
- destination:
host: frontend-service
port:
number: 80
出口网关:
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: external-gateway
spec:
selector:
istio: egressgateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
hosts:
- api.external.com
tls:
mode: PASSTHROUGH
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: external-api
spec:
hosts:
- api.external.com
gateways:
- mesh
- external-gateway
http:
- match:
- gateways:
- mesh
port: 80
route:
- destination:
host: istio-egressgateway.istio-system.svc.cluster.local
port:
number: 443
- match:
- gateways:
- external-gateway
port: 443
route:
- destination:
host: api.external.com
port:
number: 443
PeerAuthentication (mTLS):
# 网格范围内严格的 mTLS
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: istio-system
spec:
mtls:
mode: STRICT
---
# 命名空间级别的宽松 mTLS
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: namespace-policy
namespace: production
spec:
mtls:
mode: PERMISSIVE
---
# 工作负载特定的 mTLS
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: api-mtls
namespace: production
spec:
selector:
matchLabels:
app: api
mtls:
mode: STRICT
portLevelMtls:
8080:
mode: DISABLE # 允许指标端口使用纯 HTTP
AuthorizationPolicy:
# 默认拒绝所有
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-all
namespace: production
spec:
{}
---
# 允许特定操作
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: api-access
namespace: production
spec:
selector:
matchLabels:
app: api
action: ALLOW
rules:
# 允许来自前端
- from:
- source:
principals:
- cluster.local/ns/production/sa/frontend
to:
- operation:
methods: ["GET", "POST"]
paths: ["/api/v1/*"]
# 允许来自特定命名空间
- from:
- source:
namespaces: ["production"]
to:
- operation:
methods: ["GET"]
paths: ["/health"]
---
# JWT 验证
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name: jwt-auth
namespace: production
spec:
selector:
matchLabels:
app: api
jwtRules:
- issuer: "https://auth.example.com"
jwksUri: "https://auth.example.com/.well-known/jwks.json"
audiences:
- "api.example.com"
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: require-jwt
spec:
selector:
matchLabels:
app: api
action: ALLOW
rules:
- from:
- source:
requestPrincipals: ["*"]
Prometheus 指标:
# 检查指标端点
kubectl exec -it deploy/istio-ingressgateway -n istio-system -- curl localhost:15090/stats/prometheus
# 重要指标
istio_requests_total
istio_request_duration_milliseconds
istio_request_bytes
istio_response_bytes
istio_tcp_connections_opened_total
istio_tcp_connections_closed_total
分布式追踪:
apiVersion: v1
kind: ConfigMap
metadata:
name: istio
namespace: istio-system
data:
mesh: |
enableTracing: true
defaultConfig:
tracing:
sampling: 100.0
custom_tags:
environment:
literal:
value: "production"
zipkin:
address: zipkin.istio-system:9411
安装和管理:
# 安装 Istio
istioctl install --set profile=demo -y
istioctl install --set profile=production -y
# 验证安装
istioctl verify-install
# 显示网格状态
istioctl proxy-status
# 分析配置
istioctl analyze
istioctl analyze -n production
# 显示 Envoy 配置
istioctl proxy-config cluster <pod-name>
istioctl proxy-config listener <pod-name>
istioctl proxy-config route <pod-name>
istioctl proxy-config endpoint <pod-name>
调试:
# 检查注入状态
kubectl get namespace -L istio-injection
# 描述带有边车的 Pod
kubectl describe pod <pod-name>
# 获取 Envoy 日志
kubectl logs <pod-name> -c istio-proxy
# 仪表板
istioctl dashboard kiali
istioctl dashboard prometheus
istioctl dashboard grafana
istioctl dashboard jaeger
# 配置文件对比
istioctl experimental profile diff default production
# 逐步迁移到 STRICT
spec:
mtls:
mode: PERMISSIVE # 从此处开始
# mode: STRICT # 迁移至此
# 在命名空间级别应用以确保一致性
metadata:
namespace: production
http:
- route:
- destination:
host: service
timeout: 10s
retries:
attempts: 3
perTryTimeout: 2s
trafficPolicy:
connectionPool:
http:
http1MaxPendingRequests: 10
outlierDetection:
consecutive5xxErrors: 5
interval: 30s
- 延迟 (请求持续时间)
- 流量 (每秒请求数)
- 错误 (错误率)
- 饱和度 (资源使用率)
1. 无资源限制:
# 错误:无边车资源限制
# 正确:设置明确的限制
spec:
template:
metadata:
annotations:
sidecar.istio.io/proxyCPU: "100m"
sidecar.istio.io/proxyMemory: "128Mi"
2. 过于宽松的策略:
# 错误:允许所有
action: ALLOW
rules:
- {}
# 正确:明确的规则
rules:
- from:
- source:
principals: ["cluster.local/ns/prod/sa/frontend"]
3. 无健康检查:
# 正确:始终定义健康检查
livenessProbe:
httpGet:
path: /health
readinessProbe:
httpGet:
path: /ready
实施 Istio 时:
始终遵循云原生原则,设计安全、可观测且可维护的服务网格配置。
每周安装次数
51
代码仓库
GitHub 星标数
12
首次出现
2026年1月24日
安全审计
安装于
opencode43
codex43
gemini-cli41
github-copilot38
cursor38
amp34
You are an expert in Istio service mesh with deep knowledge of traffic management, security, observability, and production operations. You design and manage secure, observable microservices architectures using Istio's control plane and data plane.
Components:
Control Plane (istiod):
├── Pilot (traffic management)
├── Citadel (certificate management)
├── Galley (configuration validation)
└── Mixer (deprecated in 1.7+)
Data Plane:
├── Envoy Proxy (sidecar)
├── Automatic sidecar injection
└── Gateway proxies
Install with istioctl:
# Download Istio
curl -L https://istio.io/downloadIstio | sh -
cd istio-1.20.0
export PATH=$PWD/bin:$PATH
# Install with default profile
istioctl install --set profile=default -y
# Install with custom profile
istioctl install --set profile=production -y
# Verify installation
istioctl verify-install
# Enable sidecar injection for namespace
kubectl label namespace default istio-injection=enabled
IstioOperator Custom Resource:
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
name: production-istio
namespace: istio-system
spec:
profile: production
meshConfig:
accessLogFile: /dev/stdout
enableTracing: true
defaultConfig:
tracing:
sampling: 100.0
zipkin:
address: zipkin.istio-system:9411
components:
pilot:
k8s:
resources:
requests:
cpu: 500m
memory: 2Gi
limits:
cpu: 1000m
memory: 4Gi
hpaSpec:
minReplicas: 2
maxReplicas: 5
ingressGateways:
- name: istio-ingressgateway
enabled: true
k8s:
resources:
requests:
cpu: 1000m
memory: 1Gi
limits:
cpu: 2000m
memory: 2Gi
service:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
name: http2
- port: 443
targetPort: 8443
name: https
Basic VirtualService:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: reviews
namespace: default
spec:
hosts:
- reviews
http:
- match:
- headers:
end-user:
exact: jason
route:
- destination:
host: reviews
subset: v2
- route:
- destination:
host: reviews
subset: v1
Advanced Traffic Splitting (Canary):
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: reviews-canary
namespace: default
spec:
hosts:
- reviews.default.svc.cluster.local
http:
- match:
- headers:
x-canary:
exact: "true"
route:
- destination:
host: reviews
subset: v2
weight: 100
- route:
- destination:
host: reviews
subset: v1
weight: 90
- destination:
host: reviews
subset: v2
weight: 10
URL Rewrite and Redirect:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: api-rewrite
spec:
hosts:
- api.example.com
http:
# Redirect HTTP to HTTPS
- match:
- port: 80
redirect:
uri: /
authority: api.example.com
scheme: https
redirectCode: 301
# URL rewrite
- match:
- uri:
prefix: /v1/
rewrite:
uri: /api/v1/
route:
- destination:
host: api-service
port:
number: 8080
# Timeout and retry
- route:
- destination:
host: api-service
timeout: 10s
retries:
attempts: 3
perTryTimeout: 2s
retryOn: 5xx,reset,connect-failure
Subsets and Load Balancing:
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: reviews-destination
namespace: default
spec:
host: reviews
trafficPolicy:
loadBalancer:
consistentHash:
httpHeaderName: x-user-id
connectionPool:
tcp:
maxConnections: 100
http:
http1MaxPendingRequests: 50
http2MaxRequests: 100
maxRequestsPerConnection: 2
outlierDetection:
consecutive5xxErrors: 5
interval: 30s
baseEjectionTime: 30s
maxEjectionPercent: 50
minHealthPercent: 40
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
- name: v3
labels:
version: v3
trafficPolicy:
loadBalancer:
simple: LEAST_REQUEST
Circuit Breaking:
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: circuit-breaker
spec:
host: backend.prod.svc.cluster.local
trafficPolicy:
connectionPool:
tcp:
maxConnections: 100
http:
http1MaxPendingRequests: 10
http2MaxRequests: 100
maxRequestsPerConnection: 1
outlierDetection:
consecutiveGatewayErrors: 5
consecutive5xxErrors: 5
interval: 5s
baseEjectionTime: 30s
maxEjectionPercent: 100
minHealthPercent: 0
Ingress Gateway:
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: web-gateway
namespace: default
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: example-com-tls
hosts:
- "*.example.com"
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: web-route
spec:
hosts:
- "app.example.com"
gateways:
- web-gateway
http:
- match:
- uri:
prefix: /api
route:
- destination:
host: api-service
port:
number: 8080
- match:
- uri:
prefix: /
route:
- destination:
host: frontend-service
port:
number: 80
Egress Gateway:
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: external-gateway
spec:
selector:
istio: egressgateway
servers:
- port:
number: 443
name: https
protocol: HTTPS
hosts:
- api.external.com
tls:
mode: PASSTHROUGH
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: external-api
spec:
hosts:
- api.external.com
gateways:
- mesh
- external-gateway
http:
- match:
- gateways:
- mesh
port: 80
route:
- destination:
host: istio-egressgateway.istio-system.svc.cluster.local
port:
number: 443
- match:
- gateways:
- external-gateway
port: 443
route:
- destination:
host: api.external.com
port:
number: 443
PeerAuthentication (mTLS):
# Mesh-wide strict mTLS
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: istio-system
spec:
mtls:
mode: STRICT
---
# Namespace-level permissive mTLS
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: namespace-policy
namespace: production
spec:
mtls:
mode: PERMISSIVE
---
# Workload-specific mTLS
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: api-mtls
namespace: production
spec:
selector:
matchLabels:
app: api
mtls:
mode: STRICT
portLevelMtls:
8080:
mode: DISABLE # Allow plain HTTP on metrics port
AuthorizationPolicy:
# Deny all by default
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-all
namespace: production
spec:
{}
---
# Allow specific operations
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: api-access
namespace: production
spec:
selector:
matchLabels:
app: api
action: ALLOW
rules:
# Allow from frontend
- from:
- source:
principals:
- cluster.local/ns/production/sa/frontend
to:
- operation:
methods: ["GET", "POST"]
paths: ["/api/v1/*"]
# Allow from specific namespace
- from:
- source:
namespaces: ["production"]
to:
- operation:
methods: ["GET"]
paths: ["/health"]
---
# JWT validation
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
name: jwt-auth
namespace: production
spec:
selector:
matchLabels:
app: api
jwtRules:
- issuer: "https://auth.example.com"
jwksUri: "https://auth.example.com/.well-known/jwks.json"
audiences:
- "api.example.com"
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: require-jwt
spec:
selector:
matchLabels:
app: api
action: ALLOW
rules:
- from:
- source:
requestPrincipals: ["*"]
Prometheus Metrics:
# Check metrics endpoint
kubectl exec -it deploy/istio-ingressgateway -n istio-system -- curl localhost:15090/stats/prometheus
# Important metrics
istio_requests_total
istio_request_duration_milliseconds
istio_request_bytes
istio_response_bytes
istio_tcp_connections_opened_total
istio_tcp_connections_closed_total
Distributed Tracing:
apiVersion: v1
kind: ConfigMap
metadata:
name: istio
namespace: istio-system
data:
mesh: |
enableTracing: true
defaultConfig:
tracing:
sampling: 100.0
custom_tags:
environment:
literal:
value: "production"
zipkin:
address: zipkin.istio-system:9411
Installation and Management:
# Install Istio
istioctl install --set profile=demo -y
istioctl install --set profile=production -y
# Verify installation
istioctl verify-install
# Show mesh status
istioctl proxy-status
# Analyze configuration
istioctl analyze
istioctl analyze -n production
# Show Envoy config
istioctl proxy-config cluster <pod-name>
istioctl proxy-config listener <pod-name>
istioctl proxy-config route <pod-name>
istioctl proxy-config endpoint <pod-name>
Debugging:
# Check injection status
kubectl get namespace -L istio-injection
# Describe pod with sidecar
kubectl describe pod <pod-name>
# Get Envoy logs
kubectl logs <pod-name> -c istio-proxy
# Dashboard
istioctl dashboard kiali
istioctl dashboard prometheus
istioctl dashboard grafana
istioctl dashboard jaeger
# Profile application
istioctl experimental profile diff default production
# Gradually migrate to STRICT
spec:
mtls:
mode: PERMISSIVE # Start here
# mode: STRICT # Move to this
# Apply at namespace level for consistency
metadata:
namespace: production
http:
- route:
- destination:
host: service
timeout: 10s
retries:
attempts: 3
perTryTimeout: 2s
trafficPolicy:
connectionPool:
http:
http1MaxPendingRequests: 10
outlierDetection:
consecutive5xxErrors: 5
interval: 30s
- Latency (request duration)
- Traffic (requests per second)
- Errors (error rate)
- Saturation (resource usage)
1. No Resource Limits:
# BAD: No sidecar resource limits
# GOOD: Set explicit limits
spec:
template:
metadata:
annotations:
sidecar.istio.io/proxyCPU: "100m"
sidecar.istio.io/proxyMemory: "128Mi"
2. Overly Permissive Policies:
# BAD: Allow all
action: ALLOW
rules:
- {}
# GOOD: Explicit rules
rules:
- from:
- source:
principals: ["cluster.local/ns/prod/sa/frontend"]
3. No Health Checks:
# GOOD: Always define health checks
livenessProbe:
httpGet:
path: /health
readinessProbe:
httpGet:
path: /ready
When implementing Istio:
Always design service mesh configurations that are secure, observable, and maintainable following cloud-native principles.
Weekly Installs
51
Repository
GitHub Stars
12
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
opencode43
codex43
gemini-cli41
github-copilot38
cursor38
amp34
Elastic Observability SLO管理指南:创建、监控服务等级目标与SLI类型详解
234 周安装
Flutter BLoC 模式最佳实践指南:状态管理、依赖注入与导航规范
46 周安装
skill-comply:AI编码智能体合规性自动化测试工具 - 验证Claude技能规则遵循
46 周安装
ljg-card:内容转PNG图片工具,支持长图、信息图、漫画等多种视觉化格式
46 周安装
Trello项目管理技能:Membrane集成指南与API自动化操作教程
46 周安装
Linear CLI Watch:实时监听Linear问题变更,支持自定义轮询与JSON输出的命令行工具
46 周安装
客户探索方法指南:史蒂夫·布兰克方法论,验证商业假设,避免产品失败
46 周安装