I am trying to deploy nginx image from docker hub to kubernetes cluster.
This is the steps I did -
docker pull nginx
kubectl run nginx --image=nginx --port=8080 --image-pull-policy=IfNotPresent
kubectl expose deployment nginx --type=LoadBalancer --port=80 --target-port=8080 --name=nginx
xxx@cloudshell:~ (involuted-ratio-227118)$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.51.240.1 <none> 443/TCP 2d
nginx LoadBalancer 10.51.252.202 34.73.115.78 80:30355/TCP 8m
nginx-http ClusterIP 10.51.254.159 <none> 80/TCP 1d
Below is the error displayed on accessing external endpoint URL -
The following error was encountered while trying to retrieve the URL: http://34.73.115.78/
Connection to 34.73.115.78 failed. The system returned: (111) Connection refused The remote host or network may be down. Please try the request again. Your cache administrator is webmaster.
But I see nginx deployed and also service endpoint showing without any errors in kubernetes-dashboard. I even checked nginx pod logs and this is what is displayed - The selected container has not logged any messages yet.
Any help is appreciated. Thanks
nginx run in port 80
. But you are trying to connect in port 8080
. That's why you are getting error. Try this instead:
kubectl run nginx --image=nginx --port=80 --image-pull-policy=IfNotPresent
kubectl expose deployment nginx --type=LoadBalancer --port=80 --target-port=80 --name=nginx