我创建了一个本地ubuntu Kubernetes集群,其中有1个主节点和2个从属节点。
我在2个Pod中部署了2个应用程序,并为两个Pod创建了服务,一切正常。 我通过输入以下命令进入pod内部,
$ kubectl exec -it firstpod /bin/bash
# apt-get update
无法进行更新,但出现错误:
Err http://security.debian.org jessie/updates InRelease
Err http://deb.debian.org jessie InRelease
Err http://deb.debian.org jessie-updates InRelease
Err http://security.debian.org jessie/updates Release.gpg Temporary failure resolving 'security.debian.org' Err http://deb.debian.org jessie-backports InRelease
Err http://deb.debian.org jessie Release.gpg Temporary failure resolving 'deb.debian.org' Err http://deb.debian.org jessie-updates Release.gpg Temporary failure resolving 'deb.debian.org' Err http://deb.debian.org jessie-backports Release.gpg Temporary failure resolving 'deb.debian.org' Reading package lists... Done W: Failed to fetch http://deb.debian.org/debian/dists/jessie/InRelease
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/InRelease
W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-backports/InRelease
W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/jessie/Release.gpg Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/Release.gpg Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/jessie-backports/Release.gpg Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
我正在尝试ping我的第二个pod服务:
# ping secondservice (This is the service name of secondpod)
PING secondservice.default.svc.cluster.local (10.100.190.196): 56 data bytes
unable to ping.
如何从第一个节点ping /呼叫第二个服务?
答案 0 :(得分:1)
我在那里看到两个(不相关的)问题。我将专注于第二个,因为第二个我不清楚(要问什么?)。
因此,您想知道为什么以下方法不起作用:
# ping secondservice
这不是错误或意外(实际上,我是here写过它的)。简而言之:FQDN secondservice.default.svc.cluster.local
通过DNS插件解析为虚拟IP(VIP),此VIP的本质是它是虚拟的,即它没有连接到网络接口,这只是一堆iptables规则。因此,基于ICMP的ping并不是可以解决的问题,因为它不是“真正的” IP。不过,您可以curl
服务。假设服务在端口9876上运行,则以下各项应能工作:
# curl secondservice:9876