kube-dns找不到api-server

时间:2018-01-15 13:42:57

标签: kubernetes kube-dns

我正按照Kelsey Hightowers https://github.com/kelseyhightower/kubernetes-the-hard-way/中描述的那样在GKE上设置kubernetes

除了设置DNS ClusterAddon https://github.com/kelseyhightower/kubernetes-the-hard-way/blob/master/docs/12-dns-addon.md

外,一切正常

当我开始这样的kube-dns时:

  

kubectl create -f   https://storage.googleapis.com/kubernetes-the-hard-way/kube-dns.yaml

我确实得到了预期的输出:

 serviceaccount "kube-dns" created 
 configmap "kube-dns" created 
 service "kube-dns" 
 created deployment "kube-dns" created

但是检查pod的状态和kube-dns容器的输出我看到错误:

kubectl get po -n kube-system
NAME                        READY     STATUS             RESTARTS   AGE
kube-dns-6c857864fb-cpvvr   2/3       CrashLoopBackOff   63         2h

并在容器日志中:

I0115 13:22:35.272492       1 dns.go:173] Waiting for services and endpoints to be initialized from apiserver...
I0115 13:22:35.772476       1 dns.go:173] Waiting for services and endpoints to be initialized from apiserver...
I0115 13:22:36.272406       1 dns.go:173] Waiting for services and endpoints to be initialized from apiserver...
I0115 13:22:36.772356       1 dns.go:173] Waiting for services and endpoints to be initialized from apiserver...
I0115 13:22:37.272386       1 dns.go:173] Waiting for services and endpoints to be initialized from apiserver...
E0115 13:22:37.273178       1 reflector.go:201] k8s.io/dns/pkg/dns/dns.go:147: Failed to list *v1.Endpoints: Get https://10.32.0.1:443/api/v1/endpoints?resourceVersion=0: dial tcp 10.32.0.1:443: i/o timeout
E0115 13:22:37.273340       1 reflector.go:201] k8s.io/dns/pkg/dns/dns.go:150: Failed to list *v1.Service: Get https://10.32.0.1:443/api/v1/services?resourceVersion=0: dial tcp 10.32.0.1:443: i/o timeout

容器日志中的网址https://10.32.0.1:443似乎有误,但我找不到任何可以指定其他网址的地方,也没有找到在配置文件https://storage.googleapis.com/kubernetes-the-hard-way/kube-dns.yaml中设置此网址的位置

2 个答案:

答案 0 :(得分:2)

URL来自内部kubernetes信息(服务帐户令牌),它应该没问题(它应该指向分配给服务网络的范围中的第一个IP,这应该是kubernetes.default服务。需要检查的是你的pod-to-pod网络和kube-proxy(它实现服务ClusterIPs)是否按预期工作。

如果您执行kubectl get svc kubernetes -o yaml,您应该会看到具有10.32.0.1 IP的kubernetes服务,因此请确认(apiserver为此svc注册自己的IP,因此ksp get endpoints kubernetes应该为您提供API IP /端口)

答案 1 :(得分:0)

我正在使用kubespray(v2.5.0版)尝试在Openstack上设置kubernetes(1.10.4版)集群,并遇到了完全相同的错误消息。 Google带领我来到这里,但没有为这个问题提供解决方案。

我的最终解决方案是将清单/mycluster/group_vars/kube-cluster.yml中的kube_proxy_mode选项从“ iptables”的默认值更改为“ ipvs”:

# Kube-proxy proxyMode configuration.
# Can be ipvs, iptables
kube_proxy_mode: ipvs

在重新运行ansible playbook命令之后,此问题消失了,所有服务/吊舱均按预期运行。希望对尝试使用相同工具链的人设置kubernetes集群有所帮助。