Lesson 8 DNS Networking CoreDNS and CNI
Lesson 8 DNS Networking CoreDNS and CNI
Kubernetes: Networking
Learning Objectives
Domain Name System (DNS) is used to configure the kubelets and schedule pods and services on
a cluster.
DNS is responsible for configuring the kubelets that let the containers use the DNS service’s IP to
resolve the DNS names.
Kubernetes clusters automatically configure the DNS, hence providing a mechanism for service
discovery. This discovery helps the applications to find and communicate with each other.
DNS: Record Types
When DNS and other options are not applicable, the /etc/hosts file is used to provide pod-level
override of hostname resolution.
Host file is used to prevent docker from modifying the file once the containers are running.
Here is the command that can be used to check the hosts file content:
/etc/resolve/conf is a file that is used to store the local DNS configuration list.
• Use kubectl exec busybox cat /etc/resolv.conf command to look inside the
resolv.conf file
• To verify the search path and name server are set up, use:
search default.svc.cluster.local svc.cluster.local cluster.local google.internal
c.gce_project_id.internal
nameserver 10.0.0.10
options ndots:5
CoreDNS
CoreDNS Installation and Configuration
Problem Statement: You are given a project to demonstrate the installation and
configuration of CoreDNS.
Network Namespace
Creating Network Namespace
Bridge Overlay
Macvlan
CNI
Container Network Interface (CNI): Requirements
Container Network Model (CNM) provides the interfaces that can be used to add or remove
containers from a network.
Given below are the prerequisites for node for cluster networking:
• Pods on a node should be able to communicate with the pods on all the
other nodes without NAT.
Problem Statement: You are given a project to demonstrate the workflow of weaveworks.
IP Address Management: Weave
IPAM Weave Using DHCP or Host-Local
Problem Statement: You are given a project to demonstrate the workflow of IPAM Weave
using DHCP or host-local.
Service Networking
Cluster IP
Problem Statement: You are given a project to demonstrate the workflow of cluster IP.
NodePort
Problem Statement: You are given a project to demonstrate the workflow of NodePort.
DNS in Kubernetes
Name Resolution in SVC in a Single Namespace
Problem Statement: You are given a project to demonstrate the workflow of resolving names
in SVC in a single namespace.
Name Resolution in SVC in Multiple Namespaces
Problem Statement: You are given a project to demonstrate the workflow of resolving names
in SVC in multiple namespaces.
CoreDNS in Kubernetes
CoreDNS Setup
• Satisfies an ingress
It is necessary to have an ingress controller running for the ingress resources to work.
Ingress controllers do not start automatically with a cluster, unlike other controllers.
An Ingress needs apiVersion, kind, and metadata fields with all other Kubernetes resources.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: test-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /testpath
backend:
serviceName: test
servicePort: 80
Ingress Creation with One Rule and Multiple Paths
Problem Statement: You are given a project to create ingress with one rule and multiple
paths.
Key Takeaways
a. Bridge
b. Connector
c. Overlay
d. Macvlan
Knowledge
Check
Which of the following is NOT a network type in docker?
1
a. Bridge
b. Connector
c. Overlay
d. Macvlan
a. A records
b. SRV records
c. ETC records
d. CNM records
Knowledge
Check
Which of the following records refer to the port number and domain name?
2
a. A records
b. SRV records
c. ETC records
d. CNM records
SRV records refer to the port number and the domain name.
Knowledge
Check
Which of the following is NOT a controller?
3
b. Citrix
c. NGINX
d. F8 networks
Knowledge
Check
Which of the following is NOT a controller?
3
b. Citrix
c. NGINX
d. F8 networks
a. /etc/resolve.conf
b. /etc/hosts
c. --cni-bin-dir
d. /etc/resolve/config
Knowledge
Check
_____________ is used to provide pod-level override of hostname resolution.
4
a. /etc/resolve.conf
b. /etc/hosts
c. --cni-bin-dir
d. /etc/resolve/config
c. If multiple configuration files are present, the first one in lexicographic order must
be used
d. All of the above
Knowledge
Check
Which of the following is a prerequisites of CNI?
5
c. If multiple configuration files are present, the first one in lexicographic order must
be used
d. All of the above
The CNI configuration file must match the CNI specifications, the required plugins for configuration must
be present in --cni-bin-dir, and if multiple configuration files are present, the first one in lexicographic
order must be used.
Problem Statement: One of the biggest challenges while developing a
highly scalable application is improving the concurrent user capacity and
the overall reliability of the application. The use of Kubernetes helps
improve these by distributing the workload across multiple servers/DNS,
decreasing the overall burden placed on each server.