Redeploy workloads using triggers

Updated at:

ACK clusters support triggers. Accessing a trigger URL automatically redeploys the associated workload. This topic describes how to use triggers.

Triggers

You can create triggers to automatically redeploy specified workloads in certain scenarios to improve O&M efficiency. The following table describes common use cases.

Scenario

Trigger action

Description

Trigger redeployment upon configuration update

Update the configuration and redeploy related pods

Redeploy an application by calling a trigger when its associated ConfigMap is updated.

Trigger deployment from an external signal

Automatically deploy a new version of the application

When a new image is pushed to an image repository, a webhook can automatically trigger an application deployment. This ensures that the application is updated after the code changes. For more information, see Use triggers for container DevOps.

Prerequisites

  • You need a Deployment to create and test a trigger. For more information, see Create a stateless Deployment. You do not need to create a Service.

Procedure

  1. Log on to the ACK console. In the left navigation pane, click Clusters.

  2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Workloads > Deployments.

  3. On the Deployments page, find the Nginx workload and click Details in the Actions column.

  4. On the details page of the Nginx workload, click the Triggers tab and then click Create Trigger.

  5. In the Create Trigger dialog box, select Redeploy for Action and then click OK.

    Note

    Currently, the only supported Action is redeployment.

    After you create the trigger, its URL appears on the Triggers tab.

  6. Copy the trigger URL and open it in a browser. You receive a response that includes a status code and a request ID.

    The following code shows a sample response:

    {
      "code": "200",
      "message": "success",
      "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
    }
  7. Return to the details page of the Nginx workload and click the Pods tab. You will see a new pod being created. After the new pod is deployed, the Nginx workload deletes the old pod and keeps only the new one.

Other ways to use triggers

You can use a standard HTTP GET or POST request to activate the trigger. For example, run the command curl https://cs.console.aliyun.com/hook/trigger?token=xxxxxxx.

Note

In some shell environments, the ? character may be interpreted as a wildcard, which causes the curl command to fail. To prevent this, enclose the URL in quotation marks. For example: curl "https://cs.console.aliyun.com/hook/trigger?token=xxxxxxx".

Related documents

You can also manage triggers by calling API operations. For more information, see the following topics: