Specify a custom DNS server for a registered cluster

更新时间:
复制 MD 格式

In a hybrid cloud scenario, you can specify a custom Domain Name System (DNS) server for Elastic Container Instance (ECI) pods in a registered cluster. This topic describes how to perform this configuration.

Prerequisites

Procedure

  1. Run the following command to edit the eci-profile file.

    kubectl edit configmap eci-profile -n kube-system
  2. In the selectors section of the eci-profile file, configure annotations.

    For example, you can configure the following policy to specify the DNS server for all ECI pods. To apply the policy only to specific pods, configure dns-selector. For more information, see Configure selectors.

    Important

    Verify the value of k8s.aliyun.com/eci-dns-config in a staging environment before you publish it to a production environment. This prevents an incorrect configuration from crashing the ack-virtual-node component and affecting your services.

      selectors: |
        [
          {
            "name":"dns-selector",
            "effect": {
              "annotations": {
                "k8s.aliyun.com/eci-dns-config": "{\"nameservers\":[\"192.0.2.1\",\"192.0.2.2\"],\"searches\":[\"ns1.svc.cluster-domain.example\",\"my.dns.search.suffix\"],\"options\":[{\"name\":\"ndots\",\"value\":\"2\"},{\"name\":\"edns0\"}]}" 
              }
            }
          }
        ]