@@ -24,10 +24,10 @@ This page shows how to use an HTTP proxy to access the Kubernetes API.
24
24
* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
25
25
26
26
<!--
27
- * If you do not already have an application running in your cluster, start
27
+ If you do not already have an application running in your cluster, start
28
28
a Hello world application by entering this command:
29
29
-->
30
- * 如果你的集群中还没有任何应用,使用如下命令启动一个 Hello World 应用:
30
+ 如果你的集群中还没有任何应用,使用如下命令启动一个 Hello World 应用:
31
31
32
32
``` shell
33
33
kubectl create deployment node-hello --image=gcr.io/google-samples/node-hello:1.0 --port=8080
@@ -47,7 +47,9 @@ This command starts a proxy to the Kubernetes API server:
47
47
-->
48
48
使用如下命令启动 Kubernetes API 服务器的代理:
49
49
50
- kubectl proxy --port=8080
50
+ ``` shell
51
+ kubectl proxy --port=8080
52
+ ```
51
53
52
54
<!--
53
55
## Exploring the Kubernetes API
@@ -62,60 +64,70 @@ or a browser.
62
64
63
65
<!--
64
66
Get the API versions:
65
- -->
67
+ -->
66
68
获取 API 版本:
67
69
68
- curl http://localhost:8080/api/
70
+ ``` shell
71
+ curl http://localhost:8080/api/
72
+ ```
69
73
70
74
<!--
71
75
The output should look similar to this:
72
76
-->
73
-
74
77
输出应该类似这样:
75
78
79
+ ```
80
+ {
81
+ "kind": "APIVersions",
82
+ "versions": [
83
+ "v1"
84
+ ],
85
+ "serverAddressByClientCIDRs": [
76
86
{
77
- "kind": "APIVersions",
78
- "versions": [
79
- "v1"
80
- ],
81
- "serverAddressByClientCIDRs": [
82
- {
83
- "clientCIDR": "0.0.0.0/0",
84
- "serverAddress": "10.0.2.15:8443"
85
- }
86
- ]
87
+ "clientCIDR": "0.0.0.0/0",
88
+ "serverAddress": "10.0.2.15:8443"
87
89
}
90
+ ]
91
+ }
92
+ ```
88
93
89
94
<!--
90
95
Get a list of pods:
91
96
-->
92
97
获取 Pod 列表:
93
98
94
- curl http://localhost:8080/api/v1/namespaces/default/pods
99
+ ``` shell
100
+ curl http://localhost:8080/api/v1/namespaces/default/pods
101
+ ```
95
102
103
+ <!--
104
+ The output should look similar to this:
105
+ -->
106
+ 输出应该类似这样:
107
+
108
+ ```
109
+ {
110
+ "kind": "PodList",
111
+ "apiVersion": "v1",
112
+ "metadata": {
113
+ "resourceVersion": "33074"
114
+ },
115
+ "items": [
96
116
{
97
- "kind": "PodList",
98
- "apiVersion": "v1",
99
117
"metadata": {
100
- "resourceVersion": "33074"
101
- },
102
- "items": [
103
- {
104
- "metadata": {
105
- "name": "kubernetes-bootcamp-2321272333-ix8pt",
106
- "generateName": "kubernetes-bootcamp-2321272333-",
107
- "namespace": "default",
108
- "uid": "ba21457c-6b1d-11e6-85f7-1ef9f1dab92b",
109
- "resourceVersion": "33003",
110
- "creationTimestamp": "2016-08-25T23:43:30Z",
111
- "labels": {
112
- "pod-template-hash": "2321272333",
113
- "run": "kubernetes-bootcamp"
114
- },
115
- ...
116
- }
117
-
118
-
118
+ "name": "kubernetes-bootcamp-2321272333-ix8pt",
119
+ "generateName": "kubernetes-bootcamp-2321272333-",
120
+ "namespace": "default",
121
+ "uid": "ba21457c-6b1d-11e6-85f7-1ef9f1dab92b",
122
+ "resourceVersion": "33003",
123
+ "creationTimestamp": "2016-08-25T23:43:30Z",
124
+ "labels": {
125
+ "pod-template-hash": "2321272333",
126
+ "run": "kubernetes-bootcamp"
127
+ },
128
+ ...
129
+ }
130
+ ```
119
131
120
132
## {{% heading "whatsnext" %}}
121
133
0 commit comments