为什么 kubernetes 需要有 2 个 coredns pods
Why kubernetes needs to have 2 coredns pods
我安装了新的 kubernetes 单节点集群,我看到 2 个 coredns pods 运行。其中一个失败了(不是这个问题的一部分)
为什么是2个?
两个 pods 存在弹性。
您始终可以通过在 kube-system
中编辑部署来配置副本数
有关 CoreDNS 的详细调整信息 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.
两个副本用于高可用性(降低 CoreDNS 停机的风险)和安装时的默认值。
您可以通过扩展 down/up 部署中的 coredns 部署来更改此设置。
默认
$ 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
缩小到 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
放大到 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
我安装了新的 kubernetes 单节点集群,我看到 2 个 coredns pods 运行。其中一个失败了(不是这个问题的一部分)
为什么是2个?
两个 pods 存在弹性。
您始终可以通过在 kube-system
有关 CoreDNS 的详细调整信息 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.
两个副本用于高可用性(降低 CoreDNS 停机的风险)和安装时的默认值。
您可以通过扩展 down/up 部署中的 coredns 部署来更改此设置。
默认
$ 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
缩小到 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
放大到 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