Trigger

Last Updated: Dec 07, 2017

Introduction

A trigger is an API provided by the Container Service for simple and fast redeployment and resource scaling.

As standard APIs require security, strict authentication is needed. However, in scenarios where an API is integrated with a third-party system (for example, Jenkins or other continuous integration and deployment (CI/CD) system), the required permission is limited, for example, messaging only. Therefore, for security and convenience considerations, APIs that have partial authentication policies and can be flexibly called are widely applied in scenarios requiring continuous integration and delivery.

Currently, the Container Service provides redeployment trigger and scaling trigger.

  • Redeployment trigger

    You can integrate your APIs with your monitoring system, and redeploy your applications when the system has exceptions; you can also integrate your APIs with Hub container, so that the container can be automatically redeployed using the new image after the new image is constructed.

  • Scaling trigger

    You can call the scaling trigger to realize container scaling.

Create a trigger

Procedure

  1. Log on to the Container Service console

  2. Click Applications in the left-side navigation pane.

  3. Select the target cluster and click the name of the application.

    application

  4. Click Create Trigger.

    create

  5. Select Redeploy or Scaling in Action and click Confirm.

    • Redeploy

      When you have write permission on the image used by the application, you can select Associated with image update. Then, the container can be automatically redeployed using the new image after the new image is constructed.

      trigger

    • Scaling

      Select the service in the Service drop-down list.

      Note: To use the scaling trigger, you need to upgrade the cluster Agent to the latest version.

      service

    The trigger IP addresses generated are the API IP addresses.

    address

Subsequent operations

You can call the trigger through a third-party system or a GET or POST request. For example, you can run the CURL command to call the trigger.

Call the redeployment trigger:

  1. curl 'https://cs.console.aliyun.com/hook/trigger?triggerUrl=YzI4YTk5NzFkZWZkYzQ2MTJiOWZkNTM1MzY2ZDU1M2NifGNvbGxlY3RkLWJlbmNobWFya3xyZWRlcGxveXwxOGlxbjc1Z25uMmVzfA==&secret=44586c6b466352395143584c3970654ff5323d2509d546fdc1b33054b0928da8'

Call the scaling trigger:

Note: When calling the scaling trigger, you need to add the following parameters in the URL:

Parameter Required Meaning Value
type Yes The type of scaling Reduce: scale_in; expand: scale_out
step Yes The number of containers to be removed or added Positive integer: 1~100

For example, calling the following trigger will add 5 containers to the service.

  1. curl 'https://cs.console.aliyun.com/hook/trigger?triggerUrl=Y2IxZjI5YzhhYjIwMzRlMjBiYjc2OGUzYTlmZDgyNDAyfHdvcmRwcmVzcy10ZXN0fHNjYWxpbmd8MTkzZmEyMXFwZXVwMXw=&secret=53374142724e4e4a626f664a313131556e62c6716cd0d97d096900b3ad42a9ad&type=scale_out&step=5'
Thank you! We've received your feedback.