首页 > 解决方案 > coredns 容器仅在一个主服务器上运行

问题描述

我已经设置了具有 3 个主节点的 Kubernetes HA 集群。版本 1.14.2。观察到 2 个 coredns 容器仅在一个 master 上运行。如果我停止这个 Master,coredns 就会停止。是否有任何配置可以将其生成给剩余的主人?

我怎样才能将 coredns 容器生成给剩余的主人。

标签: kubernetes

解决方案


您需要部署 dns 自动缩放器。然后调整自动缩放参数。点击链接 https://kubernetes.io/docs/tasks/administer-cluster/dns-horizo​​ntal-autoscaling/

按照步骤

kubectl apply -f https://raw.githubusercontent.com/epasham/docker-repo/master/k8s/dns-horizontal-autoscaler.yaml

kubectl get deployment --namespace=kube-system

kubectl edit configmap dns-autoscaler --namespace=kube-system

Look for this line:
linear: '{"coresPerReplica":256,"min":1,"nodesPerReplica":16}'

updae min value to 2 as shown below
kubectl edit configmap dns-autoscaler --namespace=kube-system
linear: '{"coresPerReplica":256,"min":2,"nodesPerReplica":16}'

you should get two coredns pods listed as below

master $ kubectl get po --namespace=kube-system|grep dns
coredns-78fcdf6894-l54db          1/1       Running   0          1h
coredns-78fcdf6894-vbk6q          1/1       Running   0          1h
dns-autoscaler-6f888f5957-fwpgl   1/1       Running   0          2m

推荐阅读