无法从 k8s pod ping 域

时间:2021-02-27 17:27:51

标签: kubernetes localhost microk8s

我从 https://ubuntu.com/tutorials/install-a-local-kubernetes-with-microk8s#1-overview 在我的笔记本电脑上本地安装了 microk8s,问题是我无法从 pod ping 一个受限制的域,但我可以从 localhost 和 docker 容器使用 --network host

我希望 Pod 继承与我的本地主机 (Bridging) 中相同的网络行为

从本地主机,我得到

$ ping x.y.z
  Réponse de 10.88.255.60 : octets=32 temps=10 ms TTL=61
  Réponse de 10.88.255.60 : octets=32 temps=9 ms TTL=61

来自 Docker 容器

without --network host,出现错误

docker run -it --entrypoint /bin/sh busybox:latest

$ ping x.y.z
  ping: bad address 'x.y.z'

Using --network host,我明白了

docker run -it --network host --entrypoint /bin/sh busybox:latest

$ ping x.y.z
  64 bytes from 10.88.255.60: seq=0 ttl=60 time=15.947 ms
  64 bytes from 10.88.255.60: seq=1 ttl=60 time=10.395 ms

来自 microk8s pod

为了测试我的集群,我启动了一个假容器

kubectl run -i --tty busybox --image=busybox --restart=Never -- sh

吊舱完美启动

kubectl get pods
NAME      READY   STATUS    RESTARTS   AGE
busybox   1/1     Running   0          17m

我有一个错误

# ping x.y.z
  ping: bad address 'x.y.z'

注意: url x.y.z 是假的,因为我无法提供 API 的真实 url(限制访问)。

kubectl 集群信息

 Kubernetes master is running at https://127.0.0.1:16443
 Heapster is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/heapster/proxy
 CoreDNS is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
 Grafana is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
 InfluxDB is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/monitoring-influxdb:http/proxy
 To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

0 个答案:

没有答案