Procedure

  1. Download a Swarm Compose file.
    1. Log on to the Container Service for Swarm console. In the left-side navigation pane, click Applications. On the Applications page, find the application that you want to migrate and click Change Configuration in the Actions column.
    2. Copy the configurations and save them in a YAML file on the on-premises machine. In this topic, the file is named swarm-piggymetrics.yaml, which is the Swarm Compose file that you can pre-process.
  2. Replace environment variables in the Swarm compose file with actual values.
    The Container Service for Swarm console allows you to use a configuration file to replace variables in a Swarm compose file with actual values. Kubernetes does not support this feature. Before you use Kompose to convert a Swarm compose file, you must manually replace the dollar signs ($) in the compose file with actual values. To replace variables in the Swarm compose file, perform the following steps:
    1. Log on to the Container Service for Swarm console. In the left-side navigation pane, click Configurations. On the page that appears, select the region where the configuration file is deployed and find the configuration file.
    2. Replace the dollar signs ($) in the swarm-piggymetrics.yaml file with the actual values based on this configuration file.
  3. Pre-process labels.
    You must pre-process the labels in the Swarm compose file. Otherwise, Kompose may report an error and stop the conversion as a result of invalid formats or unsupported labels. The following text describes the two major methods of label processing. For more information about each label, see Application configuration parameters, Application release parameters, Network configuration labels, and Log configuration parameters.
    • Change the values of the following labels from BOOLEAN to STRING. For example, change true or false to "true" or "false".
      • aliyun.global
      • aliyun.latest_image
    • Kubernetes Services with labels that contain the following value cannot be migrated. You must delete them and create new ones with the same configurations in the related Kubernetes cluster.
      • external
  4. Modify the version number of the Swarm compose file.
    Kompose supports Swarm compose files of version 2. You must change the version declaration from version: '2.X' to version: '2' in the Swarm compose file. Otherwise, an error will occur during conversion.