This page describes how to create Service Extensions plugins that you can use to implement edge extensibility with Google Cloud services such as Media CDN.
For a product overview, see Service Extensions overview.
Before you begin
Prepare and upload the files required to create a plugin.
Get the required Identity and Access Management (IAM) roles and permissions.
Create a plugin
Creating a plugin entails specifying a container image that contains the plugin code, adding a Wasm action, and specifying labels and logging options for the plugin.
Create a plugin by running the
gcloud service-extensions wasm-plugins create
command:gcloud service-extensions wasm-plugins create WASM_PLUGIN \ --description=PLUGIN_DESCRIPTION \ --labels=[LABELS,...] \ --log-config=[LOG_CONFIG,...] \ --image=IMAGE \ --main-version=MAIN_VERSION \ --plugin-config=PLUGIN_CONFIG | --plugin-config-file=PLUGIN_CONFIG_FILE | --plugin-config-uri=PLUGIN_CONFIG_URI
Replace the following:
WASM_PLUGIN
: the ID or the fully qualified name of the pluginPLUGIN_DESCRIPTION
: a description of the pluginLABELS
: labels in the form of key-value pairs separated by commasLOG_CONFIG
: logging options for the plugin. When not set, logs are not captured for the plugin. To enable logging, set theenable
option totrue
. Then specify the following details:sample-rate
: the sampling rate of activity logs as a value between0
and1
. The value0
indicates that log messages are not stored. The default value1
indicates that all log messages are stored. A floating point value between0.0
and1.0
indicates that a percentage of log messages is stored.min-log-level
: the minimum severity level of plugin log messages to be exported to Cloud Logging. The default value isINFO
.
IMAGE
: the URI of the container image with the Wasm module stored in the Artifact Registry repository. Before you specify a container image from another project, ensure that Service Extensions has access to it.MAIN_VERSION
: the ID of the plugin version to create and set as the main (active) versionPLUGIN_CONFIG
,PLUGIN_CONFIG_FILE
, orPLUGIN_CONFIG_URI
: the optional configuration file, which can be specified as a text file, a local file, or a container image in Artifact Registry, respectively
For example:
gcloud service-extensions wasm-plugins create my-plugin \ --description="This is my plugin." \ --log-config=enable=true,sample-rate=0.5,min-log-level=INFO \ --labels=key1=value1,key2=value2 \ --image=...-docker.pkg.dev/my-project/repository/container:tag \ --main-version=v1 \ --plugin-config=config.txt
Create a Wasm action for the plugin by running the
gcloud service-extensions wasm-actions create
command:gcloud service-extensions wasm-actions create WASM_ACTION \ --wasm-plugin=WASM_PLUGIN \ --supported-events=[EVENT,...]
Replace the following:
WASM_ACTION
: the ID or the fully qualified name of the Wasm actionWASM_PLUGIN
: the name of the plugin to which you want to attach the actionEVENT
: the portion of the payload to be processed by the plugin as indicated by either or both of these values:request-headers
orresponse-headers
. If not specified, both headers are processed.
It might take several minutes for a plugin to be created and the related success message to appear.
Access container images in another project
Before you can select container images from another project, the
Service Extensions service agent must have
access to the project repository
and artifactregistry.repositories.downloadArtifacts
permission on the project.
The Service Extensions service agent is named as follows:
service-PROJECT_NUMBER@gcp-sa-networkactions.iam.gserviceaccount.com
Replace PROJECT_NUMBER
with your project number.
What's next
- Learn how to deploy plugins in Media CDN routes.
- Learn how to manage plugins.
- See the Service Extensions overview.