告别AnimationPlayer!用Godot4的AnimatedSprite2D节点5分钟搞定角色动画(附精灵表切割技巧)
2026/6/2 7:47:06
**服务网格(Service Mesh)**是一种专门用于处理服务间通信的基础设施层,提供流量管理、安全、可观测性等功能。
┌─────────────────────────────────────────────────────────────────┐ │ Service Mesh Architecture │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ Sidecar │ │ Sidecar │ │ Sidecar │ │ │ │ (Envoy) │ │ (Envoy) │ │ (Envoy) │ │ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │ │ │ │ │ │ │ ▼ ▼ ▼ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ Control Plane │ │ │ │ - Pilot - Citadel - Galley - Mixer │ │ │ └─────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ 数据平面 │ │ │ │ - Envoy代理 - mTLS加密 - 流量路由 - 监控 │ │ │ └─────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────┘| 特性 | Istio | Linkerd | Consul Connect |
|---|---|---|---|
| 数据平面 | Envoy | Linkerd2-proxy | Envoy |
| mTLS | 支持 | 支持 | 支持 |
| 流量管理 | 丰富 | 简洁 | 中等 |
| 可观测性 | 完整 | 基础 | 中等 |
| 部署复杂度 | 高 | 低 | 中等 |
# 下载Istio curl -L https://istio.io/downloadIstio | sh - cd istio-* export PATH=$PWD/bin:$PATH # 安装Istio istioctl install --set profile=demo -y # 启用自动注入 kubectl label namespace default istio-injection=enabledapiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: my-gateway spec: selector: istio: ingressgateway servers: - port: number: 80 name: http protocol: HTTP hosts: - "*"apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: my-virtual-service spec: hosts: - "*" gateways: - my-gateway http: - route: - destination: host: my-service port: number: 80apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: weighted-route spec: hosts: - my-service http: - route: - destination: host: my-service subset: v1 weight: 90 - destination: host: my-service subset: v2 weight: 10apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: header-route spec: hosts: - my-service http: - match: - headers: user-type: exact: premium route: - destination: host: my-service subset: premium - route: - destination: host: my-service subset: standardapiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: timeout-route spec: hosts: - my-service http: - route: - destination: host: my-service timeout: 5sapiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: name: default namespace: istio-system spec: mtls: mode: STRICTapiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: name: default namespace: my-namespace spec: mtls: mode: PERMISSIVEapiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: my-destination-rule spec: host: my-service subsets: - name: v1 labels: version: v1 trafficPolicy: tls: mode: ISTIO_MUTUALapiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: delay-injection spec: hosts: - my-service http: - fault: delay: percentage: value: 10 fixedDelay: 5s route: - destination: host: my-serviceapiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: abort-injection spec: hosts: - my-service http: - fault: abort: percentage: value: 5 httpStatus: 503 route: - destination: host: my-serviceapiVersion: telemetry.istio.io/v1alpha1 kind: Telemetry metadata: name: default namespace: istio-system spec: metrics: - providers: - name: prometheus overrides: - match: metric: REQUEST_DURATION disabled: false traces: - providers: - name: zipkin randomSamplingPercentage: 100apiVersion: telemetry.istio.io/v1alpha1 kind: Telemetry metadata: name: default namespace: istio-system spec: logging: - providers: - name: stdout overrides: - match: operationName: "inbound" disabled: falseapiVersion: networking.istio.io/v1alpha3 kind: Sidecar metadata: name: my-sidecar spec: workloadSelector: labels: app: my-app resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 512MiapiVersion: networking.istio.io/v1alpha3 kind: Sidecar metadata: name: egress-sidecar spec: workloadSelector: labels: app: my-app egress: - hosts: - "./*" - "istio-system/*"apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: canary-deployment spec: hosts: - my-service http: - route: - destination: host: my-service subset: stable weight: 95 - destination: host: my-service subset: canary weight: 5apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: circuit-breaker spec: host: my-service trafficPolicy: connectionPool: tcp: maxConnections: 100 http: http1MaxPendingRequests: 100 maxRequestsPerConnection: 10 outlierDetection: consecutiveErrors: 5 interval: 5s baseEjectionTime: 30s maxEjectionPercent: 50apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: rate-limit spec: hosts: - my-service http: - route: - destination: host: my-service rateLimits: - actions: - requestHeaders: headerName: "x-user-id" descriptorKey: "user"服务网格实践要点:
建议从小规模开始逐步推广服务网格,先在测试环境验证效果。
参考资料: