- Kubernetes for Developers
- Joseph Heck
- 234字
- 2021-08-27 19:04:15
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.
- 高效能辦公必修課:Word圖文處理
- Practical Ansible 2
- Deep Learning Quick Reference
- Linux Mint System Administrator’s Beginner's Guide
- 基于LPC3250的嵌入式Linux系統(tǒng)開發(fā)
- 21天學通C#
- C語言開發(fā)技術詳解
- 工業(yè)機器人操作與編程
- Implementing AWS:Design,Build,and Manage your Infrastructure
- Containers in OpenStack
- 人工智能技術入門
- 從零開始學Java Web開發(fā)
- Linux常用命令簡明手冊
- Learning iOS 8 for Enterprise
- Keras Reinforcement Learning Projects