# Caching Not working for NodeLocal DNSCache.

## Problem

* The NodeLocal DNSCache pods are failing to resolve the cached kubernetes service DNS queries.
* The DNS resolution for kubernetes services failing with `SERVFAIL` response.

## Environment

* Platform9 Managed Kubernetes – All Versions

## Cause

* The TTL of the records coming from CoreDNS is 30 Secs by default, hence any `.cluster.local` records would only be cached for 30s.

{% tabs %}
{% tab title="Javascript" %}

```javascript
kubernetes cluster.local in-addr.arpa ip6.arpa {
            pods insecure
            fallthrough in-addr.arpa ip6.arpa
            ttl 30
        }
```

{% endtab %}
{% endtabs %}

* Due to this any record cached in NodeLocal DNSCache pods would only be queryable for 30 Secs before it is expired from the cache.
* The DNS resolutions beyond 30 Secs will fail with a `SERVFAIL` response.

## Resolution

* The CoreDNS ConfigMap may be edited to set a higher TTL for any such domains; however, this can result in to a situation where these records will take longer to update in case their endpoint is updated.
* The ConfigMap/Corefile for the node-local-dns component would also need to be updated to allow a >30s maximum for any successful lookup record TTLs, e.g.

{% tabs %}
{% tab title="Javascript" %}

```javascript
cache {
            success 9984 60
            denial 9984 5
    }
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Info**

A similar issue was reported to upstream at

<https://github.com/kubernetes/dns/issues/415#issuecomment-712450686>
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pmk/solutions/caching-not-working-for-nodelocal-dnscache.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
