How to check the default CoreDNS configmap of a Rancher Kubernetes Engine (RKE) Kubernetes version

Follow
Table of Contents

Task

You might have modified the default configmap for CoreDNS using Rancher Kubernetes Engine's (RKE) cluster configuration YAML (cluster.yml). In this case, you may want to know the default configmap prior to upgrading Kubernetes. This verification step will help you to add all of the default/mandatory parameters to the modified configmap in RKE's cluster.yml, upon upgrade.

Pre-requisites

  • python2

Resolution

Download the kontainer-metadata according to the Rancher version you are running.

Rancher 2.4.x:

curl -O https://raw.githubusercontent.com/rancher/kontainer-driver-metadata/release-v2.4/data/data.json

Rancher v2.5.x:

curl -O https://raw.githubusercontent.com/rancher/kontainer-driver-metadata/dev-v2.5/data/data.json

Get the available template list:

python2 -c "import sys, json; d=json.load(sys.stdin)['K8sVersionedTemplates']['coreDNS']; print json.dumps(d,indent=4)" <data.json

Output:

{
    ">=1.8.0-rancher0 <1.16.0-alpha": "coredns-v1.8",
    ">=1.17.0-alpha": "coredns-v1.17",
    ">=1.16.0-alpha <1.17.0-alpha": "coredns-v1.16"
}

Translation of one of the entry from the list is as follows:

">=1.8.0-rancher0 <1.16.0-alpha": "coredns-v1.8",

If Kubenetes version is greater than or equal to 1.8.0-rancher0 and less than 1.16.0-alpha ,then the CoreDNS key we have to use in next step is coredns-v1.8

python2 -c "import sys, json; print json.load(sys.stdin)['K8sVersionedTemplates']['templateKeys']['coredns-v1.8']" <data.json

The configmap will be printed on the screen along with other YAML template specs associated with CoreDNS.

Sample output:

[...]
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns
  namespace: kube-system
  labels:
      addonmanager.kubernetes.io/mode: EnsureExists
data:
  Corefile: |
    .:53 {
        errors
        health
        kubernetes {{.ClusterDomain}} {{ if .ReverseCIDRs }}{{ .ReverseCIDRs }}{{ else }}{{ "in-addr.arpa ip6.arpa" }}{{ end }} {
          pods insecure
          upstream
          fallthrough in-addr.arpa ip6.arpa
          ttl 30
        }
        prometheus :9153
    {{- if .UpstreamNameservers }}
        forward . {{range $i, $v := .UpstreamNameservers}}{{if $i}} {{end}}{{.}}{{end}}
    {{- else }}
        forward . "/etc/resolv.conf"
    {{- end }}
        cache 30
        loop
        reload
        loadbalance
    }
---
[...]
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.