Main Menu

Search

Showing posts with label coredns. Show all posts
Showing posts with label coredns. Show all posts

KUBERNETES - How To Verify DNS Resolution Is Working and CoreDNS Pods Are Healthy In Kubernetes?

To verify / validate / check DNS resolution is working and coredns pods are healthy in Kubernetes, we can deploy dnsutils pods and run nslookup tests. More information on deploying dnsutils pod and running nslookup tests can be found in below kubernetes.io documentation.

https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/

KUBERNETES - How Does Services in Kubernetes Naming Format Look Like?

In Kubernetes, services are assigned a DNS A record in the format of svc-name.service-namespace.svc.cluster.local. This name resolves to the cluster IP of the Service. 

For e.g. if you have a service named tomcatappsvc in tomcat-ns namespace, the service DNS name format would be tomcatappsvc.tomcat-ns.svc.cluster.local


KUBERNETES: Kubectl Commands To Check CoreDNS (kube-dns) Pods, Services & Logs

KUBERNETES: Kubectl Commands To Check CoreDNS (kube-dns) Pods, Services & Logs


Below are commands to check coredns (kube-dns) pods, services and logs.

 

For listing kube-dns coredns pods, below command can be used.


# kubectl get pods --namespace=kube-system -l k8s-app=kube-dns


For listing the kube-dns service, below command cna be used.

 

# kubectl get svc --namespace=kube-system

 

For checking the logs of kube-dns pods below command can be used.


# kubectl logs --namespace=kube-system -l k8s-app=kube-dns

KUBERNETES: Kubectl Command To View Kube-DNS Service Configuration

Kubectl Command To View Kube-DNS Service Configuration


Below kubectl command can be used to list kube-dns service configuration.


kubectl describe svc -n kube-system kube-dns


Below is sample output.


$ kubectl describe svc -n kube-system kube-dns

Name:              kube-dns

Namespace:         kube-system

Labels:            k8s-app=kube-dns

                   kubernetes.io/cluster-service=true

                   kubernetes.io/name=CoreDNS

Annotations:       prometheus.io/port: 9153

                   prometheus.io/scrape: true

Selector:          k8s-app=kube-dns

Type:              ClusterIP

IP Family Policy:  SingleStack

IP Families:       IPv4

IP:                10.XX.0.10

IPs:               10.XX.0.10

Port:              dns  53/UDP

TargetPort:        53/UDP

Endpoints:         10.244.0.2:53,10.244.0.3:53

Port:              dns-tcp  53/TCP

TargetPort:        53/TCP

Endpoints:         10.244.0.2:53,10.244.0.3:53

Port:              metrics  9153/TCP

TargetPort:        9153/TCP

Endpoints:         10.244.0.2:9153,10.244.0.3:9153

Session Affinity:  None

Events:            <none>

KUBERNETES: Kubectl Commands To Check CoreDNS (kube-dns) DNS Service Logs

KUBERNETES: Kubectl Commands To Check CoreDNS (kube-dns) DNS Service Logs


Below commands can be used.


kubectl logs --namespace=kube-system -l k8s-app=kube-dns


For continuously failing the log below command can be used.


kubectl logs --follow -n kube-system --selector 'k8s-app=kube-dns'

KUBERNETES: KUBECTL Command To Restart CoreDNS

Below command can be used.

kubectl -n kube-system rollout restart deployment coredns

KUBERNETES: KUBECTL Commands To Describe & Edit CoreDNS ConfigMap

 KUBERNETES: KUBECTL Commands To Describe & Edit CoreDNS ConfigMap

For describing coredns configmap, below command can be used.

kubectl describe configmap coredns  -n=kube-system 

For Editing coredns configmap, below command can be used.

kubectl -n kube-system edit configmap coredns

For capturing coredns configmap in YAML file, below command can be used.

kubectl -n kube-system get configmap coredns -o yaml > coredns.yaml

KUBERNETES: KUBECTL Commands To Describe & Edit CoreDNS Deployment

KUBERNETES: KUBECTL Commands To Describe & Edit CoreDNS Deployment

For describing coredns deployment, below command can be used.

kubectl describe deployment coredns -n=kube-system

For Editing coredns deployment, below command can be used.

kubectl edit deployment -n kube-system coredns

For capturing coredns deployment in YAML file, below command can be used.

kubectl get deploy coredns -n kube-system -o yaml > ~/coredns-deployment.yaml

KUBERNETES: How To Capture (gather) CoreDNS Deployment YAML File?

 KUBERNETES: Capture (gather) CoreDNS Deployment YAML File

Below is command to capture (gather) coreDNS deployment yaml file.

kubectl get deploy coredns -n kube-system -o yaml > ~/coredns-deployment.yaml

KUBERNTES: K8S: Kubectl Command To View CoreDNS Pod Configuration - Memory, CPU, IP, State

Below is Kubectl Command To View CoreDNS Pod Configuration - Memory, CPU, IP, State

kubectl describe pod coredns -n kube-system

Below is sample output.
 
 $ kubectl describe pod coredns -n kube-system
Name:                 coredns-f87d5877b-9xwqp
Namespace:            kube-system
Priority:             2000000000
Priority Class Name:  system-cluster-critical
Service Account:      coredns
Node:                 cne1-ha-control1/10.0.1.66
Start Time:           Fri, 13 Oct 2023 04:08:27 +0000
Labels:               k8s-app=kube-dns
                      pod-template-hash=f87d5877b
Annotations:          <none>
Status:               Running
IP:                   10.244.0.2
IPs:
  IP:           10.244.0.2
Controlled By:  ReplicaSet/coredns-f87d5877b
Containers:
  coredns:
    Container ID:  cri-o://1ed580cf5e2cc178a47590954269e6b4eaaf56488a7ea36e78c80de4cc24b7b3
    Image:         container-registry.oracle.com/olcne/coredns:v1.9.3
    Image ID:      container-registry.oracle.com/olcne/coredns@sha256:1736d5ffa6fc5b0b0946411acf0e9059a63b134f95743d8dd874de724fb1d8bb
    Ports:         53/UDP, 53/TCP, 9153/TCP
    Host Ports:    0/UDP, 0/TCP, 0/TCP
    Args:
      -conf
      /etc/coredns/Corefile
    State:          Running
      Started:      Wed, 18 Oct 2023 18:46:40 +0000
    Ready:          True
    Restart Count:  3
    Limits:
      memory:  170Mi
    Requests:
      cpu:        100m
      memory:     70Mi
    Liveness:     http-get http://:8080/health delay=60s timeout=5s period=10s #success=1 #failure=5
    Readiness:    http-get http://:8181/ready delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:  <none>
    Mounts:
      /etc/coredns from config-volume (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-v4rbv (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  config-volume:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      coredns
    Optional:  false
  kube-api-access-v4rbv:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   Burstable
Node-Selectors:              kubernetes.io/os=linux
Tolerations:                 CriticalAddonsOnly op=Exists
                             node-role.kubernetes.io/control-plane:NoSchedule
                             node-role.kubernetes.io/master:NoSchedule
                             node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

Name:                 coredns-f87d5877b-l24w4
Namespace:            kube-system
Priority:             2000000000
Priority Class Name:  system-cluster-critical
Service Account:      coredns
Node:                 cne1-ha-control1/10.0.1.66
Start Time:           Fri, 13 Oct 2023 05:00:01 +0000
Labels:               k8s-app=kube-dns
                      pod-template-hash=f87d5877b
Annotations:          <none>
Status:               Running
IP:                   10.244.0.3
IPs:
  IP:           10.244.0.3
Controlled By:  ReplicaSet/coredns-f87d5877b
Containers:
  coredns:
    Container ID:  cri-o://f14cb9b54cc64963a758bcbc254f96d919fbf2bc4ca4d9a5e2985d63b62ed105
    Image:         container-registry.oracle.com/olcne/coredns:v1.9.3
    Image ID:      container-registry.oracle.com/olcne/coredns@sha256:1736d5ffa6fc5b0b0946411acf0e9059a63b134f95743d8dd874de724fb1d8bb
    Ports:         53/UDP, 53/TCP, 9153/TCP
    Host Ports:    0/UDP, 0/TCP, 0/TCP
    Args:
      -conf
      /etc/coredns/Corefile
    State:          Running
      Started:      Wed, 18 Oct 2023 18:46:41 +0000
    Ready:          True
    Restart Count:  3
    Limits:
      memory:  170Mi
    Requests:
      cpu:        100m
      memory:     70Mi
    Liveness:     http-get http://:8080/health delay=60s timeout=5s period=10s #success=1 #failure=5
    Readiness:    http-get http://:8181/ready delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:  <none>
    Mounts:
      /etc/coredns from config-volume (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-27bhj (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  config-volume:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      coredns
    Optional:  false
  kube-api-access-27bhj:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   Burstable
Node-Selectors:              kubernetes.io/os=linux
Tolerations:                 CriticalAddonsOnly op=Exists
                             node-role.kubernetes.io/control-plane:NoSchedule
                             node-role.kubernetes.io/master:NoSchedule
                             node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>