Remove command prompts and split command outputs (#13015)

* Remove command prompts

* Add comments before commands
This commit is contained in:
makocchi
2019-03-16 01:16:58 +09:00
committed by Kubernetes Prow Robot
parent 8d0a6745cb
commit fcbb89a2af
@@ -26,7 +26,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](/docs/user-guide/kubectl-cheatsheet) provide an introduction to using Many of the [examples](/docs/user-guide/kubectl-cheatsheet) provide an introduction to using
@@ -56,7 +56,7 @@ locating the apiserver 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.
@@ -65,7 +65,12 @@ Then you can explore the API with curl, wget, or a browser, replacing localhost
with [::1] for IPv6, like so: with [::1] for IPv6, 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"
@@ -76,16 +81,19 @@ $ curl http://localhost:8080/api/
### Without kubectl proxy ### Without kubectl proxy
Use `kubectl describe secret...` to get the token for the default service account: Use `kubectl describe secret...` to get the token for the default service account with grep/cut:
Use `kubectl describe secret` with grep/cut:
```shell ```shell
$ APISERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ") APISERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ")
$ SECRET_NAME=$(kubectl get secrets | grep ^default | cut -f1 -d ' ') SECRET_NAME=$(kubectl get secrets | grep ^default | cut -f1 -d ' ')
$ TOKEN=$(kubectl describe secret $SECRET_NAME | grep -E '^token' | cut -f2 -d':' | tr -d " ") TOKEN=$(kubectl describe secret $SECRET_NAME | grep -E '^token' | cut -f2 -d':' | tr -d " ")
$ curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
```
The output is similar to this:
```json
{ {
"kind": "APIVersions", "kind": "APIVersions",
"versions": [ "versions": [
@@ -103,11 +111,16 @@ $ curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
Using `jsonpath`: Using `jsonpath`:
```shell ```shell
$ APISERVER=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}') APISERVER=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')
$ SECRET_NAME=$(kubectl get serviceaccount default -o jsonpath='{.secrets[0].name}') SECRET_NAME=$(kubectl get serviceaccount default -o jsonpath='{.secrets[0].name}')
$ TOKEN=$(kubectl get secret $SECRET_NAME -o jsonpath='{.data.token}' | base64 --decode) TOKEN=$(kubectl get secret $SECRET_NAME -o jsonpath='{.data.token}' | base64 --decode)
$ curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
```
The output is similar to this:
```json
{ {
"kind": "APIVersions", "kind": "APIVersions",
"versions": [ "versions": [
@@ -239,8 +252,12 @@ Typically, there are several services which are started on a cluster by kube-sys
with the `kubectl cluster-info` command: with the `kubectl cluster-info` command:
```shell ```shell
$ kubectl cluster-info kubectl cluster-info
```
The output is similar to this:
```
Kubernetes master is running at https://104.197.5.247 Kubernetes master is running at https://104.197.5.247
elasticsearch-logging is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy elasticsearch-logging is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/elasticsearch-logging/proxy
kibana-logging is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/kibana-logging/proxy kibana-logging is running at https://104.197.5.247/api/v1/namespaces/kube-system/services/kibana-logging/proxy