All Products
Search
Document Center

Enterprise Distributed Application Service:Configure DNS policies

Last Updated:Mar 06, 2024

You can configure Domain Name Service (DNS) policies for application pods in Kubernetes clusters. This helps you control access from application pods to DNS and ensure that the application pods can find and communicate with the desired services over DNS. This topic describes how to configure DNS policies and domain name alias for application pods when you create applications.

Procedure

  1. Log on to the EDAS console. In the left-side navigation pane, choose Application Management > Applications. The Applications page appears. In the top navigation bar, select a region. In the upper part of the page, select a namespace. In the upper-left corner, click Create Application.

  2. In the Basic Information step, configure the relevant parameters as required and click Next.

  3. In the Configurations step, configure the environment information, basic information, and deployment method for the application, set the related resource parameters, and then click Next.

  4. In the Advanced Settings step, click DNS Settings, configure the relevant parameters as required, and then click Next.

    Parameter

    Description

    dnsPolicy

    You can use the dnsPolicy field to specify multiple DNS policies for each application pods.

    • ClusterFirst: uses CoreDNS to resolve domain names. The /etc/resolv.conf file of each pod provides the DNS server address, which is also known as the kube-dns address of CoreDNS. This is the default DNS policy for workloads in a cluster.

    • ClusterFirstWithHostNet: combines the ClusterFirst policy with the hostNetwork mode. This allows pods to resolve internal and external Kubernetes domain names.

    • Default: inherits the DNS settings of the cluster node. That is, pods can use the /etc/resolv.conf file of Elastic Compute Service (ECS) instances. This file contains the DNS server address provided by Alibaba Cloud DNS.

    • None: ignores the DNS settings of the cluster node. Instead, the DNS settings specified by the dnsConfig field take effect.

    dnsConfig

    The custom DNS settings for a pod. You can configure the following parameters:

    • nameserver: the IP address of the DNS server for a pod. You can specify up to three IP addresses.

      Note

      If you set the dnsPolicy parameter to None for a pod, you must specify at least one IP address. In other cases, this parameter is optional. The specified IP addresses are added to the nameserver field of the DNS configuration file that is generated based on the specified DNS policy. Duplicate IP addresses are removed.

    • searches: the DNS search domains that you search by hostnames. This parameter is optional. You can use search domains to search for and resolve the domain name of a pod. The specified search domains are added to the basic domain names that are generated based on the specified DNS policy. Duplicate domain names are removed. You can specify up to six search domains.

    • options: the available options. For each option, the Name attribute is required, and the Variable Value attribute is optional. The specified options are added to the list of options that are generated based on the specified DNS policy. Duplicate items are removed.

    hostAliases

    You can add entries for on-premises domain name resolution to the hosts file for a pod.

    • IP Address: the IP addresses to which the specified hostnames are resolved.

    • Hostname: the specified hostnames that you want to resolve to IP addresses. Separate multiple hostnames by commas(,).

  5. Click Create Application.

    1. After you configure the advanced settings, click Create Application. In the Creation Completed step, click Create Application.

    2. In the Confirm Application Change Precheck dialog box, click Start Precheck.

      1. After the data in the dialog box is refreshed, confirm the precheck items and results and click Continue.

      2. (Optional) If you modify the preceding precheck items, click Check Again.

      The application requires several minutes to be deployed. During the process, you can view the change records to track the deployment progress of the application on the Change List page. After you deploy the application, go to the Application Overview page to view the running status of pods. If the pods are in the running state, the application is deployed. You can click the running status of pods to view the Deployments, pods, and advanced configurations of the application instances.

Verify the result

  1. On the Application Overview page, click Click View next to Running Status in the Basic Information section.

  2. In the Pod section, find the pod that you want to verify and click Terminal in the Actions column.

  3. On the Terminal page, run the following command to check whether the DNS settings have been written to the /etc/resolv.conf file:

    cat /etc/resolv.conf

What to do next