Identifying the Cluster DNS Solution
Begin by setting an alias for kubectl:Counting the DNS Server Pods
To determine the number of DNS server pods deployed, run:Discovering the DNS Service
Identify the service used to access CoreDNS by listing services in the kube-system namespace:Configuring CoreDNS and the Corefile
File Location and Mounting
The CoreDNS container is initiated with an argument that points to its configuration file located at:Name of the ConfigMap
Inspect the volume configuration to see how the Corefile is provided:Note that the ConfigMap names in the outputs differ slightly. Despite this inconsistency, both refer to the ConfigMap used for CoreDNS configuration.
Configured Root Domain
The Corefile provided by the ConfigMap includes the DNS configuration block for Kubernetes:Exploring Pod and Service Connectivity
Multiple applications have been deployed in various namespaces. In the default namespace, you have pods like HR, simple-webapp, and test. In the payroll namespace, a pod named web is running. Verify their statuses:In the Default Namespace
In the Payroll Namespace
Accessing the HR Web Server
Inspect the services in the default namespace to determine how the test pod can reach the HR web server:name=hr:
Accessing the Payroll Service
For services deployed in a non-default namespace, you must use the fully qualified domain name that includes the namespace. In the payroll namespace, the web service is defined as:Deploying a Web App That Connects to a MySQL Database
A web application is deployed that accesses a MySQL database. Inspect the current deployment:kubectl describe deploy webapp), you’ll notice the container’s environment variables:
- DB_Host: mysql
- DB_User: root
- DB_Password: paswrd
If the MySQL service is running in the payroll namespace, using just “mysql” as the hostname will not resolve from a pod in the default namespace. Use the fully qualified domain name instead.
Verifying DNS Resolution with nslookup
From the HR pod, verify DNS resolution using nslookup.Checking an Incorrect Hostname
First, run nslookup for the incorrect hostname:Checking the Correct Hostname
Run nslookup for the fully qualified hostname:That concludes this lab. By following these steps, you have verified CoreDNS settings, confirmed service connectivity across namespaces, and ensured proper service name resolution so that your web application can connect to its MySQL database. Thank you for following along.