How To Customize CoreDNS Configuration for Adding Additional External DNS

Problem

How To Customize CoreDNS Configuration for Adding Additional External DNS.

Environment

  • Platform9 Managed Kubernetes - v5.2 and K8s v1.20 and Higher

  • AddOn Management

Procedure

  1. Generate the TOKEN by following steps mentioned in Keystone Identityarrow-up-right.

  2. API to retrieve existing CoreDNS ClusterAddon object detail.

curl -X GET -H "X-Auth-Token: $TOKEN" https://<DU_FQDN>/qbert/v4/<PROJECT_ID>/sunpike/apis/sunpike.platform9.com/v1alpha2/namespaces/default/clusteraddons/<CLUSTER_UUID>-coredns
$ curl -X GET -H "X-Auth-Token: $TOKEN" https://cs-sanchit.platform9.horse/qbert/v4/1c1003c1b84e47e7bd2a4cdf3b725976/sunpike/apis/sunpike.platform9.com/v1alpha2/namespaces/default/clusteraddons/8c8f1d62-159a-4829-b68f-3432d4a9afc6-coredns | jq
...
...
  "spec": {
    "clusterID": "8c8f1d62-159a-4829-b68f-3432d4a9afc6",
    "version": "1.7.0",
    "type": "coredns",
    "override": {
      "params": [
        {
          "name": "dnsMemoryLimit",
          "value": "170Mi"
        },
        {
          "name": "dnsDomain",
          "value": "cluster.local"
        }
      ]
    },
    "watch": true
  1. Create a new JSON spec file with the required additional DNS configuration parameter.

circle-info

Note

The extra DNS configuration parameter one wants to add should have no indentations. The addon operator adds the correct indentation before adding it under the DNS block in the configmap.

This needs to be inputted as a value for the parameter base64EncAdditionalDnsConfig in the JSON spec file.

You can read more about it here CoreDNS Addonarrow-up-right.

  1. Patch the existing CoreDNS ClusterAddon object with the newly created Spec file coredns.json.

circle-info

Info

Replace the placeholders <DU_FQDN>, <PROJECT_ID> and the <CLUSTER_UUID> with their appropriate values required. The name attribute in the spec must be in the format CLUSTER_UUID-coredns

The CoreDNS version in the above JSON file is currently on 1.7.0. It will be updated along with the pf9-kube version and can be referred from the Support Matrix.arrow-up-right

circle-info

Note

The changes made to the AddOn object will persist across management plane & cluster upgrades.

Last updated