配置校验

istioctl validate

istioctl validate 可用于校验 istio 配置文件规则,即:验证YAML文件。

istioctl analyze

istioctl analyze 可用于检查istio配置潜在的问题。

如,校验某命名空间下资源配置:

$ istioctl analyze --namespace=bookinfo
2022-06-21T12:39:20.119874Z	warn	 networking.istio.io/v1alpha3/Gateway resource [bookinfo/bookinfo-gateway1] could not be found
Error [IST0101] (VirtualService bookinfo/bookinfo) Referenced gateway not found: "bookinfo-gateway1"
Warning [IST0132] (VirtualService bookinfo/bookinfo) one or more host [*] defined in VirtualService bookinfo/bookinfo not found in Gateway bookinfo/bookinfo-gateway1.
Error: Analyzers found issues when analyzing namespace: bookinfo.
See https://istio.io/v1.13/docs/reference/config/analysis for more information about causes and resolutions.

资源 status

默认情况下,istio 资源是没有 status 字段,需单独进行配置来开启。

配置方法参考:Configuration Status Field

  1. 修改 istio-sidecar-injector ConfingMap 中的 istiod.enableAnalysis 为 true(values 配置项);
  2. 添加 istiod 的环境变量 PILOT_ENABLE_STATUS=true

(上述配置完后,istio 资源中会自动出现 status 字段)

实际配置时,发现 istio 1.9.0 版本未配置生效,在 1.13.4 版本配置生效。

istioctl analyze 对比发现,status 字段展示的信息并不完善:

  • status:并没有体现出潜在的配置问题。

    (细看发现,该特性属于 Alpha 版本,静待后续稳定版本吧。)

    status:
    conditions:
    - lastProbeTime: "2022-07-01T09:21:51.977984805Z"
      lastTransitionTime: "2022-07-01T09:21:51.977984930Z"
      message: 36/36 proxies up to date.
      status: "True"
      type: Reconciled
    observedGeneration: "4"
    
  • istioctl analyze:分析结果一目了然。

 % istioctl analyze -n bookinfo               
2022-07-01T09:40:39.338911Z	warn	 networking.istio.io/v1alpha3/Gateway resource [bookinfo/bookinfo-gateway1] could not be found
Error [IST0101] (VirtualService bookinfo/bookinfo) Referenced gateway not found: "bookinfo-gateway1"
Warning [IST0132] (VirtualService bookinfo/bookinfo) one or more host [*] defined in VirtualService bookinfo/bookinfo not found in Gateway bookinfo/bookinfo-gateway1.
Error: Analyzers found issues when analyzing namespace: bookinfo.
See https://istio.io/v1.13/docs/reference/config/analysis for more information about causes and resolutions.

messages说明:istio/pkg/config/analysis/msg/messages.yaml

no healthy upstream

Istio Ingress resulting in “no healthy upstream”

redis、mysql等注入边车后,无法连接问题

通过DestinationRule 禁用 Redis Service 的 mTLS:

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: redis-disable-mtls
spec:
  host: redis.default.svc.cluster.local
  trafficPolicy:
    tls:
      mode: DISABLE

参考:

  1. Server First Protocols
  2. Istio 运维实战系列(2):让人头大的『无头服务』-上

TCP协议服务故障注入(如:redis)

目前istio故障注入是通过VS实现对http协议的故障,针对TCP协议还未直接支持。

为了解决TCP协议类服务的故障注入,可以采取以下两种方式实现:

  1. 基于 Envoy 的 RedisProxy能力 ,网格内的 Redis 流量将经由 Envoy 代理,通过配置EnvoyFilter来实现。(待验证)
  2. 通过 VS 将匹配到redis端口, 路由到一个未知的service 来实现。
    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
    name: redis-route
    namespace: redis
    spec:
    hosts:
    \- devops-redis.redis.svc.cluster.local
    tcp:
    match:
    \- port: 6379
    route:
    destination:
    host: devops-redis-unknown.redis.svc.cluster.local
    port:
    number: 6379

参考:

  1. Help: Is it possible to inject faults in Redis with Envoy Redis Proxy?
  2. Redis 流量管理
  3. [https://stackoverflow.com/questions/66941477/redis-fault-injection-using-istio-and-envoy-filter](redis fault injection using istio and envoy filter)
  4. How to Fault Injection for redis
Logo

一起探索未来云端世界的核心,云原生技术专区带您领略创新、高效和可扩展的云计算解决方案,引领您在数字化时代的成功之路。

更多推荐