Procedure

  1. Download a Swarm Compose file.
    1. Log on to the Container Service - Swarm console. In the left-side navigation pane, click Applications. On the Applications page, find the target application and click Change Configuration in the Actions column.
    2. Copy the configurations and save them in a .yaml file on the local computer. In this topic, name the file swarm-piggymetrics.yaml, which is the Swarm Compose file that you can preprocess.
  2. Replace the environment variables in the Swarm Compose file with the actual values.
    You can create a configuration file in the Container Service - Swarm console and use the configuration file to replace variables in a Swarm Compose file with the actual values. Kubernetes does not provide a feature that matches this feature. Before you use Kompose to convert a Swarm Compose file, manually replace variables, which start with a dollar sign ($), in the Swarm Compose file with the actual values. To replace variables in the Swarm Compose file, follow these steps:
    1. Log on to the Container Service - Swarm console. In the left-side navigation pane, click Configurations. On the Configuration File List page, select the target region and find the target configuration file.
    2. Replace the variables, which start with a dollar sign ($), in the swarm-piggymetrics.yaml file with the actual values according to this configuration file.
  3. Preprocess some keys.
    You must preprocess some keys in the Swarm Compose file. Otherwise, Kompose may report an error and stop conversion due to invalid value types or unsupported keys. Generally, you must preprocess keys in the following ways.
    • Change the values of the following keys from the Boolean type to the string type. For example, change true or false to 'true' or 'false'.
      • aliyun.global
      • aliyun.latest_image
    • Delete the services that contain the external key and manually migrate these services later.
      • external
  4. Modify the version number of the Swarm Compose file.
    Kompose works best with Swarm Compose files of version 2 and does not support Swarm Compose files of versions 2.X. Therefore, you must change the version declaration from version: '2.X' to version: '2' in the Swarm Compose file. Otherwise, an error is returned during the conversion.