remove command prompts and separate commands from output (#12337)

This commit is contained in:
makocchi
2019-01-24 15:32:09 +09:00
committed by Kubernetes Prow Robot
parent b3ed053c82
commit a254339aa2
@@ -29,7 +29,7 @@ or someone else setup the cluster and provided you with credentials and a locati
Check the location and credentials that kubectl knows about with this command: Check the location and credentials that kubectl knows about with this command:
```shell ```shell
$ kubectl config view kubectl config view
``` ```
Many of the [examples](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/) provide an introduction to using Many of the [examples](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/) provide an introduction to using
@@ -53,7 +53,7 @@ locating the API server and authenticating.
Run it like this: Run it like this:
```shell ```shell
$ kubectl proxy --port=8080 & kubectl proxy --port=8080 &
``` ```
See [kubectl proxy](/docs/reference/generated/kubectl/kubectl-commands/#proxy) for more details. See [kubectl proxy](/docs/reference/generated/kubectl/kubectl-commands/#proxy) for more details.
@@ -61,7 +61,12 @@ See [kubectl proxy](/docs/reference/generated/kubectl/kubectl-commands/#proxy) f
Then you can explore the API with curl, wget, or a browser, like so: Then you can explore the API with curl, wget, or a browser, like so:
```shell ```shell
$ curl http://localhost:8080/api/ curl http://localhost:8080/api/
```
The output is similar to this:
```json
{ {
"versions": [ "versions": [
"v1" "v1"
@@ -82,12 +87,21 @@ directly to the API server, like this:
``` shell ``` shell
# Check all possible clusters, as you .KUBECONFIG may have multiple contexts # Check all possible clusters, as you .KUBECONFIG may have multiple contexts
$ kubectl config view -o jsonpath='{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}' kubectl config view -o jsonpath='{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}'
# Point to the API server refering the cluster name # Point to the API server refering the cluster name
$ APISERVER=$(kubectl config view -o jsonpath='{.clusters[?(@.name=="$CLUSTER_NAME")].cluster.server}') APISERVER=$(kubectl config view -o jsonpath='{.clusters[?(@.name=="$CLUSTER_NAME")].cluster.server}')
# Gets the token value # Gets the token value
$ TOKEN=$(kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='default')].data.token}"|base64 -d) TOKEN=$(kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='default')].data.token}"|base64 -d)
$ curl -X GET $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
# Explore the API with TOKEN
curl -X GET $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
```
The output is similar to this:
```json
{ {
"kind": "APIVersions", "kind": "APIVersions",
"versions": [ "versions": [