1.19.6. 从 ServiceMeshExtension 迁移到 WasmPlugin 资源

ServiceMeshExtension API 从 Red Hat OpenShift Service Mesh 版本 2.2 开始已弃用,并将在以后的版本中删除。如果使用 ServiceMeshExtention API,则必须迁移到 WasmPlugin API 才能继续使用 WebAssembly 扩展。

API 非常相似。迁移由两个步骤组成:

  1. 重命名您的插件文件并更新模块打包。
  2. 创建引用更新的容器镜像的 WasmPlugin 资源。

1.19.6.1. API 更改

新的 WasmPlugin API 与 ServiceMeshExtension 类似,但有一些区别,特别是在字段名称中:

表 1.22. ServiceMeshExtensionsWasmPlugin之间的字段变化

ServiceMeshExtensionWasmPlugin

spec.config

spec.pluginConfig

spec.workloadSelector

spec.selector

spec.image

spec.url

spec.phase 有效值: PreAuthN、PostAuthN、PreAuthZ、PostAuthZ、PreStats、PostStats

spec.phase 有效值: <empty>、AUTHN、AUTHZ、STATS

以下是如何将 ServiceMeshExtension 资源转换为 WasmPlugin 资源的示例。

ServiceMeshExtension 资源

apiVersion: maistra.io/v1
kind: ServiceMeshExtension
metadata:
  name: header-append
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      app: httpbin
  config:
    first-header: some-value
    another-header: another-value
  image: quay.io/maistra-dev/header-append-filter:2.2
  phase: PostAuthZ
  priority: 100

新的 WasmPlugin 资源等同于上面的 ServiceMeshExtension

apiVersion: extensions.istio.io/v1alpha1
kind: WasmPlugin
metadata:
  name: header-append
  namespace: istio-system
spec:
  selector:
    matchLabels:
      app: httpbin
  url: oci://quay.io/maistra-dev/header-append-filter:2.2
  phase: STATS
  pluginConfig:
    first-header: some-value
    another-header: another-value