簡體   English   中英

無法從Kubernetes容器訪問Internet

[英]Unable to access the internet from Kubernetes containers

我正在Mac OSX上使用Vagrant Kubernetes 0.9.3設置。

環境:

  • Kubernetes 0.9.3
  • 流浪漢1.7.2
  • VirtualBox的-4.3.20-96996-OSX

我能夠在單個minion環境中成功部署映像並啟動容器:

奴才-1

我無法從正在運行的容器中訪問Internet。 我可以從minion-1機器上訪問Internet。

我使用Vagrant設置環境

/kubernetes$ export KUBERNETES_PROVIDER=vagrant
/kubernetes$ vagrant up

...(初始化日志和Virtualbox中master + minion-1的成功設置)

SSH到minion-1機器中以確保Internet連接

/kubernetes$ vagrant ssh minion-1
[vagrant@kubernetes-minion-1 ~]$ ping google.com
PING google.com (173.194.123.37) 56(84) bytes of data.
64 bytes from lga15s47-in-f5.1e100.net (173.194.123.37): icmp_seq=1 ttl=63 time=89.3 ms

前者成功連接

在下面您可以看到該容器似乎無法訪問Internet。

[vagrant@kubernetes-minion-1 ~]$ sudo docker run -it --rm ubuntu /bin/bash
Unable to find image 'ubuntu:latest' locally
ubuntu:latest: The image you are pulling has been verified
27d47432a69b: Downloading [=============================================>     ] 180.6 MB/197.2 MB 44s
5f92234dcf1e: Download complete 
51a9c7c1f8bb: Download complete 
5ba9dab47459: Download complete 
511136ea3c5a: Already exists 
27d47432a69b: Pull complete 
5f92234dcf1e: Pull complete 
51a9c7c1f8bb: Pull complete 
5ba9dab47459: Pull complete 

Status: Downloaded newer image for ubuntu:latest

在Ubuntu容器內

root@84914a7e5184:/# ping google.com
ping: unknown host google.com
root@84914a7e5184:/# sudo apt-get update  
Err http://archive.ubuntu.com trusty InRelease

Err http://archive.ubuntu.com trusty-updates InRelease

Err http://archive.ubuntu.com trusty-security InRelease

Err http://archive.ubuntu.com trusty Release.gpg
Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-updates Release.gpg
Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-security Release.gpg
Could not resolve 'archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease  

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease  

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/InRelease  

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Could not resolve 'archive.ubuntu.com'

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg  Could not resolve 'archive.ubuntu.com'

W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg  Could not resolve 'archive.ubuntu.com'

W: Some index files failed to download. They have been ignored, or old ones used instead.
root@84914a7e5184:/# 

這是Vagrant設置的問題還是在Kubernetes框架中故意這樣做? 如果是這樣,訪問互聯網的正確方法是什么?

這不是故意的。 容器應該能夠看到外部互聯網。 我的猜測是您的Vagrant網絡設置存在問題,可能是由於您的主機對來自容器IP的數據包進行了防火牆保護。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM