我正在尝试设置Kubernetes集群,但我无法运行CoreDNS.我运行了以下命令来启动集群:
sudo swapoff -a sudo sysctl net.bridge.bridge-nf-call-iptables=1 sudo kubeadm init mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config kubectl apply -f "https://cloud.weave.works/k8s/net?k8s- version=$(kubectl version | base64 | tr -d '\n')" kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
为了检查POD kubectl get pods --all-namespaces
,我明白了
NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-68fb79bcf6-6s5bp 0/1 CrashLoopBackOff 6 10m kube-system coredns-68fb79bcf6-hckxq 0/1 CrashLoopBackOff 6 10m kube-system etcd-myserver 1/1 Running 0 79m kube-system kube-apiserver-myserver 1/1 Running 0 79m kube-system kube-controller-manager-myserver 1/1 Running 0 79m kube-system kube-proxy-9ls64 1/1 Running 0 80m kube-system kube-scheduler-myserver 1/1 Running 0 79m kube-system kubernetes-dashboard-77fd78f978-tqt8m 1/1 Running 0 80m kube-system weave-net-zmhwg 2/2 Running 0 80m
所以CoreDNS不断崩溃.我能找到的唯一错误消息来自
/var/log/syslog
:
Oct 4 18:06:44 myserver kubelet[16397]: E1004 18:06:44.961409 16397 pod_workers.go:186] Error syncing pod c456a48b-c7c3-11e8-bf23-02426706c77f ("coredns-68fb79bcf6-6s5bp_kube-system(c456a48b-c7c3-11e8-bf23-02426706c77f)"), skipping: failed to "StartContainer" for "coredns" with CrashLoopBackOff: "Back-off 5m0s restarting failed container=coredns pod=coredns-68fb79bcf6-6s5bp_kube-system(c456a48b-c7c3-11e8-bf23-02426706c77f)"
来自kubectl logs coredns-68fb79bcf6-6s5bp -n kube-system
:
.:53 2018/10/04 11:04:55 [INFO] CoreDNS-1.2.2 2018/10/04 11:04:55 [INFO] linux/amd64, go1.11, eb51e8b CoreDNS-1.2.2 linux/amd64, go1.11, eb51e8b 2018/10/04 11:04:55 [INFO] plugin/reload: Running configuration MD5 = f65c4821c8a9b7b5eb30fa4fbc167769 2018/10/04 11:04:55 [FATAL] plugin/loop: Seen "HINFO IN 3256902131464476443.1309143030470211725." more than twice, loop detected
我发现的一些解决方案是要发布的
kubectl -n kube-system get deployment coredns -o yaml | \ sed 's/allowPrivilegeEscalation: false/allowPrivilegeEscalation: true/g' | \ kubectl apply -f -
并修改/etc/resolv.conf
为指向实际的DNS,而不是localhost,我也尝试过.
该问题在https://kubernetes.io/docs/setup/independent/troubleshooting-kubeadm/#pods-in-runcontainererror-crashloopbackoff-or-error-state中进行了描述,我尝试了许多不同的Pod网络,但没有任何帮助.
我跑sudo kubeadm reset && rm -rf ~/.kube/ && sudo kubeadm init
了好几次.
我正在运行Ubuntu 16.04,Kubernetes 1.12和Docker 17.03.有任何想法吗?
我也有同样的问题.
我会通过删除cmred cm内的插件'loop'来解决问题.但我不知道这个云案例是否还有其他问题.
1,kubectl编辑cm coredns -n kube-system
2,删除'循环',保存并退出
3,重启coredns pods:"kubctel delete pod coredns .... -n kube-system"
使用这种方式可以解决一些问题:
打开并编辑coredns的配置图。
kubectl edit cm coredns -n kube-system
“将代理。/etc/resolv.conf替换为上游DNS的IP地址,例如代理8.8.8.8。” 根据coredns日志输出中的链接(在页面末尾)
保存并退出。
kubectl get pods -n kube-system -oname | grep coredns | xargs kubectl delete -n kube-system
在链接中说明了问题的原因。您可以在此cmd的输出中找到此链接
kubectl日志coredns-7d9cd4f75b-cpwxp -n kube-system
此链接在CoreDNS-1.2.4的输出中。
我使用此cmd升级CoreDNS
kubectl补丁程序部署-n = kube-system coredns -p'{“ spec”:{“ template”:{“ spec”:{“ containers”:[{“ image”:“ k8s.gcr.io/coredns:1.2。 4“,” name“:” coredns“,” resources“:{” limits“:{” memory“:” 1Gi“},” requests“:{” cpu“:” 100m“,” memory“:” 70Mi“ }}}]}}}}'