edit-icon download-icon

Implement multiple environments by using configurations

Last Updated: Dec 18, 2017

An application consists of codes and configurations. After an application is containerized, the configurations are usually transmitted by using container environment variables to deploy multiple applications using the same image and different configurations.

Limits

  • When associating a configuration file with an application, make sure the configuration file is in the same region as the application.
  • Currently, associating a configuration file when creating an application is only available when you create the application by using an orchestration template.

Scenarios

Create an application

  1. Log on to the Container Service console.

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

  3. Select the region in which you want to create a configuration from the Region list and click Create.

    1

  4. Enter the configuration file information and click OK.

    • File Name: It can contain 1–32 characters.
    • Description: It can contain up to 128 characters.
    • Configuration: You can add up to 50 configurations in a region.

    In this example, the size variable is set.

    1

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

  6. Select the cluster in the same region as the created configuration from the Cluster list and click Create Application.

  7. Complete the basic information for the application and click Create with Orchestration Template.

  8. Enter the following orchestration template and then click Create and Deploy.

    Wherein, size is a dynamic variable and will be overwritten by the value in the configuration.

    1. busybox:
    2. image: 'busybox'
    3. command: 'top -b'
    4. labels:
    5. aliyun.scale: $size
  9. The Template Parameter dialog box appears.

    1

  10. Select the configuration file to be associated with from the Associated Configuration File list.

  11. Click Replace Variable and click OK.

Update an application

If you associated a configuration file when creating an application, you can update the application by modifying the configuration file and redeploying the application.

  1. Log on to the Container Service console.

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

  3. Select the region in which the configuration you want to modify resides from the Region list, and click Modify at the right of the configuration.

    1

  4. Click Confirm in the displayed dialog box.

  5. Click Edit (changes to Save after you click it) at the right of the variable you want to modify. Modify the variable value. Click Save and then click OK.

    1

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

  7. Select the cluster in the same region as the created configuration, and then click Redeploy at the right of the application.

    1

    After the application is updated, the number of containers changes to 3.

    1

Trigger an update

If you associated a configuration file when creating an application, you can redeploy the application by using the redeployment trigger.

  1. Log on to the Container Service console.

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

  3. Select the region in which the configuration you want to modify resides from the Region list, and click Modify at the right of the configuration.

    1

  4. Click Confirm in the displayed dialog box.

  5. Click Edit (changes to Save after you click it) at the right of the variable you want to modify. Modify the variable value. Click Save and then click OK.

    1

  6. Create a redeployment trigger.

    For how to create a trigger, see Trigger.

    trigger

  7. Trigger the redeployment trigger.

    1. curl "https://cs.console.aliyun.com/hook/trigger?triggerUrl=Y2ViZDhkZTIwZGMyMjRmOTM4NDIzMTgwMzI3NmIwM2IxfHRlc3QtZ3JvdXB8c2NhbGluZ3wxOXZwYzNmOXFiNTcwfA==&secret=466242376775654951546d6451656a7a66e7f5b61db6885f8d15aa64826672c2"

    After the application is updated, the number of containers changes to 3.

    1

Thank you! We've received your feedback.