How to check the default CoreDNS configmap of a Rancher Kubernetes Engine (RKE) Kubernetes version
Article Number: 000020036
Environment
- Rancher 2.6.x/ 2.7/2.8.x
- CoreDNS default configuration
Situation
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 before 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
- Python installed.
Resolution
Download the kontainer-metadata
according to the Rancher version you are running.
Rancher 2.6.x:
curl -O https://raw.githubusercontent.com/rancher/kontainer-driver-metadata/release-v2.6/data/data.json
Rancher v2.7.x:
curl -O https://raw.githubusercontent.com/rancher/kontainer-driver-metadata/dev-v2.7/data/data.json
Rancher v2.8.x:
curl -O https://raw.githubusercontent.com/rancher/kontainer-driver-metadata/dev-v2.8/data/data.json
Get the available template list:
python -c "import sys, json; d=json.load(sys.stdin)['K8sVersionedTemplates']['coreDNS']; print (json.dumps(d,indent=4))" <data.json
Output:
{
">=1.16.0-alpha <1.17.0-alpha": "coredns-v1.16",
">=1.17.0-alpha <1.20.15-rancher1-2": "coredns-v1.17",
">=1.20.15-rancher1-2 <1.21.0-rancher1-1": "coredns-v1.8.3-rancher2",
">=1.21.0-rancher1-1 <1.21.9-rancher1-2": "coredns-v1.8.3",
">=1.21.9-rancher1-2": "coredns-v1.8.3-rancher2",
">=1.8.0-rancher0 <1.16.0-alpha": "coredns-v1.8"
}
Translation of one of the entries from the list is as follows:
">=1.21.9-rancher1-2": "coredns-v1.8.3-rancher2",
If the Kubernetes version is greater than or equal to 1.21.9-rancher1-2
, then the CoreDNS key we have to use in the next step is coredns-v1.8.3-rancher2.
python -c "import sys, json; print (json.load(sys.stdin)['K8sVersionedTemplates']['templateKeys']['coredns-v1.8.3-rancher2'])" <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
data:
Corefile: |
.:53 {
errors
health {
lameduck 5s
}
ready
kubernetes {{.ClusterDomain}} {{ if .ReverseCIDRs }}{{ .ReverseCIDRs }}{{ else }}{{ "in-addr.arpa ip6.arpa" }}{{ end }} {
pods insecure
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
{{- if .UpstreamNameservers }}
forward . {{range $i, $v := .UpstreamNameservers}}{{if $i}} {{end}}{{.}}{{end}}
{{- else }}
forward . "/etc/resolv.conf"
{{- end }}
cache 30
loop
reload
loadbalance
} # STUBDOMAINS - Rancher specific change
---