Use the DNS controller#
Background#
About connecting to off-mesh services#
By default, Aspen Mesh is configured not to allow on-mesh services to connect to off-mesh services. To allow on-mesh services to connect to an off-mesh service, you create a Kubernetes object called an Istio service entry for the off-mesh service. If an Istio service entry exists for an off-mesh service, any pod with a sidecar—that is, any pod in the mesh—can connect to that off-mesh service.
The service entry’s resolution field#
An Istio service entry has a resolution field that specifies how the sidecar should resolve the IP address of the off-mesh service.
Resolution-field values#
The resolution field can have one of several values. This table describes two common values.
Resolution-field value |
Description |
|---|---|
Static |
The IP address of the off-mesh service doesn’t change regularly. The IP address is specified in the service entry. When the service entry is created or modified, all sidecars are provided with the IP address of the off-mesh service. |
DNS |
The IP address of the off-mesh service may change over time. The IP address is not specified in the service entry. All sidecars must independently and repeatedly query CoreDNS to obtain the IP address of the off-mesh service. |
What to notice about DNS-resolution service entries#
As the number of DNS-resolution service entries and the number of sidecars increase, the number of sidecar queries that CoreDNS must handle increases rapidly.
About the DNS controller#
Introduction#
For Istio service entries that meet specific requirements, the DNS controller can reduce the DNS traffic between sidecar proxies and CoreDNS.
Availability#
The DNS controller is available in Aspen Mesh 1.11.8-am3 and later.
How the DNS controller works#
You convert an original, DNS-resolution Istio service entry to an Aspen Mesh DNS static entry, which the DNS controller uses to create a managed, static-resolution Istio service entry. The DNS controller, not each sidecar, queries CoreDNS when necessary and updates the managed, static-resolution Istio service entry with the IP address of the off-mesh service.
Because the managed Istio service entry has a static resolution, all sidecars are provided with the IP address of the off-mesh service when the DNS controller creates or updates the managed Istio service entry. Sidecars don’t need to query CoreDNS to obtain the IP address of the off-mesh service.
Requirements for original Istio service entries#
To be eligible for conversion, original Istio service entries must meet the following requirements:
The value of
.spec.resolutionmust beDNS. Other values are not supported.The list of hosts in
.spec.hostsmust include only one host.The host specified in
.spec.hostsmust not use a wildcard prefix (for example,*.google.com).The
.spec.endpointsfield must not be included.
Start using the DNS controller#
When to follow these instructions#
Follow the instructions below only if you want to start using the DNS controller and only after you’ve installed Aspen Mesh. Perform the tasks in order.
About DNS-controller configuration#
The Helm chart for the DNS controller includes a values.yaml file that contains fields that Helm uses to generate the manifest files during an installation or an upgrade. You can change the default value of a field by doing both of the following:
Include the field in an override values file and specify a different value.
Specify the override values file when installing or upgrading the Helm chart.
Create a DNS-controller override values file#
Change to the Aspen Mesh release directory.
Change to the directory for the DNS-controller chart:
$ cd manifests/charts/dns-controller
Create a DNS-controller override values file by copying the DNS-controller
values.yamlfile:$ cp values.yaml dns-controller-override-values.yaml
Open the DNS-controller override values file in a text editor.
Read the comments for each field and comment out or remove any unrequired fields that you don’t want to override.
Change the values of the remaining fields, if any.
Save and close the file.
Move the DNS-controller override values file to a permanent location.
You’ll need access to this file when installing or upgrading the DNS controller, and you should keep the file under version control.
Install the DNS controller#
Change to the Aspen Mesh release directory.
Install the DNS controller:
$ helm install dns-controller manifests/charts/dns-controller \ --namespace istio-system \ --values dns-controller-override-values.yaml
Convert your Istio service entries to Aspen Mesh DNS static entries#
Follow these steps for each Istio service entry that you want to be managed by the DNS controller and that meets the requirements for original Istio service entries:
Copy the manifest for the Istio service entry (to use as a manifest for an Aspen Mesh DNS static entry, which will replace the Istio service entry).
Open the manifest for the Aspen Mesh DNS static entry.
Change
apiVersionfromnetworking.istio.io/v1beta1(orv1alpha1) tonetworking.aspenmesh.io/v1beta1.Change
kindfromServiceEntrytoDnsStaticEntry.In the
.specsection, changehoststohost, and change the value ofhostfrom a list to a string.Delete the
resolutionandlocationfields.Save the manifest.
Are you running Aspen Mesh 1.11.8-am4 or later?
Yes:
Create the Aspen Mesh DNS static entry:
$ kubectl create -f <dnsStaticEntryManifestFilename>
Delete the original Istio service entry:
$ kubectl delete serviceentry <serviceEntryName>
No:
Important
After you delete an original Istio service entry and until you create the corresponding Aspen Mesh DNS static entry, on-mesh services will be unable to connect to that service entry’s off-mesh service.
Delete the original Istio service entry:
$ kubectl delete serviceentry <serviceEntryName>
Create the Aspen Mesh DNS static entry:
$ kubectl create -f <dnsStaticEntryManifestFilename>
Example manifests#
These are examples of a manifest before and after converting it from an Istio service entry to an Aspen Mesh DNS static entry:
| Istio service entry (before) | Aspen Mesh DNS static entry (after) |
|---|---|
|
|
Upgrade the DNS controller#
Upgrade the DNS controller#
Change to the Aspen Mesh release directory.
Compare the new DNS-controller
values.yamlfile with the old DNS-controllervalues.yamlfile (for the currently installed version):$ diff manifests/charts/dns-controller/values.yaml <oldDnsControllerValuesFilename>
Are there any new fields that are required or that you want to override?
Yes:
Copy those fields to your DNS-controller override values file and change their values.
Go to step 4.
No:
Go to step 4.
Upgrade the DNS controller:
$ helm upgrade dns-controller manifests/charts/dns-controller \ --namespace istio-system \ --values dns-controller-override-values.yaml
Stop using the DNS controller (1.11.8-am4 and later)#
Re-create your original Istio service entries#
Follow this step for each original Istio service entry:
Re-create the original, DNS-resolution Istio service entry:
$ kubectl create -f <originalServiceEntryManifestFilename>
Uninstall the DNS controller#
Uninstall the DNS controller:
$ helm uninstall dns-controller --namespace istio-system
Helm uninstalls the DNS controller and deletes the DNS static entries, which causes Kubernetes to delete the managed, static-resolution Istio service entries.
Stop using the DNS controller (1.11.8-am3)#
Introduction#
In Aspen Mesh 1.11.8-am3, a managed Istio service entry has the same name as its original Istio service entry. Therefore, when you stop using the DNS controller, you must re-create the original Istio service entries only after you uninstall the DNS controller. Otherwise, the DNS controller will delete the re-created original Istio service entries.
Important
After you uninstall the DNS controller and until you re-create an original Istio service entry, on-mesh services will be unable to connect to that service entry’s off-mesh service.
Uninstall the DNS controller#
Uninstall the DNS controller:
$ helm uninstall dns-controller --namespace istio-system
Helm uninstalls the DNS controller and deletes the DNS static entries, which causes Kubernetes to delete the managed, static-resolution Istio service entries.
Re-create your original Istio service entries#
Follow this step for each original Istio service entry:
Re-create the original, DNS-resolution Istio service entry:
$ kubectl create -f <originalServiceEntryManifestFilename>