This topic describes the parameters that are related to network configuration.

Swarm parameter Description Corresponding Kubernetes parameter Sample Swarm configuration Sample Kubernetes configuration How to migrate
net The network mode. This parameter is only available in a Swarm compose file of version 1. It is the same as the --net parameter used in the Docker CLI. For more information, see net. hostNetwork: true, which can be directly converted from net: "host". Other values are not supported in Kubernetes. For more information, see Host namespaces. For more information, see the sample Swarm configuration in net. For more information, see the sample Kubernetes configuration in net.

Migrate manually:

After you use Kompose to convert the Swarm compose file, manually delete unsupported parameters.

aliyun.routing.port_
  • The simple routing configuration in Swarm. This parameter specifies one or more domain names for accessing the service. For more information, see routing.
  • If a domain name is suffixed with .local, it is only used for routing and load balancing among services inside the cluster. For more information, see Routing and Server Load Balancer between services in a cluster.
The ingress parameter. Kompose can convert the first domain name only. You must manually add rules for other domain names. In addition, you must replace the test domain name. For more information, see Support for Ingress. For more information, see the sample Swarm configuration in aliyun.routing.port_. For more information, see the sample Kubernetes configuration in aliyun.routing.port_.

Automatic conversion by using Kompose and manual modification are both needed.

Modify the configurations as follows:
  • Common domain name: After you use Kompose to convert the Swarm compose file, find the Kubernetes resource file *-ingress.yaml of each ingress.
    • Replace host: your-cluster-id.alicontainer.com in this file with the test domain name of the Kubernetes cluster. For example, the test domain name of cluster k8s-piggymetrics-cluster is *.c7f537c92438f415b943e7c2f8ca30b3b.cn-zhangjiakou.alicontainer.com. Use this test domain name to replace .your-cluster-id.alicontainer.com in each ingress resource file.
    • If two or more domain names exist, Kompose can convert the first domain name only. You must manually add rules for other domain names in each ingress resource file.
  • Domain name suffixed with .local:
    • Deploy the Kubernetes resource files first.
    • Create a service in the Container Service - Kubernetes console. A domain name suffixed with .local can only be used for communication within the Swarm cluster, and can contain no port number. In Kubernetes, a service name can contain only lowercase letters and hyphens (-). You cannot add the dot (.) in .local to the service name in Kubernetes. You must modify the application code to migrate the domain name suffixed with .local to Kubernetes.
aliyun.routing.session_sticky Specifies whether to maintain a sticky session when the routing parameter is set for routing requests.
Note This key must be used together with routing.
Not supported in Kubernetes. - - No need to migrate.
hostname The hostname used for accessing a service across containers running on different nodes based on Domain Name System (DNS) and Server Load Balancer (SLB). Typically, it is used by a service to access another service. In Kubernetes, you can create a service for accessing an application across pods. For more information, see Create a service. For more information, see the sample Swarm configuration in hostname. For more information, see the sample Kubernetes configuration in hostname.
Migrate manually:
  1. Deploy the Kubernetes resource files first.
  2. Create ClusterIP services in the Container Service - Kubernetes console. Kompose cannot automatically convert the hostname, links, and external_links parameters in the Swarm Compose file because the container port is not specified in the file.
Note In Kubernetes, a service name can contain only lowercase letters and hyphens (-). If the hostname, links, and external_links parameters contain other characters such as a dot (.), you must modify the application code to migrate these parameters to Kubernetes.
links
  1. The names or aliases for accessing services across containers running on different nodes.
  2. Similar to depends_on, this parameter can be used to determine the startup sequence of services.
  1. Create services with the same names as those specified by the links parameter for accessing applications across pods. For more information, see Create a service.
  2. The startup sequence can be determined based on workload needs.
For more information, see the sample Swarm configuration in links. For more information, see the sample Kubernetes configuration in links.
external_links This parameter connects two services so that they can communicate with each other. Compared with the links parameter, the external_links parameter allows you to connect a service to containers created through other Swarm compose files or in other ways.

In Kubernetes, you can create a service for accessing an application across pods. The pods must be managed by the Kubernetes cluster.

Migration method:
  1. Migrate the containers specified by external_links parameter to the Kubernetes cluster.
  2. Create services with the same names as those specified by the external_links parameter for accessing applications across pods. For more information, see Create a service.
For more information, see the sample Swarm configuration in external_links. For more information, see the sample Kubernetes configuration in external_links.
external:
     host: $RDS_URL
     ports:
       - 3306
The address of the external system to which the service is directly linked.
  • host: the domain name of the external system.
  • ports: the ports of the external system.
The headless service. For more information, see Headless services. For more information, see the sample Swarm configuration in external:***. For more information, see the sample Kubernetes configuration in external:***.
Migrate manually:
  1. Delete the external parameter from the Swarm compose file before you use Kompose to convert this file. This prevents the conversion from being interrupted.
  2. After you use Kompose to convert the Swarm compose file, create a Kubernetes resource file for deploying a headless service, which is a service of the ExternalName type.
  3. Use kubectl to deploy this Kubernetes resource file together with other Kubernetes resource files.
aliyun.lb.port_* The service port to be exposed through an SLB instance to the public or internal network in NAT mapping mode. For more information, see Server Load Balancer routing. Access the service through an SLB instance, which is similar to load balancing in Swarm. For more information, see Use SLB to access services. For more information, see the sample Swarm configuration in aliyun.lb.port_*. For more information, see the sample Kubernetes configuration in aliyun.lb.port_*.

Migrate manually:

After the service is deployed, update the service to LoadBalancer type to access it through an SLB instance. For more information, see Use SLB to access services.
Note
  • The configuration in this example is for reference only. You must follow related Kubernetes documents to configure the service based on your workload needs.
  • When an SLB instance is attached to the service port, production traffic may come in immediately. We recommend that you attach the SLB instance to a test port for testing before you attach the SLB instance to the service port.
dns The upstream DNS server of the container. The DNS configurations that apply to pods. For more information, see Pod's DNS Config.
Note If a DNS server is specified, the service name may fail to be parsed.
For more information, see the sample Swarm configuration in dns. For more information, see the sample Kubernetes configuration in dns.

Migrate manually:

After you use Kompose to convert the Swarm compose file, add the dnsConfig field to the Kubernetes resource file *-deployment.yaml of the application.

net

Sample Swarm configuration Sample Kubernetes configuration
net net

For more information, see logtail2-daemonset.yaml.

aliyun.routing.port_

Sample Swarm configuration Sample Kubernetes configuration
aliyun.routing.port_ aliyun.routing.port_

For more information, see gateway-ingress.yaml.

hostname

Sample Swarm configuration Sample Kubernetes configuration
hostname hostname
Note Create a service with the same name as the hostname in the Container Service - Kubernetes console. Use the container port as the service port.

links

Sample Swarm configuration Sample Kubernetes configuration
links links
Note Create services with the same names as those specified by the links parameter in the Container Service - Kubernetes console.

external_links

Sample Swarm configuration Sample Kubernetes configuration
external_links external_links
Note Create a service with the same name as the one specified by the external_links parameter in the Container Service - Kubernetes console.

external_links

Sample Swarm configuration Sample Kubernetes configuration
external_links external_links
Note Create a service with the same name as the one specified by the external_links parameter in the Container Service - Kubernetes console.

external:***

The external parameter includes the following fields:

external:
     host: $RDS_URL
     ports:
       - 3306
Sample Swarm configuration Sample Kubernetes configuration
external: external:

For more information, see account-db-service.yaml.

aliyun.lb.port_*

Sample Swarm configuration Sample Kubernetes configuration
aliyun.lb.port_* aliyun.lb.port_*

dns

Sample Swarm configuration Sample Kubernetes configuration
dns dns

For more information, see logtail2-daemonset.yaml.