Why kubernetes needs to have 2 coredns pods
Asked Answered
S

2

5

I installed fresh kubernetes single node cluster and I see 2 coredns pods running. One of them is failing (not part of this question)

Why they are 2 of them?

Sulphonamide answered 4/3, 2020 at 9:8 Comment(0)
E
8

Detailed tuning info for CoreDNS's on this link.

CoreDNS memory usage is predominantly affected by the number of Pods and Services in the cluster. Other factors include the size of the filled DNS answer cache, and the rate of queries received (QPS) per CoreDNS instance.

Two Replicas are for high availability (reduce the risk of CoreDNS downtime) and default value at install time.

You can change this by scaling down/up the deployment for coredns on your deployment.

Default

$ kubectl describe deployment.apps -n kube-system coredns
Name:                   coredns
Namespace:              kube-system
CreationTimestamp:      Tue, 03 Mar 2020 09:28:50 +0000
Labels:                 k8s-app=kube-dns
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               k8s-app=kube-dns
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  1 max unavailable, 25% max surge

Scale Down to 1

$ kubectl scale deployments.apps -n kube-system coredns --replicas=1
deployment.apps/coredns scaled

$ kubectl describe deployment.apps -n kube-system coredns
Name:                   coredns
Namespace:              kube-system
CreationTimestamp:      Tue, 03 Mar 2020 09:28:50 +0000
Labels:                 k8s-app=kube-dns
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               k8s-app=kube-dns
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable

Scale Up to 3

$ kubectl scale deployments.apps -n kube-system coredns --replicas=3
deployment.apps/coredns scaled

$ kubectl describe deployment.apps -n kube-system coredns
Name:                   coredns
Namespace:              kube-system
CreationTimestamp:      Tue, 03 Mar 2020 09:28:50 +0000
Labels:                 k8s-app=kube-dns
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               k8s-app=kube-dns
Replicas:               3 desired | 3 updated | 3 total | 2 available | 1 unavailable
Estrellaestrellita answered 4/3, 2020 at 9:59 Comment(2)
you can describe too like this: kubectl describe deploy -n kube-system -l k8s-app=kube-dns /n kubectl describe deploy -n kube-system coredns /n kubectl describe deployment -n kube-system coredns /n kubectl describe deployment.apps -n kube-system coredns /nCryptonym
you can scale like this: kubectl scale deployment -n kube-system coredns --replicas=3Cryptonym
P
1

Two pods exist for resilience.

You can always configure the number of replicas by editing the deployment in kube-system

Pforzheim answered 4/3, 2020 at 9:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.