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

Proxy

The other command you can use to access your Pod is the kubectl proxy command. The proxy provides access not only to your Pod, but to all of the Kubernetes APIs as well. To invoke the proxy, run the following command:

kubectl proxy

And the output will show something akin to the following:

Starting to serve on 127.0.0.1:8001

Like the port-forward command, you won't get a prompt back in the Terminal window until the proxy terminates. While it is active, you can access Kubernetes REST API endpoints through this proxy. Open a browser and enter the URL http://localhost:8001/.

You should see a long list of URLs in JSON format, something akin to the following:

{
"paths": [
"/api",
"/api/v1",
"/apis",
"/apis/",
"/apis/admissionregistration.k8s.io",
"/apis/admissionregistration.k8s.io/v1alpha1",
"/apis/apiextensions.k8s.io",
"/apis/apiextensions.k8s.io/v1beta1",
"/apis/apiregistration.k8s.io",

These are accessing the Kubernetes infrastructure directly. One of those URL's is /api/v1 - and although it wasn't listed specifically, it uses the Kubernetes API server to provide a proxy to Pods based on the name. When we invoked our run command, we didn't specify a namespace, so it used the default, which is called default. The URL pattern to see a Pod is:

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/flask-1599974757-b68pw/

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.

主站蜘蛛池模板: 东辽县| 河东区| 桑植县| 万源市| 天祝| 金阳县| 原平市| 来凤县| 祁连县| 皋兰县| 彰武县| 繁峙县| 曲麻莱县| 林芝县| 天峻县| 兴业县| 盐津县| 罗平县| 金阳县| 深州市| 靖边县| 黄梅县| 榆树市| 咸阳市| 克山县| 永靖县| 福鼎市| 子洲县| 东安县| 顺义区| 都匀市| 南木林县| 泗洪县| 乐昌市| 尼勒克县| 怀远县| 延安市| 溧阳市| 宜阳县| 广东省| 商丘市|