﻿# Install NodeLocal DNS Cache

> [HTML Version](install-nodelocal-dns-cache.html)

NodeLocal DNS Cache helps reduce the load on DNS queries within a Kubernetes cluster. NodeLocal DNS enhances the stability of DNS name resolution, which in turn can avoid DNAT rules, connection tracking, and connection count limits.

````
начало внимание 

````
For Kubernetes clusters deployed on the Deckhouse platform, the installation of NodeLocal DNS is not required. In this case, use the built-in [module](https://deckhouse.io/documentation/v1/modules/350-node-local-dns/). 

````
конец внимание 

````
The installation consists of four steps:

1. [Get the IP address of the kube-dns service](#get-ip-addresses).

2. [Download the Helm chart and configuration file](#download-helm-chart-and-config-file).

3. [Fill out the configuration file](#fill-config-file).

4. [Install the Node Local DNS chart using Helm in the Kubernetes cluster](#install-nodelocaldns-chart).

## Step 1: Get the IP address of the kube-dns service

The kube-dns service is typically located in the \[OBJECT\] of the Kubernetes cluster.

Determine the IP address of the kube-dns service by executing the command:

````
kubectl get svc kube-dns -n kube-system -o jsonpath=\{.spec.clusterIP\}

````
The result of the command should be the IP address, which will be used in Step 3. In the context of this article, the result of the command is the IP address 172.20.0.10.

## Step 2: Download the Helm chart and configuration file

For installation via the internet, obtain the configuration file \[OBJECT\] by executing the command:

````
helm repo add brix365 https://charts.brix365.com  
helm repo update  
helm show values brix365/node-local-dns > values-nodelocal-dns.yaml

````
Getting the configuration file for installation in a closed-loop environment without internet access

1. On a computer with internet access, download the BRIX images and upload them to the local image registry by executing the following command:

````
helm repo add brix365 https://charts.brix365.com  
helm repo update  
helm pull brix365/node-local-dns

````
For more details, see [Download BRIX images](downloadin-images-elma365.md).

2. Copy the downloaded chart archive \[OBJECT\] to the server where the installation will be performed.

3. Unpack this chart and copy the default configuration file \[OBJECT\] to \[OBJECT\]: 

````
tar -xf node-local-dns-X.Y.Z.tgz  
cp node-local-dns/values.yaml values-nodelocal-dns.yaml
````

## ````
Step 3: Fill out the configuration file

Fill out the configuration file \[OBJECT\] for the installation of NodeLocal DNS Cache.

````
\# NodeLocal DNS Cache settings  
node-local-dns:  
  config:  
    # cluster domain  
    dnsDomain: "cluster.local"  
    # IP address of kube-dns service  
    dnsServer: "172.20.0.10"  
    # IP address for NodeLocal DNS Cache.  
    localDns: "169.254.20.25"

````
where:

- \[OBJECT\] is the domain of the Kubernetes cluster;

- \[OBJECT\] is the IP address of the kube-dns service, obtained in Step 1;

- \[OBJECT\] is the local IP address for NodeLocal DNS Cache.

Filling out connection parameters to the private registry for installation in a closed-loop environment without internet access

  
To connect to the private registry, you need to:

1. Download BRIX images and upload them to the local image registry. For more details, see [Download BRIX images](downloadin-images-elma365.md).

2. Set the address and path for the parameter \[OBJECT\].

3. Indicate the name of the secret with access rights to the private registry in the parameter \[OBJECT\]. The secret must be created manually and encrypted in Base64.

````
\# NodeLocal DNS Cache settings  
node-local-dns:  
  # Connection parameters to the private registry  
  image:  
    # address and path for the private registry  
    repository: registry.example.com/dns/k8s-dns-node-cache  
  # The secret with access rights to the private registry must be created manually, encrypted in Base64  
  imagePullSecrets:  
    - myRegistryKeySecretName

````
where **repository **format is:

- address is \[OBJECT\]; 

- path is \[OBJECT\]. 

## Step 4: Install the Node Local DNS chart using Helm in the Kubernetes cluster

Perform the installation of the Node Local DNS chart in \[OBJECT\].

For online installation:

````
helm upgrade --install nodelocaldns brix365/node-local-dns -f values-nodelocal-dns.yaml -n kube-system

````
For offline installation without internet access:

````
helm upgrade --install nodelocaldns ./node-local-dns -f values-nodelocal-dns.yaml -n kube-system

## ````
Delete Node Local DNS chart using helm in the Kubernetes cluster

To remove the Node Local DNS chart in \[OBJECT\], execute the command:

````
helm uninstall nodelocaldns -n kube-system
````