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
I have this in the 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
...
containers:
- name: nginx
image: nginx:1.18.0
ports:
- containerPort: 80
When showing the services, I can see the external 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. Same with 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 10.111.105.46
How to make the nginx service accept connection on the public ip address?
Is Port 80 open on the host? if not enable it sudo ufw allow 80/tcp.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.