官术网_书友最值得收藏!

Proxy

Since this is an HTTP-based application, we can also use the kubectl proxy command to get access to the responses from our code:

kubectl proxy

And the output will show something akin to the following:

Starting to serve on 127.0.0.1:8001

As a reminder, you won't get a prompt back in the Terminal window until the proxy terminates. Just as with the Python example, we can determine the URL to use that the proxy will use to forward to our container based on the Pod name and the namespace that we used when invoking the kubectl run command. Since we did not specify a namespace, it used the default, which is called default. The URL pattern for accessing the Pod is the same as the Python example:

http://localhost:8001/api/v1/proxy/namespaces/<NAME_OF_NAMESPACE>/pods/<POD_NAME>/

And in the case of our Pod, this would be:

http://localhost:8001/api/v1/proxy/namespaces/default/pods/nodejs-568183341-2bw5v/

If you open a URL in your browser created with the Pod name that your Kubernetes cluster assigned, it should show you the same output that you saw using the port-forward command.

主站蜘蛛池模板: 内丘县| 绥滨县| 达孜县| 苏州市| 友谊县| 邢台市| 河曲县| 中超| 宝应县| 湖南省| 根河市| 赣榆县| 利辛县| 长海县| 桐城市| 巴彦县| 壶关县| 高雄市| 三原县| 安乡县| 双辽市| 泾川县| 绥阳县| 道孚县| 闽侯县| 交城县| 曲水县| 体育| 高平市| 齐齐哈尔市| 当涂县| 东光县| 内黄县| 明水县| 东源县| 渭源县| 泊头市| 新蔡县| 香港| 乳源| 商丘市|