Checking CoreDNS Configuration Consistency

Check Item

Check whether the current CoreDNS key configuration Corefile is different from the Helm Release record. The difference may be overwritten during the add-on upgrade, affecting domain name resolution in the cluster.

Solution

You can upgrade the coredns add-on separately after confirming the configuration differences.

  1. For details about how to configure kubectl, see Connecting to a Cluster Using kubectl.
  2. Obtain the Corefile that takes effect currently.

    kubectl get cm -nkube-system coredns -o jsonpath='{.data.Corefile}' > corefile_now.txt
    cat corefile_now.txt

  3. Obtain the Corefile in the Helm Release record (depending on Python 3).

    latest_release=`kubectl get secret -nkube-system -l owner=helm -l name=cceaddon-coredns --sort-by=.metadata.creationTimestamp | awk 'END{print $1}'`
    kubectl get secret -nkube-system $latest_release -o jsonpath='{.data.release}' | base64 -d | base64 -d | gzip -d | python -m json.tool | python -c "
    import json,sys,re,yaml;
    manifests = json.load(sys.stdin)['manifest']
    files = re.split('(?:^|\s*\n)---\s*',manifests)
    for file in files:
        if 'coredns/templates/configmap.yaml' in file and 'Corefile' in file:
          corefile = yaml.safe_load(file)['data']['Corefile']
          print(corefile,end='')
          exit(0);
    print('error')
    exit(1);
    " > corefile_record.txt
    cat corefile_record.txt
    

  4. Compare the output information of 2 and 3.

    diff corefile_now.txt corefile_record.txt -y;

  5. Return to the CCE console and click the cluster name to go to the cluster console. On the Add-ons page, select the coredns add-on and click Upgrade.

    To retain the differentiated configurations, use either of the following methods:
    • Set parameterSyncStrategy to force. You need to manually enter the differentiated configurations. For details, see coredns (System Resource Add-On, Mandatory).
    • If parameterSyncStrategy is set to inherit, differentiated configurations are automatically inherited. The system automatically parses, identifies, and inherits differentiated parameters.

  6. Click OK. After the add-on upgrade is complete, check whether all CoreDNS instances are available and whether the Corefile meets the expectation.

    kubectl get cm -nkube-system coredns -o jsonpath='{.data.Corefile}'

  7. Change the value of parameterSyncStrategy to ensureConsistent to enable configuration consistency verification.

    Use the parameter configuration function of CCE add-on management to modify the Corefile configuration to avoid differences.