1.3. 将 Service Mesh 3.x 与 OpenShift Serverless 集成


OpenShift Serverless Operator 提供 Kourier 作为 Knative 的默认入口。但是,无论是否启用了 Kourier,您都可以在 OpenShift Serverless 中使用 Service Mesh。禁用 Kourier 集成后,您可以配置 Kourier ingress 不支持的额外网络和路由选项,如 mTLS 功能。

请注意以下假设和限制:

  • 所有 Knative 内部组件以及 Knative 服务都是 Service Mesh 的一部分,并启用了 sidecar 注入。这意味着整个网格中强制实施严格的 mutual Transport Layer Security (mTLS)。所有对 Knative Services 的请求都需要 mTLS 连接,客户端必须发送其证书,但来自 OpenShift Routing 的调用除外。
  • 带有 Service Mesh 集成的 OpenShift Serverless 只能针对一个服务网格。集群中可以存在多个网格,但 OpenShift Serverless 只在其中之一可用。

1.3.1. 先决条件

  • 您可以使用集群管理员访问权限访问 Red Hat OpenShift Serverless 帐户。
  • 已安装 OpenShift CLI(oc)。
  • 已安装 Serverless Operator。
  • 已安装 Red Hat OpenShift Service Mesh 3.x Operator。
  • 以下流程中的示例使用域 example.com。这个域的示例证书被用作为子域证书签名的证书颁发机构(CA)。

    要在部署中完成并验证这些步骤,您需要一个由广泛信任的公共 CA 签名的证书,或者您的机构提供的 CA。根据您的域、子域和 CA 调整命令示例。

  • 您必须配置通配符证书,以匹配 OpenShift Container Platform 集群的域。例如,如果您的 OpenShift Container Platform 控制台地址是 https://console-openshift-console.apps.openshift.example.com,您必须配置通配符证书,以便域为 *.apps.openshift.example.com。如需更多信息,请参阅创建证书来加密传入的外部流量
  • 如果要使用任何域名,包括不是默认 OpenShift Container Platform 集群域子域的域名,您必须为这些域设置域映射。如需更多信息,请参阅 创建自定义域映射 OpenShift Serverless 文档

1.3.2. 创建证书来加密传入的外部流量

默认情况下,Service Mesh mTLS 功能只会保护 Service Mesh 本身内部的流量,在 ingress 网关和带有 sidecar 的独立 pod 间的安全。要在流向 OpenShift Container Platform 集群时对流量进行加密,您必须先生成证书,然后才能启用 OpenShift Serverless 和 Service Mesh 集成。

先决条件

  • 在 OpenShift Container Platform 上具有集群管理员权限,或者具有 Red Hat OpenShift Service on AWS 或 OpenShift Dedicated 的集群或专用管理员权限。
  • 安装了 OpenShift Serverless Operator 和 Knative Serving。
  • 已安装 OpenShift CLI(oc)。
  • 您可以访问 knative-serving-ingress 命名空间,OpenShift Serverless Operator 在安装过程中自动创建该命名空间。
  • 您已创建了一个项目,或者具有适当的角色和权限访问项目,以创建应用程序和其他工作负载。

流程

  1. 创建为 Knative 服务签名的 root 证书和私钥:

    $ openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \
        -subj '/O=Example Inc./CN=example.com' \
        -keyout root.key \
        -out root.crt
    Copy to Clipboard Toggle word wrap
  2. 创建通配符证书:

    $ openssl req -nodes -newkey rsa:2048 \
        -subj "/CN=*.apps.openshift.example.com/O=Example Inc." \
        -keyout wildcard.key \
        -out wildcard.csr
    Copy to Clipboard Toggle word wrap
  3. 为通配符证书签名:

    $ openssl x509 -req -days 365 -set_serial 0 \
        -CA root.crt \
        -CAkey root.key \
        -in wildcard.csr \
        -out wildcard.crt
    Copy to Clipboard Toggle word wrap
  4. 输入以下命令之一创建一个包含通配符证书的 secret,具体取决于您的 Service Mesh 版本:

    • 选项 A:对于 Service Mesh 2.x,输入 folloing 命令在 istio-system 命名空间中创建 secret:

      $ oc create -n istio-system secret tls wildcard-certs \
          --key=wildcard.key \
          --cert=wildcard.crt
      Copy to Clipboard Toggle word wrap
    • 选项 B:对于 Service Mesh 3.x,输入 folloing 命令在 knative-serving-ingress 命名空间中创建 secret:

      $ oc create -n knative-serving-ingress secret tls wildcard-certs \
          --key=wildcard.key \
          --cert=wildcard.crt
      Copy to Clipboard Toggle word wrap

      用于 secret 的命名空间取决于 Service Mesh 的版本。Service Mesh 2.x 需要 istio-system 命名空间中的证书。Service Mesh 3.x 使用专用的 knative-serving-ingress 命名空间,其中运行 OpenShift Serverless ingress 网关。

您可以将 Service Mesh 3.x 与 OpenShift Serverless 集成,以便为无服务器应用程序启用高级流量管理、安全性和可观察性。本节提供了验证先决条件、安装和配置这两个组件的步骤,并确认集成是否按预期工作。

1.3.3.1. 验证安装先决条件

在安装和配置 Service Mesh 与 Serverless 集成前,请验证是否满足先决条件。

流程

  1. 检查冲突网关:

    示例命令

    $ oc get gateway -A -o jsonpath='{range .items[*]}{@.metadata.namespace}{"/"}{@.metadata.name}{" "}{@.spec.servers}{"\n"}{end}' | column -t
    Copy to Clipboard Toggle word wrap

    输出示例

    knative-serving/knative-ingress-gateway  [{"hosts":["*"],"port":{"name":"https","number":443,"protocol":"HTTPS"},"tls":{"credentialName":"wildcard-certs","mode":"SIMPLE"}}]
    knative-serving/knative-local-gateway    [{"hosts":["*"],"port":{"name":"http","number":8081,"protocol":"HTTP"}}]
    Copy to Clipboard Toggle word wrap

    这个命令不应该返回绑定端口 的网关 :443hosts: ["*"],除了作为另一个 Service Mesh 实例一部分的 knative-serving Gateways 的网关。

    注意

    Serverless 是 Serverless 一部分的网格必须不同,最好只为 Serverless 工作负载保留。这是因为额外的配置(如 Gateways )可能会影响 Serverless 网关 knative-local-gatewayknative-ingress-gateway。Red Hat OpenShift Service Mesh 只允许一个网关在同一端口(端口:443 )上声明通配符主机绑定(hosts:["*"])。如果另一个网关已绑定此配置,则必须为 Serverless 工作负载创建一个单独的网格。

1.3.3.2. 安装和配置 Service Mesh 3.x

您可以通过安装和配置所需的 Istio 组件、网关和 Knative Serving 资源,将 Service Mesh 3.x 与 Serverless 集成。配置这些资源后,您可以使用 Istio 部署 Knative Serving 实例,以确保无服务器工作负载在 Service Mesh 环境中运行。

流程

  1. 使用以下配置在 istio-system 命名空间中创建 Istio 资源:

    apiVersion: sailoperator.io/v1
    kind: Istio
    metadata:
      name: default
    spec:
      values:
        meshConfig:
          defaultConfig:
            terminationDrainDuration: 35s
      updateStrategy:
        inactiveRevisionDeletionGracePeriodSeconds: 30
        type: InPlace
      namespace: istio-system
      version: v1.26-latest
    Copy to Clipboard Toggle word wrap
  2. 运行以下命令,创建一个名为 istio-system 的项目:

    $ oc new-project istio-system
    Copy to Clipboard Toggle word wrap
  3. 运行以下命令来应用 Istio 自定义资源(CR):

    $ oc apply -f istio.yaml
    Copy to Clipboard Toggle word wrap
  4. 使用以下配置在 istio-cni 命名空间中创建 IstioCNI 资源:

    apiVersion: sailoperator.io/v1
    kind: IstioCNI
    metadata:
      name: default
    spec:
      namespace: istio-cni
      version: v1.26-latest
    Copy to Clipboard Toggle word wrap
  5. 运行以下命令,创建一个名为 istio-cni 的项目:

    $ oc new-project istio-cni
    Copy to Clipboard Toggle word wrap
  6. 运行以下命令来应用 IstioCNI CR:

    $ oc apply -f istio-cni.yaml
    Copy to Clipboard Toggle word wrap
  7. 使用以下配置,创建名为 gateway-deploy.yaml 的文件:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: knative-istio-ingressgateway
      namespace: knative-serving-ingress
    spec:
      selector:
        matchLabels:
          knative: ingressgateway
      template:
        metadata:
          annotations:
            inject.istio.io/templates: gateway
          labels:
            knative: ingressgateway
            sidecar.istio.io/inject: "true"
        spec:
          containers:
            - name: istio-proxy
              image: auto
    
    ---
    # Set up roles to allow reading credentials for TLS
    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: istio-ingressgateway-sds
      namespace: knative-serving-ingress
    rules:
      - apiGroups: [""]
        resources: ["secrets"]
        verbs: ["get", "watch", "list"]
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: istio-ingressgateway-sds
      namespace: knative-serving-ingress
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: istio-ingressgateway-sds
    subjects:
      - kind: ServiceAccount
        name: default
    Copy to Clipboard Toggle word wrap
    • spec.template.metadata.annotations.inject.istio.io/templates 指定网关注入模板,而不是默认的 sidecar 模板。
    • spec.template.metadata.labels.knative 为网关定义唯一标签。这需要确保网关可以选择此工作负载。
    • spec.template.metadata.labels.sidecar.istio.io/inject 启用网关注入。
    • spec.template.spec.containers.image 确保镜像在每次 pod 启动时自动更新。
  8. 运行以下命令来应用资源:

    $ oc apply -f gateway-deploy.yaml
    Copy to Clipboard Toggle word wrap
  9. 使用以下配置创建名为 service-gateways.yaml 的文件,为 Knative Serving 组件创建网关资源:

    ###########################################################
    # cluster external
    ###########################################################
    apiVersion: v1
    kind: Service
    metadata:
      name: knative-istio-ingressgateway
      namespace: knative-serving-ingress
    spec:
      type: ClusterIP
      selector:
        knative: ingressgateway
      ports:
        - name: http2
          port: 80
          targetPort: 8080
        - name: https
          port: 443
          targetPort: 8443
    ---
    apiVersion: networking.istio.io/v1beta1
    kind: Gateway
    metadata:
      name: knative-ingress-gateway
      namespace: knative-serving
    spec:
      selector:
        knative: ingressgateway
      servers:
        - hosts:
            - '*'
          port:
            name: https
            number: 443
            protocol: HTTPS
          tls:
            credentialName: wildcard-certs
            mode: SIMPLE
    ---
    ###########################################################
    # cluster local
    ###########################################################
    apiVersion: v1
    kind: Service
    metadata:
      labels:
        experimental.istio.io/disable-gateway-port-translation: "true"
      name: knative-local-gateway
      namespace: knative-serving-ingress
    spec:
      ports:
        - name: http2
          port: 80
          protocol: TCP
          targetPort: 8081
      selector:
        knative: ingressgateway
      type: ClusterIP
    ---
    apiVersion: networking.istio.io/v1beta1
    kind: Gateway
    metadata:
      name: knative-local-gateway
      namespace: knative-serving
    spec:
      selector:
        knative: ingressgateway
      servers:
        - hosts:
            - '*'
          port:
            name: http
            number: 8081
            protocol: HTTP
    Copy to Clipboard Toggle word wrap
  10. 运行以下命令来应用资源:

    $ oc apply -f serving-gateways.yaml
    Copy to Clipboard Toggle word wrap
  11. istio-system 命名空间中创建 PeerAuthentication 资源,以使用以下配置在网格间强制实施 mTLS:

    apiVersion: security.istio.io/v1
    kind: PeerAuthentication
    metadata:
      name: mesh-mtls
      namespace: istio-system
    spec:
      mtls:
        mode: STRICT
    Copy to Clipboard Toggle word wrap
  12. 运行以下命令来应用资源:

    $ oc apply -f peerauth.yaml
    Copy to Clipboard Toggle word wrap

1.3.3.3. 安装和配置 Serverless

安装 Service Mesh 后,您需要使用特定的配置安装 Serverless。

流程

  1. 使用以下 KnativeServing 自定义资源安装 Knative Serving,该资源启用 Istio 集成:

    knative-serving-config.yaml 配置文件示例

    apiVersion: operator.knative.dev/v1beta1
    kind: KnativeServing
    metadata:
      name: knative-serving
      namespace: knative-serving
      annotations:
        serverless.openshift.io/disable-istio-net-policies-generation: "true"
    spec:
      ingress:
        istio:
          enabled: true 
    1
    
      deployments: 
    2
    
      - name: activator
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
      - name: autoscaler
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
      config:
        istio: 
    3
    
          gateway.knative-serving.knative-ingress-gateway: istio-ingressgateway.<your-istio-namespace>.svc.cluster.local
          local-gateway.knative-serving.knative-local-gateway: knative-local-gateway.<your-istio-namespace>.svc.cluster.local
    Copy to Clipboard Toggle word wrap

    1
    启用 Istio 集成。
    2
    为 Knative Serving data plane pod 启用 sidecar 注入。
    3
    如果您的 istio 没有在 istio-system 命名空间中运行,则需要使用正确的命名空间设置这两个标记。
  2. 应用 KnativeServing 资源:

    $ oc apply -f knative-serving-config.yaml
    Copy to Clipboard Toggle word wrap
  3. 使用以下 KnativeEventing 对象安装 Knative Eventing,它启用了 Istio 集成:

    knative-eventing-config.yaml 配置文件示例

    apiVersion: operator.knative.dev/v1beta1
    kind: KnativeEventing
    metadata:
      name: knative-eventing
      namespace: knative-eventing
      annotations:
        serverless.openshift.io/disable-istio-net-policies-generation: "true"
    spec:
      config:
        features:
          istio: enabled
      workloads:
        - name: pingsource-mt-adapter
          labels:
            sidecar.istio.io/inject: "true"
          annotations:
            sidecar.istio.io/rewriteAppHTTPProbers: "true"
    
        - name: imc-dispatcher
          labels:
            sidecar.istio.io/inject: "true"
          annotations:
            sidecar.istio.io/rewriteAppHTTPProbers: "true"
    
        - name: mt-broker-ingress
          labels:
            sidecar.istio.io/inject: "true"
          annotations:
            sidecar.istio.io/rewriteAppHTTPProbers: "true"
    
        - name: mt-broker-filter
          labels:
            sidecar.istio.io/inject: "true"
          annotations:
            sidecar.istio.io/rewriteAppHTTPProbers: "true"
    
        - name: job-sink
          labels:
            sidecar.istio.io/inject: "true"
          annotations:
            sidecar.istio.io/rewriteAppHTTPProbers: "true"
    Copy to Clipboard Toggle word wrap

    • spec.config.features.istio 启用 Eventing Istio 控制器为每个 InMemoryChannelKafkaChannel 服务创建一个 DestinationRule
    • spec.workload 为 Knative Eventing pod 启用 sidecar 注入。
  4. 应用 KnativeEventing 资源:

    $ oc apply -f knative-eventing-config.yaml
    Copy to Clipboard Toggle word wrap
  5. 使用以下 KnativeKafka 自定义资源安装 Knative Kafka,该资源启用 Istio 集成:

    knative-kafka-config.yaml 配置文件示例

    apiVersion: operator.serverless.openshift.io/v1alpha1
    kind: KnativeKafka
    metadata:
      name: knative-kafka
      namespace: knative-eventing
    spec:
      channel:
        enabled: true
        bootstrapServers: <bootstrap_servers> 
    1
    
      source:
        enabled: true
      broker:
        enabled: true
        defaultConfig:
          bootstrapServers: <bootstrap_servers> 
    2
    
          numPartitions: <num_partitions>
          replicationFactor: <replication_factor>
        sink:
          enabled: true
      workloads: 
    3
    
      - name: kafka-controller
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
      - name: kafka-broker-receiver
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
      - name: kafka-broker-dispatcher
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
      - name: kafka-channel-receiver
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
      - name: kafka-channel-dispatcher
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
      - name: kafka-source-dispatcher
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
      - name: kafka-sink-receiver
        labels:
          "sidecar.istio.io/inject": "true"
        annotations:
          "sidecar.istio.io/rewriteAppHTTPProbers": "true"
    Copy to Clipboard Toggle word wrap

    1 2
    Apache Kafka 集群 URL,如 my-cluster-kafka-bootstrap.kafka:9092
    3
    为 Knative Kafka pod 启用 sidecar 注入。
  6. 应用 KnativeEventing 对象:

    $ oc apply -f knative-kafka-config.yaml
    Copy to Clipboard Toggle word wrap
  7. 安装 ServiceEntry 以告知 Service Mesh KnativeKafka 组件和 Apache Kafka 集群之间的通信:

    kafka-cluster-serviceentry.yaml 配置文件示例

    apiVersion: networking.istio.io/v1alpha3
    kind: ServiceEntry
    metadata:
      name: kafka-cluster
      namespace: knative-eventing
    spec:
      hosts: 
    1
    
        - <bootstrap_servers_without_port>
      exportTo:
        - "."
      ports: 
    2
    
        - number: 9092
          name: tcp-plain
          protocol: TCP
        - number: 9093
          name: tcp-tls
          protocol: TCP
        - number: 9094
          name: tcp-sasl-tls
          protocol: TCP
        - number: 9095
          name: tcp-sasl-tls
          protocol: TCP
        - number: 9096
          name: tcp-tls
          protocol: TCP
      location: MESH_EXTERNAL
      resolution: NONE
    Copy to Clipboard Toggle word wrap

    1
    Apache Kafka 集群主机列表,如 my-cluster-kafka-bootstrap.kafka
    2
    Apache Kafka 集群监听程序端口。
    注意

    spec.ports 中列出的端口是 examplecategories 端口。实际值取决于 Apache Kafka 集群的配置方式。

  8. 应用 ServiceEntry 资源:

    $ oc apply -f kafka-cluster-serviceentry.yaml
    Copy to Clipboard Toggle word wrap

1.3.3.4. 验证 Service Mesh 3.x 的集成设置

在使用 Serverless 安装和配置 Service Mesh 3.x 后,您可以验证集成是否正常工作。此验证可确保 Service Mesh 组件、网关和 Knative Serving 配置被正确设置,无服务器工作负载可以在网格中安全通信。

folloiwng 测试部署一个简单的 Knative 服务,并验证 sidecar 注入、mutual Transport Layer Security (mTLS)兼容性并通过 ingress 网关进行透传。

流程

  1. 输入以下命令验证 Istio 组件是否正在运行:

    $ oc get pods -n istio-system
    Copy to Clipboard Toggle word wrap
  2. 输入以下命令验证 Istio CNI 组件是否正在运行:

    $ oc get pods -n istio-cni
    Copy to Clipboard Toggle word wrap
  3. 输入以下命令验证 Knative 组件是否正在运行:

    $ oc get pods -n knative-serving
    Copy to Clipboard Toggle word wrap
  4. 输入以下命令验证网关服务是否存在:

    $ oc get svc -n knative-serving-ingress
    Copy to Clipboard Toggle word wrap
  5. 运行以下命令来创建测试命名空间:

    $ oc new-project demo
    Copy to Clipboard Toggle word wrap
  6. 创建 Knative 服务清单示例,并使用以下配置保存为 hello-service.yaml

    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      annotations:
        serving.knative.openshift.io/enablePassthrough: "true"
      name: hello-service
      namespace: demo
    spec:
      template:
        metadata:
          labels:
            sidecar.istio.io/inject: "true"
          annotations:
            sidecar.istio.io/rewriteAppHTTPProbers: "true"
        spec:
          containers:
            - image: quay.io/openshift-knative/showcase
    Copy to Clipboard Toggle word wrap
    • service.knative.openshift.io/enablePassthrough: "true" 配置 ingress 以允许通过 Istio 网关进行 TLS 透传。
    • sidecar.istio.io/inject: "true" 可确保注入 Istio 代理。
    • sidecar.istio.io/rewriteAppHTTPProbers: "true" 使 Knative 健康探测与 mTLS 一起工作。
  7. 输入以下命令应用 Knative 服务:

    $ oc apply -f hello-service.yaml
    Copy to Clipboard Toggle word wrap
  8. 输入以下命令确认 sidecar 注入和 pod 就绪:

    $ oc get pods -n demo
    Copy to Clipboard Toggle word wrap
    $ oc get pod -n demo -l serving.knative.dev/service=hello-service -o jsonpath='{.items[0].spec.containers[*].name}{"\n"}'
    Copy to Clipboard Toggle word wrap
  9. 输入以下命令来检索服务 URL:

    $ oc get ksvc hello-service -n demo -o jsonpath='{.status.url}{"\n"}'
    Copy to Clipboard Toggle word wrap
  10. 输入以下命令之一来调用该服务:

    • 选项 A:如果您在 ingress 域中设置了可信证书,请输入 folloing 命令:

      $ curl https://$(oc get ksvc hello-service -n demo -o jsonpath='{.status.url}' | sed 's#https://##')
      Copy to Clipboard Toggle word wrap
    • 选项 B:如果您使用自定义或自签名证书,请使用 -k 或者输入以下命令提供带有 --cacert <path> 的 CA 文件:

      $ curl  --cacert <path_to_your_CA_file> https://$(oc get ksvc hello-service -n demo -o jsonpath='{.status.url}' | sed 's#https://##')
      Copy to Clipboard Toggle word wrap

      您应该看到类似以下示例的输出:

      {"artifact":"knative-showcase","greeting":"Welcome"}
      Copy to Clipboard Toggle word wrap

      确切的 JSON 值可能有所不同,但响应应该表示 knative-showcase 应用程序成功运行。

1.3.4. 禁用默认网络策略

OpenShift Serverless Operator 默认生成网络策略。要禁用默认网络策略生成,您可以在 KnativeEventingKnativeServing 自定义资源(CR)中添加 serverless.openshift.io/disable-istio-net-policies-generation 注解。

重要

OpenShift Serverless Operator 默认生成所需的网络策略。但是,对 Service Mesh 3.x 的支持当前还只是一个技术预览,但这些默认网络策略还没有考虑 Service Mesh 3.x 的网络要求。因此,在应用这些策略时,新创建的 Knative Services (ksvc)可能无法进入 Ready 状态。

要避免这个问题,您必须在 KnativeServingKnativeEventing 自定义资源中将 serverless.openshift.io/disable-istio-net-policies-generation 注解设置为 true 来禁用 Istio 相关的网络策略。

先决条件

  • 您有以下权限之一来访问集群:

    • OpenShift Container Platform 上的集群管理员权限
    • Red Hat OpenShift Service on AWS 上的集群管理员权限
    • OpenShift Dedicated 上的专用管理员权限
  • 已安装 OpenShift CLI(oc)。
  • 您可以使用适当的角色和权限访问项目,以创建应用程序和其他工作负载。
  • 在集群中安装了 OpenShift Serverless Operator、Knative Serving 和 Knative Eventing。
  • 已安装了启用了 mTLS 功能的 Red Hat OpenShift Service Mesh。

流程

  • 在 Knative 自定义资源中添加 serverless.openshift.io/disable-istio-net-policies-generation: "true" 注解。

    注意

    OpenShift Serverless Operator 默认生成所需的网络策略。当使用 manageNetworkPolicy: false 配置 ServiceMeshControlPlane 时,您必须禁用默认网络策略生成,以确保正确事件交付。要禁用默认网络策略生成,您可以在 KnativeEventingKnativeServing 自定义资源(CR)中添加 serverless.openshift.io/disable-istio-net-policies-generation 注解。

    1. 运行以下命令来注解 KnativeEventing CR:

      $ oc edit KnativeEventing -n knative-eventing
      Copy to Clipboard Toggle word wrap

      KnativeEventing CR 示例

      apiVersion: operator.knative.dev/v1beta1
      kind: KnativeEventing
      metadata:
        name: knative-eventing
        namespace: knative-eventing
        annotations:
          serverless.openshift.io/disable-istio-net-policies-generation: "true"
      Copy to Clipboard Toggle word wrap

    2. 运行以下命令来注解 KnativeServing CR:

      $ oc edit KnativeServing -n knative-serving
      Copy to Clipboard Toggle word wrap

      KnativeServing CR 示例

      apiVersion: operator.knative.dev/v1beta1
      kind: KnativeServing
      metadata:
        name: knative-serving
        namespace: knative-serving
        annotations:
          serverless.openshift.io/disable-istio-net-policies-generation: "true"
      Copy to Clipboard Toggle word wrap

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat