kubernetes / minikube

Run Kubernetes locally
https://minikube.sigs.k8s.io/
Apache License 2.0
29.41k stars 4.88k forks source link

doc: After deploying and exposing a container, how do I view and use my app? #5236

Closed BZM708 closed 4 years ago

BZM708 commented 5 years ago

After deploying and exposing a container/image on to kubernetes, how do I view and use my application when it is on kubernetes?

nascarj commented 5 years ago

With VirtualBox, I exposed the service with NodePort and then had to forward the port from VirtualBox to my host.

BZM708 commented 5 years ago

What commands(syntax) did you use in ubuntu for this?

tstromberg commented 5 years ago

See https://minikube.sigs.k8s.io/docs/examples/

Here is the primary method:

For LoadBalancer services, we also offer this:

Does this help?

BZM708 commented 5 years ago

I used the link from the primary method (https://minikube.sigs.k8s.io/docs/tasks/nodeport) and I got the url for my app service. When I clicked the link, the output from google chrome is:

This site can’t be reached 192.168.99.108 refused to connect. Search Google for 192 168 108 31970 ERR_CONNECTION_REFUSED

How do I fix this issue?

BZM708 commented 5 years ago

By the way, I forgot to mention that the app that I deployed and exposed onto kubernetes has asp.net core. The error from above is a result of this app. How can I fix this error?

tstromberg commented 5 years ago

I can't speak to the particular error, but I am a bit surprised about the ERR_CONNECTION_REFUSED error.

https://kubernetes.io/docs/tutorials/hello-minikube/ has better documents around viewing and using an application. We should probably point there.

BZM708 commented 5 years ago

I used the link (https://kubernetes.io/docs/tutorials/hello-minikube/) and I was able to get it to work. When I tried the same steps with my app (asp.net core), the output on google chrome is this:

site can’t be reached 192.168.99.108 refused to connect. Search Google for 192 168 108 30178 ERR_CONNECTION_REFUSED

medyagh commented 5 years ago

@BZM708 I am curious if this is a proxy settings in your browser.

do you mind trying to see if you can curl the url:port of your service?

for example curl SERVICE_URL and also try with a different browser.

BZM708 commented 5 years ago

When I used curl SERVICE_URL the output is this:

curl: (7) Failed to connect to 192.168.99.108 port 30178: Connection refused

When I tried the address on another browser the output is:

Firefox can’t establish a connection to the server at 192.168.99.108:30178.

medyagh commented 5 years ago

When I used curl SERVICE_URL the output is this:

curl: (7) Failed to connect to 192.168.99.108 port 30178: Connection refused

When I tried the address on another browser the output is:

Firefox can’t establish a connection to the server at 192.168.99.108:30178.

@BZM708 do you mind trying in a different browser ? I had this issue that I couldn't access it in chrome but in firefox or safari and I realized browsers have different settings for proxy.

and do you mind sharing the output of this in a terminal ?

curl -vvv 192.168.99.108:30178

replace 192.168.99.108:30178 with whatever the serivce_url minikube gives you. (mind that it might change each time you start-stop minikube)

BZM708 commented 5 years ago

I inputted the following code in terminal:

< curl -vvv 192.168.99.108:30178 >

output is:

tstromberg commented 5 years ago

I tested the service command with this tutorial today, and got it to work on Linux at least. I suspect you may be running into a firewall or proxy issue.

Do you mind sharing the output of:

minikube service list

minikube service <your service name>

BZM708 commented 5 years ago

Here is the output for minikube service list:

|-----------------|-----------------------|-----------------------------|
|NAMESPACE       NAME          |        URL             |
|-----------------|-----------------------|-----------------------------|
| default                 | hello-node            | http://192.168.99.108:32744 |
| default                 | helo-svc              | http://192.168.99.108:31647 |
| default                  | kubernetes            | No node port                |
| default                   | my-service            | http://192.168.99.108:32734 |
| default                     | my-service2           | http://192.168.99.108:32241 |
| default                      | tesb-node             | http://192.168.99.108:30178 |
| default                     | tesc-node                 | http://192.168.99.108:31107 |
| kube-system     | default-http-backend       | http://192.168.99.108:30001 |
| kube-system     | elasticsearch-logging    | No node port                |
| kube-system     | heapster                       | No node port                |
| kube-system     | kibana-logging              | http://192.168.99.108:30003 |
| kube-system     | kube-dns                       | No node port                |
| kube-system     | kubernetes-dashboard   | No node port                |
| kube-system     | logviewer                        | http://192.168.99.108:32000 |
| kube-system     | metrics-server                 | No node port                |
| kube-system     | monitoring-grafana               | http://192.168.99.108:30002 |
| kube-system     | monitoring-influxdb                 | No node port                |
| kube-system     | registry                            | No node port                |
| storage-gluster | heketi                                  | No node port                |
|-----------------|-----------------------|-----------------------------|

Here is the output for minikube service tesb-node on google chrome:

This site can’t be reached192.168.99.108 refused to connect. Search Google for 192 168 108 30178 ERR_CONNECTION_REFUSED

medyagh commented 4 years ago

Here is the output for minikube service list:

----------------- ----------------------- ----------------------------- NAMESPACE NAME URL
default hello-node http://192.168.99.108:32744
default helo-svc http://192.168.99.108:31647
default kubernetes No node port
default my-service http://192.168.99.108:32734
default my-service2 http://192.168.99.108:32241
default tesb-node http://192.168.99.108:30178
default tesc-node http://192.168.99.108:31107
kube-system default-http-backend http://192.168.99.108:30001
kube-system elasticsearch-logging No node port
kube-system heapster No node port
kube-system kibana-logging http://192.168.99.108:30003
kube-system kube-dns No node port
kube-system kubernetes-dashboard No node port
kube-system logviewer http://192.168.99.108:32000
kube-system metrics-server No node port
kube-system monitoring-grafana http://192.168.99.108:30002
kube-system monitoring-influxdb No node port
kube-system registry No node port
storage-gluster heketi No node port
----------------- ----------------------- -----------------------------

Here is the output for minikube service tesb-node on google chrome:

This site can’t be reached192.168.99.108 refused to connect. Search Google for 192 168 108 30178 ERR_CONNECTION_REFUSED

are you on a corp network ? mostly probably your browser is using a proxy that tries to redirect the local traffic to your proxy.

here are three things you could try:

1- try in terminal curl IP:PORT replace ip:port with your service

2- try a different browser with no proxy settings.

3- se the NO_PROXY env variable to the IP of the service.

BZM708 commented 4 years ago

I am not on a corp network.

1 - that didn't work

2 - the result was the same in firefox

3 - how do you set no proxy to the IP of the service?

priyawadhwa commented 4 years ago

Hey @BZM708 -- docs for setting NO_PROXY can be found here.

BZM708 commented 4 years ago

tesb-node: [ pod ip: 172.17.0.21 ] [ service ip: 10.99.98.201 ] [ port: 84 ] [ service: 192.168.99.108:30178 ]

I typed the following commands in ubuntu terminal:

export HTTP_PROXY=http://192.168.99.108:30178 export HTTPS_PROXY=https://192.168.99.108:30178 export NO_PROXY=localhost,172.17.0.21/84,192.168.99.108/84,10.99.98.201/84

minikube start \ --docker-env=HTTP_PROXY=$HTTP_PROXY \ --docker-env HTTPS_PROXY=$HTTPS_PROXY \ --docker-env NO_PROXY=$NO_PROXY

I then typed:

minikube service tesb-node

The output from google chrome is:

This site can’t be reached192.168.99.108 refused to connect. Search Google for 192 168 108 30178 ERR_CONNECTION_REFUSED

Firefox output is:

Unable to connect Firefox can’t establish a connection to the server at 192.168.99.108:30178. The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer’s network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

What did I miss?

medyagh commented 4 years ago

@BZM708 both of your browsers might be using a proxy, do you mind setting the env vars and then try with curl in terminal ?

curl -vv "SVC_URL"

BZM708 commented 4 years ago

I typed the following commands in terminal:

export HTTP_PROXY=http://192.168.99.108:30178 export HTTPS_PROXY=https://192.168.99.108:30178 export NO_PROXY=localhost,172.17.0.21/84,192.168.99.108/84,10.99.98.201/84

minikube start

curl -vv http://192.168.99.108:30178

The output in the terminal is:

medyagh commented 4 years ago

@BZM708 I am curious, do you use a vpn?

BZM708 commented 4 years ago

I use ubuntu with regular internet connection.

tstromberg commented 4 years ago

We haven't gotten anywhere, so I think for this use case you may be best off with using kubectl:

https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/

Please let me know if it helps.

BZM708 commented 4 years ago

I used the information from the link to try to port forward the app I exposed. And the output in the terminal is:

(port forward deployment) E0405 17:42:28.318087 16440 portforward.go:233] lost connection to pod

(port forward pod) E0405 17:32:08.282323 12977 portforward.go:233] lost connection to pod