Tools, Tips, and Tricks for Cloud Development

Introduction

In this blog, you will find a compilation of tools, tips, and tricks that I have found useful in the development of cloud applications. The information is organized by technology; e.g., DNS, Docker, Kubernetes, etc.

DNS

A Domain Name System (DNS) turns domain names into IP addresses.

DNS Checkers

Useful for tracking whether DNS records are propagated against multiple nameservers located in different parts of the world. To check DNS propagation, select one of the links below:

https://dnschecker.org/

https://www.whatsmydns.net/

Flush the DNS Cache

For Windows, open a Command Prompt and type the command below, then press the <Enter> key:
C:\> ipconfig /flushdns
Unlike Windows, Linux does not cache DNS records by default. But if there is a DNS service installed, you must use the required command based on the service installed. To flush the DNS cache, press the keys Ctrl+Alt+T simultaneously to open a terminal window. If the system is using the Name Service Cache Daemon (nscd), enter the following command in the terminal:
$ sudo /etc/init.d/nscd restart

But if the system is using the systemd service, enter the following command in the terminal:
$ sudo systemd-resolve --flush-caches
To verify the cache was flushed, enter the following command in the terminal:
$ sudo systemd-resolve --statistics
Google Chrome uses a different DNS cache than the Operating System (OS). To flush Chrome's DNS cache, open Chrome and type the following address into the browser's address bar:
chrome://net-internals/#dns

Next, click the Clear host cache button.
Cleaning the DNS cache for Google Chrome

Free Wildcard DNS Services

Whenever you have an IP address but need a domain name, the easiest way to map the IP address to a domain name is to change the hosts file; however, the hosts file is best left untouched. To avoid changing the hosts file, you can leveraged one of the free wildcard DNS services for mapping IP addresses to domain names such as nip.io, sslip.io, FreeDNS, et al. These services are usually relevant in development or testing environment.


Note: The hosts file is used to map domain names (hostnames) to IP addresses. It is a plain-text file used by most operating systems including, Linux and Windows. The hosts file has priority over DNS. When typing in the domain name of a web site to visit, the domain name must be translated into its corresponding IP address. The operating system first checks its hosts file for the corresponding domain, and if there is no entry for the domain, it will query the configured DNS servers to resolve the specified domain name. This affects only the computer on which the change is made, rather than how the domain is resolved worldwide. Entries in the hosts file have the following format:
IPAddress DomainName [DomainAliases]
The IP address and the domain names should be separated by at least one space or tab. The lines starting with # are comments, and they are ignored.

On Linux, the full path to the file is /etc/hosts.
On Windows, the full path to the file is C:\Windows\System32\drivers\etc\hosts.

Kubernetes (K8S)

Discover Pods through DNS

If your container image doesn’t include the nslookup or dig binary, you can perform DNS-related actions by using the tutum/dnsutils container image, which is available on Docker Hub and contains the nslookup and dig binaries. I will be demonstrating commands for one-off pods (--restart=Never), attached to the console (-it), and deleted as soon as it terminates (--rm).

Note: With the dig binary, I am listing the SRV records for the stateful pods. SRV records are used to point to hostnames and ports of servers providing a specific service; Kubernetes creates SRV records to point to the hostnames of the pods backing a headless service. By default, only the pods that are ready to become endpoints of services are returned. If you want to use the service discovery mechanism to find all pods matching the service’s label selector, you must instruct Kubernetes to return all pods added to a service, regardless of the pod’s readiness status, with the field publishNotReadyAddresses set to true.

$ kubectl run -it <pod-name> --image=tutum/dnsutils --rm --restart=Never -- dig SRV <service-name>.<namespace>.svc.cluster.local
$ kubectl run -it <pod-name> --image=tutum/dnsutils --rm --restart=Never -- nslookup <service-name>.<namespace>.svc.cluster.local
# To compare and confirm, run this command.
$ kubectl get pods -o wide -n <namespace>

Conclusion

Although this compilation is by no means exhaustive, I hope that it offers the reader valuable techniques with their time-saving potential. And of course, by necessary, this blog will be continually edited and updated.

Leave a Comment

Your email address will not be published. Required fields are marked *