Hi ..RKE2 NodeLocal DNS Custom Config SetUp I am ...
# rke2
q
Hi ..RKE2 NodeLocal DNS Custom Config SetUp I am using HelmChartConfig to customize CoreDNS via chart values - resources, affinity, autoscaler and servers, which aligns with the RKE2 documentation - docs.rke2.io/add-ons/helm#…. However, I don't see equivalent chart values for customizing the generated NodeLocal DNS ConfigMap or DaemonSet (for example adding CPU/Mem resource for node-local pods, / adding template ANY AAAA to the NodeLocal Corefile). Is there a supported mechanism for this today, or is maintaining a chart fork currently the expected approach? docs.rke2.io/networking/networking_services#… Applying CoreDNS HelmChartConfig after Rancher deploys the default CoreDNS, with NodeLocal DNS enabled
Copy code
- name: Apply RKE2 CoreDNS HelmChartConfig to {{ rancher_clustername }} cluster and enable NodeLocalDNS
  kubernetes.core.k8s:
    state: present
    validate_certs: "{{ K8S_AUTH_API_SSL_VERIFY }}"
    definition:
      apiVersion: helm.cattle.io/v1
      kind: HelmChartConfig
      metadata:
        name: rke2-coredns
        namespace: kube-system
      spec:
        valuesContent: |-
          nodelocal:
            enabled: true
          # ---- CoreDNS Deployment settings ----
          priorityClassName: system-cluster-critical
          resources:
            limits:
              cpu: 300m
              memory: 300Mi
            requests:
              cpu: 100m
              memory: 128Mi
          affinity:
            nodeAffinity:
              requiredDuringSchedulingIgnoredDuringExecution:
                nodeSelectorTerms:
                  - matchExpressions:
                      - key: node-role.kubernetes.io/worker
                        operator: Exists
            podAntiAffinity:
              requiredDuringSchedulingIgnoredDuringExecution:
                - topologyKey: kubernetes.io/hostname
                  labelSelector:
                    matchExpressions:
                      - key: k8s-app
                        operator: In
                        values: ["kube-dns"]
          # ---- Corefile via structured servers (replaces the Corefile) ----
          servers:
            - port: 53
              zones:
                - zone: .
              plugins:
                - name: errors
                - name: template ANY AAAA
                  configBlock: |-
                    rcode NOERROR
                - name: health
                  configBlock: |-
                    lameduck 5s
                - name: ready
                - name: kubernetes
                  parameters: in-addr.arpa ip6.arpa
                  configBlock: |-
                    pods insecure
                    fallthrough in-addr.arpa ip6.arpa
                    ttl 30
                - name: prometheus
                  parameters: :9153
                - name: forward
                  parameters: . /etc/resolv.conf
                - name: cache
                  parameters: "30"
                - name: loop
                - name: reload
                - name: loadbalance
          # ---- CoreDNS Autoscaler ----
          autoscaler:
            affinity:
              nodeAffinity:
                requiredDuringSchedulingIgnoredDuringExecution:
                  nodeSelectorTerms:
                    - matchExpressions:
                        - key: node-role.kubernetes.io/worker
                          operator: Exists
              podAntiAffinity:
                requiredDuringSchedulingIgnoredDuringExecution:
                  - topologyKey: kubernetes.io/hostname
                    labelSelector:
                      matchExpressions:
                        - key: k8s-app
                          operator: In
                          values: ["kube-dns-autoscaler"]
            priorityClassName: system-cluster-critical
            enabled: true
            coresPerReplica: 128
            nodesPerReplica: 4
            preventSinglePointFailure: true
            includeUnschedulableNodes: false
            min: 2
            resources:
              limits:
                cpu: 100m
                memory: 64Mi
              requests:
                cpu: 25m
                memory: 16Mi
You appear to already be setting the resources for nodelocal pods... what exactly are you asking about?
q
@creamy-pencil-82913 yes correct. Above HelmChartConfig yaml spec which i have shared is for CoreDNS, where after rke2 deploys coredns, then i apply above yaml and it works perfectly. lets say if i want to set Limit for cpu/mem resource after rancher deployes node-local then how do it set those? something like below # resources for the node-local-dns pods resources: limits: cpu: 300m memory: 512Mi requests: cpu: 25m memory: 5Mi Also, I'd like to add the following to the default NodeLocal DNS Corefile generated by RKE2:
Copy code
template ANY AAAA {
  rcode NOERROR
}
This allows NodeLocal DNS to immediately return an empty
NOERROR
response for IPv6 (AAAA) queries in our IPv4-only clusters, avoiding unnecessary upstream forwarding. Is there a supported way to customize the generated NodeLocal Corefile? below is default node-local configmap
Copy code
❯ kubectl get cm node-local-dns -n kube-system \
  -o go-template='{{index .data "Corefile"}}'
cluster.local:53 {
    errors
    cache {
            success 9984 30
            denial 9984 5
    }
    reload
    loop
    bind 169.254.20.10 100.66.0.10
    forward . __PILLAR__CLUSTER__DNS__ {
            force_tcp
    }
    prometheus :9253
    health 169.254.20.10:8080


    }
in-addr.arpa:53 {
    errors
    cache 30
    reload
    loop
    bind 169.254.20.10 100.66.0.10
    forward . __PILLAR__CLUSTER__DNS__ {
            force_tcp
    }
    prometheus :9253
    }
ip6.arpa:53 {
    errors
    cache 30
    reload
    loop
    bind 169.254.20.10 100.66.0.10
    forward . __PILLAR__CLUSTER__DNS__ {
            force_tcp
    }
    prometheus :9253
    }
.:53 {
    errors
    cache 30
    reload
    loop
    bind 169.254.20.10 100.66.0.10
    forward . __PILLAR__UPSTREAM__SERVERS__
    prometheus :9253
    }
 ~/Downloads/kube 
github.com/rancher/rke2-charts/blob/…/values.yaml#…
@creamy-pencil-82913 - do we have approach to tweak for my use-case?
i have tried few ways, however rancher reverts those and brings back to defaul spec for node-local