我目前正在学习docker和kubernetes。我遇到的问题之一就是将Nginx Pod暴露在公共互联网上。我想从Web浏览器访问我的serverIP并看到nginx页面,就像在服务器上安装了nginx一样。
来自kubernetes网站的pod-nginx.yml
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
Run Code Online (Sandbox Code Playgroud)
我可以从pod向前移植,然后通过curl访问默认的nginx页面。
sudo kubectl port-forward nginx 80:80
curl http://localhost返回nginx页面,而curl http://<serverIP>返回failed to connect <serverIP> port:80 Connection refused
我是否需要通过修改iptables和防火墙规则在公共网络接口与群集网络接口之间进行端口转发?我觉得像即时通讯失去了一些东西真的很明显这里。
我尝试使用nodeport属性,并阅读了有关入口和负载平衡器的文档,但是我的云提供程序没有后端功能,因此这些命令最终会无限期地挂起。