Wasm Plugin
WasmPlugins provides a mechanism to extend the functionality provided by the Istio proxy through WebAssembly filters.
Order of execution (as part of Envoy’s filter chain) is determined by phase and priority settings, allowing the configuration of complex interactions between user-supplied WasmPlugins and Istio’s internal filters.
Examples:
AuthN Filter deployed to ingress-gateway that implements an OpenID flow and populates the Authorization header with a JWT to be consumed by Istio AuthN.
apiVersion: extensions.istio.io/v1alpha1kind: WasmPluginmetadata:name: openid-connectnamespace: istio-ingressspec:selector:matchLabels:istio: ingressgatewayurl: file:///opt/filters/openid.wasmsha256: 1ef0c9a92b0420cf25f7fe5d481b231464bc88f486ca3b9c83ed5cc21d2f6210phase: AUTHNpluginConfig:openid_server: authnopenid_realm: ingress
This is the same as the last example, but using an OCI image.
apiVersion: extensions.istio.io/v1alpha1kind: WasmPluginmetadata:name: openid-connectnamespace: istio-ingressspec:selector:matchLabels:istio: ingressgatewayurl: oci://private-registry:5000/openid-connect/openid:latestimagePullPolicy: IfNotPresentimagePullSecret: private-registry-pull-secretphase: AUTHNpluginConfig:openid_server: authnopenid_realm: ingress
This is the same as the last example, but using VmConfig to configure environment variables in the VM.
apiVersion: extensions.istio.io/v1alpha1kind: WasmPluginmetadata:name: openid-connectnamespace: istio-ingressspec:selector:matchLabels:istio: ingressgatewayurl: oci://private-registry:5000/openid-connect/openid:latestimagePullPolicy: IfNotPresentimagePullSecret: private-registry-pull-secretphase: AUTHNpluginConfig:openid_server: authnopenid_realm: ingressvmConfig:env:- name: POD_NAMEvalueFrom: HOST- name: TRUST_DOMAINvalue: "cluster.local"
This is also the same as the last example, but the Wasm module is pulled via https and updated for each time when this plugin resource is changed.
apiVersion: extensions.istio.io/v1alpha1kind: WasmPluginmetadata:name: openid-connectnamespace: istio-ingressspec:selector:matchLabels:istio: ingressgatewayurl: https://private-bucket/filters/openid.wasmimagePullPolicy: Alwaysphase: AUTHNpluginConfig:openid_server: authnopenid_realm: ingressvmConfig:env:- name: POD_NAMEvalueFrom: HOST- name: TRUST_DOMAINvalue: "cluster.local"
And a more complex example that deploys three WasmPlugins and orders them using phase and priority. The (hypothetical) setup is that the openid-connect filter performs an OpenID Connect flow to authenticate the user, writing a signed JWT into the Authorization header of the request, which can be verified by the Istio authn plugin. Then, the acl-check plugin kicks in, passing the JWT to a policy server, which in turn responds with a signed token that contains information about which files and functions of the system are available to the user that was previously authenticated. The acl-check filter writes this token to a header. Finally, the check-header filter verifies the token in that header and makes sure that the token’s contents (the permitted ‘function’) matches its plugin configuration.
The resulting filter chain looks like this: -> openid-connect -> istio.authn -> acl-check -> check-header -> router
apiVersion: extensions.istio.io/v1alpha1kind: WasmPluginmetadata:name: openid-connectnamespace: istio-ingressspec:selector:matchLabels:istio: ingressgatewayurl: oci://private-registry:5000/openid-connect/openid:latestimagePullPolicy: IfNotPresentimagePullSecret: private-registry-pull-secretphase: AUTHNpluginConfig:openid_server: authnopenid_realm: ingress
apiVersion: extensions.istio.io/v1alpha1kind: WasmPluginmetadata:name: acl-checknamespace: istio-ingressspec:selector:matchLabels:istio: ingressgatewayurl: oci://private-registry:5000/acl-check/acl:latestimagePullPolicy: AlwaysimagePullSecret: private-registry-pull-secretphase: AUTHZpriority: 1000pluginConfig:acl_server: some_serverset_header: authz_complete
apiVersion: extensions.istio.io/v1alpha1kind: WasmPluginmetadata:name: check-headernamespace: istio-ingressspec:selector:matchLabels:istio: ingressgatewayurl: oci://private-registry:5000/check-header:latestimagePullPolicy: IfNotPresentimagePullSecret: private-registry-pull-secretphase: AUTHZpriority: 10pluginConfig:read_header: authz_completeverification_key: a89gAzxvls0JKAKIJSBnnvvvkIOfunction: read_data
WasmPlugin
WasmPlugins provides a mechanism to extend the functionality provided by the Istio proxy through WebAssembly filters.
| Field | Type | Description | Required |
|---|---|---|---|
selector | WorkloadSelector | Criteria used to select the specific set of pods/VMs on which this plugin configuration should be applied. If omitted, this configuration will be applied to all workload instances in the same namespace. If the | No |
url | string | URL of a Wasm module or OCI container. If no scheme is present, defaults to | No |
sha256 | string | SHA256 checksum that will be used to verify Wasm module or OCI container. If the | No |
imagePullPolicy | PullPolicy | The pull behaviour to be applied when fetching Wasm module by either OCI image or http/https. Only relevant when referencing Wasm module without any digest, including the digest in OCI image URL or sha256 field in | No |
imagePullSecret | string | Credentials to use for OCI image pulling. Name of a K8s Secret in the same namespace as the | No |
pluginConfig | Struct | The configuration that will be passed on to the plugin. | No |
pluginName | string | The plugin name to be used in the Envoy configuration (used to be called | No |
phase | PluginPhase | Determines where in the filter chain this | No |
priority | Int64Value | Determines ordering of | No |
vmConfig | VmConfig | Configuration for a Wasm VM. more details can be found here. | No |
match | TrafficSelector[] | Specifies the criteria to determine which traffic is passed to WasmPlugin. If a traffic satisfies any of TrafficSelectors, the traffic passes the WasmPlugin. | No |
VmConfig
Configuration for a Wasm VM. more details can be found here.
| Field | Type | Description | Required |
|---|---|---|---|
env | EnvVar[] | Specifies environment variables to be injected to this VM. Note that if a key does not exist, it will be ignored. | No |
EnvVar
| Field | Type | Description | Required |
|---|---|---|---|
name | string | Required Name of the environment variable. Must be a C_IDENTIFIER. | No |
valueFrom | EnvValueSource | Required Source for the environment variable’s value. | No |
value | string | Value for the environment variable. Note that if | No |
WasmPlugin.TrafficSelector
TrafficSelector provides a mechanism to select a specific traffic flow for which this Wasm Plugin will be enabled. When all the sub conditions in the TrafficSelector are satisfied, the traffic will be selected.
| Field | Type | Description | Required |
|---|---|---|---|
mode | WorkloadMode | Criteria for selecting traffic by their direction. Note that CLIENT and SERVER are analogous to OUTBOUND and INBOUND, respectively. For the gateway, the field should be CLIENT or CLIENT_AND_SERVER. If not specified, the default value is CLIENT_AND_SERVER. | No |
ports | PortSelector[] | Criteria for selecting traffic by their destination port. More specifically, for the outbound traffic, the destination port would be the port of the target service. On the other hand, for the inbound traffic, the destiation port is the port bound by the server process in the same Pod. If one of the given | No |
PluginPhase
The phase in the filter chain where the plugin will be injected.
| Name | Description |
|---|---|
UNSPECIFIED_PHASE | Control plane decides where to insert the plugin. This will generally be at the end of the filter chain, right before the Router. Do not specify |
AUTHN | Insert plugin before Istio authentication filters. |
AUTHZ | Insert plugin before Istio authorization filters and after Istio authentication filters. |
STATS | Insert plugin before Istio stats filters and after Istio authorization filters. |
PullPolicy
The pull behaviour to be applied when fetching a Wam module, mirroring K8s behaviour.
| Name | Description |
|---|---|
UNSPECIFIED_POLICY | Defaults to IfNotPresent, except for OCI images with tag |
IfNotPresent | If an existing version of the image has been pulled before, that will be used. If no version of the image is present locally, we will pull the latest version. |
Always | We will always pull the latest version of an image when changing this plugin. Note that the change includes |
EnvValueSource
| Name | Description |
|---|---|
INLINE | Explicitly given key-value pairs to be injected to this VM |
HOST | Istio-proxy’s environment variables exposed to this VM. |