All Products
Search
Document Center

Container Service for Kubernetes:Specify DNS servers for registered clusters

Last Updated:Dec 08, 2023

In hybrid cloud scenarios, you can specify self-managed DNS servers for elastic container instances in registered clusters. This topic describes how to specify DNS servers for registered clusters.

Prerequisites

Procedure

  1. Run the following command to modify the eci-profile file:

    kubectl edit configmap eci-profile -n kube-system
  2. Add annotations in the selectors section of the eci-profile configuration file.

    For example, you can configure the following policy to specify DNS servers for all Elastic Container Instance-based pods. You can also configure dns-selector to allow the policy to take effect only on specified pods. For more information, see Configure selectors.

    Important

    Make sure that the value of Kubernetes. aliyun.com/eci-dns-config is verified in the test environment before the configuration file is applied to the production environment. If the value is improper, the ack-virtual-node component will crash and your businesses will be adversely affected.

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