Cloud Composer 3 | Cloud Composer 2 | Cloud Composer 1
This page describes how to install custom plugins in your Cloud Composer environment.
Apache Airflow's plugin manager allows you to write custom in-house Apache Airflow operators, hooks, sensors, or interfaces. For more information, see custom plugins in the Airflow documentation.
About custom plugins
When you create an environment, Cloud Composer
creates a Cloud Storage bucket and associates this
bucket with your environment. You use the plugins
folder in your
environment's bucket to install custom plugins.
Before you begin
- Your account must have a role that allows viewing and modifying your environment's bucket contents.
- This installation method applies only to Airflow plugins. For example, you cannot use this method to install common Python modules or other libraries.
- Plugins must conform to the Airflow plugins template guidelines.
Install a plugin
To install a custom plugin into your Cloud Composer environment,
copy the plugin code to the plugins
folder in your environment's bucket.
To install a plugin:
Console
In the Google Cloud console, go to the Environments page.
Find your environment and follow the DAGs link.
Go one folder level up, then navigate to the
plugins/
folder.Upload your plugin files. For more information about uploading objects, see Uploading objects.
gcloud
Use the following gcloud
command:
gcloud composer environments storage plugins import \
--environment ENVIRONMENT_NAME \
--location LOCATION \
--source PATH_TO_LOCAL_FILE \
--destination PATH_IN_SUBFOLDER
Replace:
ENVIRONMENT_NAME
with the name of the environment.LOCATION
with the region where the environment is located.PATH_TO_LOCAL_FILE
with the path of the file to upload.- (Optional)
PATH_IN_SUBFOLDER
with the subfolder path. Use the--destination
argument to upload a plugin to a subfolder in theplugins
folder. Otherwise, omit the--destination
argument.
View the list of plugins
Console
In the Google Cloud console, go to the Environments page.
Find your environment and follow the DAGs link.
Go one folder level up, then navigate to the
plugins/
folder.View the plugin files.
gcloud
Use the following gcloud
command:
gcloud composer environments storage plugins list \
--environment ENVIRONMENT_NAME \
--location LOCATION
Replace:
ENVIRONMENT_NAME
with the name of the environment.LOCATION
with the region where the environment is located.
Delete a plugin
To delete a plugin from your Cloud Composer environment,
delete the plugin code from the plugins
folder in the environment's bucket.
To delete a plugin:
Console
In the Google Cloud console, go to the Environments page.
Find your environment and follow the DAGs link.
Go one folder level up, then navigate to the
plugins/
folder.Delete the plugin files. For more information about deleting objects, see Deleting objects.
gcloud
Use the following gcloud
command:
gcloud composer environments storage plugins delete \
--environment ENVIRONMENT_NAME \
--location LOCATION \
PLUGIN_TO_DELETE
Download plugins
To download plugins, choose an option:
Console
In the Google Cloud console, go to the Environments page.
Find your environment and follow the DAGs link.
Go one folder level up, then navigate to the
plugins/
folder.Download the plugin files. For more information about deleting objects, see Downloading objects.
gcloud
Use the following gcloud
command:
gcloud composer environments storage plugins export \
--environment ENVIRONMENT_NAME \
--location LOCATION \
--destination PATH_TO_LOCAL_DESTINATION \
--source PATH_IN_FOLDER
Replace:
ENVIRONMENT_NAME
with the name of the environment.LOCATION
with the region where the environment is located.PATH_TO_LOCAL_DESTINATION
with the destination for downloaded file.- (Optional)
--source
is an option to download only one plugin.PATH_IN_FOLDER
is the folder path.
Disable web server plugins
In Cloud Composer 3, if you experience problems with Airflow UI, you can disable web server plugins without having to remove them from the environment's bucket.
gcloud
The following Google Cloud CLI arguments disable and enable web server plugins:
--no-support-web-server-plugins
: disable web server plugins--support-web-server-plugins
: enable web server plugins
To disable web server plugins, run the following Google Cloud CLI command:
gcloud beta composer environments update ENVIRONMENT_NAME \
--location LOCATION \
--no-support-web-server-plugins
To enable web server plugins, run the following Google Cloud CLI command:
gcloud beta composer environments update ENVIRONMENT_NAME \
--location LOCATION \
--support-web-server-plugins
Replace the following:
ENVIRONMENT_NAME
: the name of the environmentLOCATION
: the region where the environment is located
API
Create an
environments.patch
API request.In this request:
In the
updateMask
parameter, specify theconfig.software_config.web_server_plugins_mode
mask.In the request body, in the
web_server_plugins_mode
field:- Specify
PLUGINS_DISABLED
to disable web server plugins. - Specify
PLUGINS_ENABLED
to enable web server plugins.
- Specify
Example (disable plugins):
// PATCH https://composer.googleapis.com/v1beta1/projects/example-project/
// locations/us-central1/environments/example-environment?updateMask=
// config.software_config.web_server_plugins_mode
"config": {
"softwareConfig": {
"web_server_plugins_mode": "PLUGINS_DISABLED"
}
}
Example (enable plugins):
// PATCH https://composer.googleapis.com/v1beta1/projects/example-project/
// locations/us-central1/environments/example-environment?updateMask=
// config.software_config.web_server_plugins_mode
"config": {
"softwareConfig": {
"web_server_plugins_mode": "PLUGINS_ENABLED"
}
}
Troubleshoot plugin issues
Plugins cause problems with Airflow UI
You can disable web server plugins without deleting them. For more information, see Disable web server plugins.
A newly-uploaded plugin is not visible in Airflow UI
If you use Airflow UI Access Control then the newly
uploaded plugin might not be visible in Airflow UI. To address this issue, ask
Airflow UI Administrator to configure access to the newly uploaded plugin or
assign yourself the Admin
role in Airflow UI.