2

我正在 GKE 上设置 kubernetes,如 Kelsey Hightowers https://github.com/kelseyhightower/kubernetes-the-hard-way/中所述

一切正常,除了设置 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

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

4

2 回答 2

2

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

如果你这样做kubectl get svc kubernetes -o yaml了,你应该看到一个具有该10.32.0.1IP 的 kubernetes 服务,所以也要确认(apiserver 为这个 svc 注册它自己的 IP,所以这样做ksp get endpoints kubernetes应该给你 API IP/PORT)

于 2018-01-15T13:55:33.520 回答
0

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

我的最终解决方案是将inventory/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 命令,这个问题就消失了,所有服务/pod 都按预期运行。希望对尝试使用相同工具链设置 kubernetes 集群的人有所帮助。

于 2018-07-09T15:30:50.593 回答