• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. User Guide 2.0
  4. Cluster Management
  5. Configuring kube-dns/CoreDNS HA Using kubectl

Configuring kube-dns/CoreDNS HA Using kubectl

kube-dns/CoreDNS provides the domain name service (DNS) for clusters. If only one kube-dns/CoreDNS is deployed in a cluster, the entire cluster will not run properly if the kube-dns/CoreDNS fails. Therefore, you are advised to configure kube-dns/CoreDNS HA for a cluster.

This section describes how to use kubectl to configure kube-dns/CoreDNS HA.

NOTE:

By default, kube-dns is installed for CCE clusters of Kubernetes v1.9, and CoreDNS is installed for CCE clusters of Kubernetes v1.11 and later.

Prerequisites

The cluster is accessible from the Internet, or the cluster and the client are in the same VPC.

Procedure

  1. Log in to the CCE console. In the navigation pane, choose Resource Management > VM Clusters. Click Kubectl for the cluster to which you want to connect.
  2. Set the API access mode for the cluster.
  3. Configure the CLI tool.

    After the CLI tool is successfully configured, you can use it to manually configure kube-dns/CoreDNS HA.

  4. Log in to the client.
  5. Edit the deployment configuration file of kube-dns/CoreDNS.

    The following uses the CoreDNS as an example:

    kubectl edit deployment coredns -n kube-system

    Change the value of replicas in the spec section in the deployment configuration file to the number of CoreDNS instances required.

    Example:

    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      annotations:
        deployment.kubernetes.io/revision: "1"
      creationTimestamp: 2019-02-11T09:36:04Z
      generation: 1
      labels:
        app: coredns
        kubernetes-app: coredns
        kubernetes.io/cluster-service: "true"
        kubernetes.io/name: CoreDNS
        release: cceaddon-coredns
      name: coredns
      namespace: kube-system
      resourceVersion: "1927"
      selfLink: /apis/extensions/v1beta1/namespaces/kube-system/deployments/coredns
      uid: 737b9296-2de0-11e9-b629-fa163e7fb882
    spec:
      progressDeadlineSeconds: 600
      replicas: 2
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          app: coredns
          kubernetes-app: coredns
      strategy:
        rollingUpdate:
          maxSurge: 10%
          maxUnavailable: 0
        type: RollingUpdate
      template:
        metadata:
          annotations:
            checksum/config: 3095a9b4028195e7e0b8b22c550bf183d0b7a8a7eba20808b36081d0b39f8b81