[英]Kubernetes Nginx port 80 not available on public ip address (only private address)
I am following the tutorial here: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-php-application-with-kubernetes-on-ubuntu-18-04#conclusion我在这里学习教程: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-php-application-with-kubernetes-on-ubuntu-18-04#conclusion
I have this in the nginx_service.yaml我在 nginx_service.yaml 中有这个
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
tier: backend
spec:
selector:
app: nginx
tier: backend
ports:
- protocol: TCP
port: 80
externalIPs:
- 51.159.171.84
And this in the nginx_deployment.yaml这在 nginx_deployment.yaml
...
containers:
- name: nginx
image: nginx:1.18.0
ports:
- containerPort: 80
When showing the services, I can see the external ip:在显示服务时,我可以看到外部 ip:
kubectl get services -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d2h <none>
nginx ClusterIP 10.111.105.46 51.159.171.84 80/TCP 2d app=nginx,tier=backend
php ClusterIP 10.108.10.193 <none> 9000/TCP 2d1h app=php,tier=backend
However, from the browser: http://51.159.171.84 shows connection refused.但是,从浏览器: http://51.159.171.84显示连接被拒绝。 Same with curl:
与 curl 相同:
curl http://51.159.171.84
curl: (7) Failed to connect to 51.159.171.84 port 80: Connection refused
but by using curl and private IP, it works:但是通过使用 curl 和私有 IP,它可以工作:
curl 10.111.105.46
How to make the nginx service accept connection on the public ip address?如何使 nginx 服务接受公共 ip 地址上的连接?
Is Port 80 open on the host?主机上的 80 端口是否打开? if not enable it sudo ufw allow 80/tcp.
如果没有启用它 sudo ufw allow 80/tcp。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.