安装 Istio ambient 模式

您可以使用 Alauda Service Mesh Operator 2.1.1 或更高版本,在 Alauda Container Platform 上以 ambient 模式部署 Istio。

先决条件

  • 必须安装 Alauda Container Platform Networking for Multus 插件。
  • kube-ovn 必须为 v4.1.5 或更高版本,并且必须使用 overlay 网络。ambient 模式不适用于 kube-ovn underlay 网络;请参阅 Ambient 模式不适用于 kube-ovn underlay 网络
  • 集群版本必须与您计划部署的 Istio 版本匹配:Istio 1.30 支持 Kubernetes 1.32 到 1.36,Istio 1.28 支持 Kubernetes 1.30 到 1.34。
  • 已安装 Alauda Service Mesh Operator 2.1.1 或更高版本。
  • 集群管理员已通过具有 cluster-admin 角色的有效 ACP CLI(kubectl)会话登录。
  • 您已在本地安装 istioctl,以便使用它运行这些操作步骤。

操作步骤

安装 Istio Container Network Interface(CNI)

  1. 创建 istio-cni 命名空间,并添加标签 istio-discovery=enabled

    kubectl create namespace istio-cni
    kubectl label namespace istio-cni istio-discovery=enabled
  2. 创建名为 istio-cni.yaml 的 IstioCNI 资源:

    apiVersion: sailoperator.io/v1
    kind: IstioCNI
    metadata:
      name: default
    spec:
      version: v1.30.4
      namespace: istio-cni
      profile: ambient
      values:
        cni:
          cniConfDir: /etc/cni/multus/net.d
          excludeNamespaces:
            - istio-cni
            - kube-system
    1. 必须将 profile 字段设置为 ambient
    NOTE
    • 不要将包含 ambient 工作负载的命名空间添加到 values.cni.excludeNamespaces。从 Istio 1.30 开始,Istio CNI agent 会遵循此列表,并将排除命名空间中已加入网格的工作负载移出网格。
    • 默认情况下,ambient 工作负载已启用 DNS 捕获。Istio CNI 在启动时会协调已加入工作负载的 pod 内重定向规则,因此无需重启这些工作负载。
  3. 应用 IstioCNI CR:

    kubectl apply -f istio-cni.yaml
  4. 等待 IstioCNI pod 就绪:

    kubectl wait --for=condition=Ready istiocnis/default --timeout=3m

安装 Istio 控制平面

  1. 创建 istio-system 命名空间,并添加标签 istio-discovery=enabled

    kubectl create namespace istio-system
    kubectl label namespace istio-system istio-discovery=enabled
  2. 创建名为 istio.yaml 的 Istio 资源:

    apiVersion: sailoperator.io/v1
    kind: Istio
    metadata:
      name: default
    spec:
      version: v1.30.4
      namespace: istio-system
      profile: ambient
      values:
        pilot:
          trustedZtunnelNamespace: ztunnel
        meshConfig:
          discoverySelectors:
            - matchLabels:
                istio-discovery: enabled
    1. 必须将 profile 字段设置为 ambient
    2. 必须配置 .spec.values.pilot.trustedZtunnelNamespace,使其与安装 ZTunnel 资源的命名空间匹配。
    3. discoverySelectors 配置确保控制平面仅监视带有 istio-discovery=enabled 标签的命名空间,这有助于减少配置开销,并支持在同一集群中共存多个服务网格。有关详细信息,请参阅 ambient 模式下的发现选择器
  3. 应用 Istio 自定义资源(CR):

    kubectl apply -f istio.yaml
  4. 等待 Istio 控制平面就绪:

    kubectl wait --for=condition=Ready istios/default --timeout=3m

安装 ZTunnel 代理

  1. 创建 ztunnel 命名空间,并添加标签 istio-discovery=enabled

    kubectl create namespace ztunnel
    kubectl label namespace ztunnel istio-discovery=enabled
    NOTE

    ZTunnel 资源的命名空间名称必须与 Istio 配置中的 trustedZtunnelNamespace 参数匹配。

  2. 创建名为 ztunnel.yaml 的 ZTunnel 资源:

    apiVersion: sailoperator.io/v1
    kind: ZTunnel
    metadata:
      name: default
    spec:
      version: v1.30.4
      namespace: ztunnel
      values:
        ztunnel:
          resources:
            requests:
              cpu: 200m
              memory: 512Mi
            limits:
              cpu: 2000m
              memory: 1024Mi
  3. 应用 ZTunnel CR:

    kubectl apply -f ztunnel.yaml
  4. 等待 ZTunnel pod 就绪:

    kubectl wait --for=condition=Ready ztunnel/default --timeout=3m