You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/tasks/access-application-cluster/access-cluster.md
+66-58Lines changed: 66 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ When accessing the Kubernetes API for the first time, we suggest using the
16
16
Kubernetes CLI, `kubectl`.
17
17
18
18
To access a cluster, you need to know the location of the cluster and have credentials
19
-
to access it. Typically, this is automatically set-up when you work through
19
+
to access it. Typically, this is automatically set-up when you work through
20
20
a [Getting started guide](/docs/setup/),
21
21
or someone else set up the cluster and provided you with credentials and a location.
22
22
@@ -36,20 +36,20 @@ Kubectl handles locating and authenticating to the apiserver.
36
36
If you want to directly access the REST API with an http client like
37
37
curl or wget, or a browser, there are several ways to locate and authenticate:
38
38
39
-
- Run kubectl in proxy mode.
40
-
- Recommended approach.
41
-
- Uses stored apiserver location.
42
-
- Verifies identity of apiserver using self-signed cert. No MITM possible.
43
-
- Authenticates to apiserver.
44
-
- In future, may do intelligent client-side load-balancing and failover.
45
-
- Provide the location and credentials directly to the http client.
46
-
- Alternate approach.
47
-
- Works with some types of client code that are confused by using a proxy.
48
-
- Need to import a root cert into your browser to protect against MITM.
39
+
- Run kubectl in proxy mode.
40
+
- Recommended approach.
41
+
- Uses stored apiserver location.
42
+
- Verifies identity of apiserver using self-signed cert. No MITM possible.
43
+
- Authenticates to apiserver.
44
+
- In future, may do intelligent client-side load-balancing and failover.
45
+
- Provide the location and credentials directly to the http client.
46
+
- Alternate approach.
47
+
- Works with some types of client code that are confused by using a proxy.
48
+
- Need to import a root cert into your browser to protect against MITM.
49
49
50
50
### Using kubectl proxy
51
51
52
-
The following command runs kubectl in a mode where it acts as a reverse proxy. It handles
52
+
The following command runs kubectl in a mode where it acts as a reverse proxy. It handles
53
53
locating the apiserver and authenticating.
54
54
Run it like this:
55
55
@@ -83,7 +83,6 @@ The output is similar to this:
83
83
}
84
84
```
85
85
86
-
87
86
### Without kubectl proxy
88
87
89
88
Use `kubectl apply` and `kubectl describe secret...` to create a token for the default service account with grep/cut:
@@ -163,16 +162,16 @@ The output is similar to this:
163
162
}
164
163
```
165
164
166
-
The above examples use the `--insecure` flag. This leaves it subject to MITM
167
-
attacks. When kubectl accesses the cluster it uses a stored root certificate
168
-
and client certificates to access the server. (These are installed in the
169
-
`~/.kube` directory). Since cluster certificates are typically self-signed, it
165
+
The above examples use the `--insecure` flag. This leaves it subject to MITM
166
+
attacks. When kubectl accesses the cluster it uses a stored root certificate
167
+
and client certificates to access the server. (These are installed in the
168
+
`~/.kube` directory). Since cluster certificates are typically self-signed, it
170
169
may take special configuration to get your http client to use root
171
170
certificate.
172
171
173
172
On some clusters, the apiserver does not require authentication; it may serve
174
-
on localhost, or be protected by a firewall. There is not a standard
175
-
for this. [Controlling Access to the API](/docs/concepts/security/controlling-access)
173
+
on localhost, or be protected by a firewall. There is not a standard
174
+
for this. [Controlling Access to the API](/docs/concepts/security/controlling-access)
176
175
describes how a cluster admin can configure this.
177
176
178
177
## Programmatic access to the API
@@ -182,20 +181,30 @@ client libraries.
182
181
183
182
### Go client
184
183
185
-
* To get the library, run the following command: `go get k8s.io/client-go@kubernetes-<kubernetes-version-number>`, see [INSTALL.md](https://github.com/kubernetes/client-go/blob/master/INSTALL.md#for-the-casual-user) for detailed installation instructions. See [https://github.com/kubernetes/client-go](https://github.com/kubernetes/client-go#compatibility-matrix) to see which versions are supported.
186
-
* Write an application atop of the client-go clients. Note that client-go defines its own API objects, so if needed, please import API definitions from client-go rather than from the main repository, e.g., `import "k8s.io/client-go/kubernetes"` is correct.
184
+
* To get the library, run the following command: `go get k8s.io/client-go@kubernetes-<kubernetes-version-number>`,
185
+
see [INSTALL.md](https://github.com/kubernetes/client-go/blob/master/INSTALL.md#for-the-casual-user)
* Write an application atop of the client-go clients. Note that client-go defines its own API objects,
190
+
so if needed, please import API definitions from client-go rather than from the main repository,
191
+
e.g., `import "k8s.io/client-go/kubernetes"` is correct.
187
192
188
193
The Go client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
189
-
as the kubectl CLI does to locate and authenticate to the apiserver. See this [example](https://git.k8s.io/client-go/examples/out-of-cluster-client-configuration/main.go).
194
+
as the kubectl CLI does to locate and authenticate to the apiserver. See this
If the application is deployed as a Pod in the cluster, please refer to the [next section](#accessing-the-api-from-a-pod).
192
198
193
199
### Python client
194
200
195
-
To use [Python client](https://github.com/kubernetes-client/python), run the following command: `pip install kubernetes`. See [Python Client Library page](https://github.com/kubernetes-client/python) for more installation options.
201
+
To use [Python client](https://github.com/kubernetes-client/python), run the following command:
202
+
`pip install kubernetes`. See [Python Client Library page](https://github.com/kubernetes-client/python)
203
+
for more installation options.
196
204
197
205
The Python client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
198
-
as the kubectl CLI does to locate and authenticate to the apiserver. See this [example](https://github.com/kubernetes-client/python/tree/master/examples).
206
+
as the kubectl CLI does to locate and authenticate to the apiserver. See this
0 commit comments