From a3690b62a2df6c5babd2668b407e1e5cdd37e48c Mon Sep 17 00:00:00 2001 From: sharet-adl <57949742+sharet-adl@users.noreply.github.com> Date: Sat, 9 May 2020 12:54:02 +0300 Subject: [PATCH] Fix couple of issues - display issue for pipe char, output for flag --server-print, labels sample, exec extra --, config sample missing newline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Proposing fixes for some issues in the page: 1. Handle display issue for the 'kubectl run' command, where pipe character ('|') is not properly escaped, so the text gets trimmed. Currently the text is rendered like this: "run `kubectl run NAME --image=image [--env=“key=value”] [--port=port] [--replicas=replicas] [--dry-run=server". The correct text will be displayed like: "kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=server|client|none] [--overrides=inline-json] [flags]". Also, the description column would be displayed properly. 2. Fixing output of 'get pods' command, when flag --server-print is set to false. The only displayed columns would be NAME and AGE. 3. Fixing description and sample command for delete pods (kubectl delete pods,service ..), where 'label-name' text is ambiguously used as the label's value. Labels are key-value pairs. Suggested way of writting it: "# Delete all the pods and services that have the label '='. kubectl delete pods,services -l =" Another way to write it could be: "# Delete all the pods and services that have the label 'name='. kubectl delete pods,services -l name=" 4. Updating the syntax for three 'kubectl exec' commands, to include the '--' before the user's command, to be inline with current way of working and to avoid deprecation message. 5. Enhance sample for 'kubectl config' command, where the newline was not handled properly. Before: [user@wstation ~]$ kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ .context.user }}{{ end }}{{ end }}' Current user: kubernetes-admin[user@wstation ~]$ After: [user@wstation ~]$ kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}' Current user: kubernetes-admin [user@wstation ~]$ --- content/en/docs/reference/kubectl/overview.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/content/en/docs/reference/kubectl/overview.md b/content/en/docs/reference/kubectl/overview.md index 1bb82cf962..bde36b3bf5 100644 --- a/content/en/docs/reference/kubectl/overview.md +++ b/content/en/docs/reference/kubectl/overview.md @@ -91,7 +91,7 @@ Operation | Syntax | Description `port-forward` | `kubectl port-forward POD [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N] [flags]` | Forward one or more local ports to a pod. `proxy` | `kubectl proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix] [flags]` | Run a proxy to the Kubernetes API server. `replace` | `kubectl replace -f FILENAME` | Replace a resource from a file or stdin. -`run` | `kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=server|client|none] [--overrides=inline-json] [flags]` | Run a specified image on the cluster. +`run` | kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=server|client|none] [--overrides=inline-json] [flags] | Run a specified image on the cluster. `scale` | kubectl scale (-f FILENAME | TYPE NAME | TYPE/NAME) --replicas=COUNT [--resource-version=version] [--current-replicas=count] [flags] | Update the size of the specified replication controller. `version` | `kubectl version [--client] [flags]` | Display the Kubernetes version running on the client and server. @@ -243,8 +243,8 @@ kubectl get pods --server-print=false Output looks like this: ```shell -NAME READY STATUS RESTARTS AGE -pod-name 1/1 Running 0 1m +NAME AGE +pod-name 1m ``` ### Sorting list objects @@ -339,8 +339,8 @@ the pods running on it, the events generated for the node etc. # Delete a pod using the type and name specified in the pod.yaml file. kubectl delete -f pod.yaml -# Delete all the pods and services that have the label name=. -kubectl delete pods,services -l name= +# Delete all the pods and services that have the label '='. +kubectl delete pods,services -l = # Delete all pods, including uninitialized ones. kubectl delete pods --all @@ -350,13 +350,13 @@ kubectl delete pods --all ```shell # Get output from running 'date' from pod . By default, output is from the first container. -kubectl exec date +kubectl exec -- date # Get output from running 'date' in container of pod . -kubectl exec -c date +kubectl exec -c -- date # Get an interactive TTY and run /bin/bash from pod . By default, output is from the first container. -kubectl exec -ti /bin/bash +kubectl exec -ti -- /bin/bash ``` `kubectl logs` - Print the logs for a container in a pod. @@ -451,7 +451,7 @@ cat ./kubectl-whoami # this plugin makes use of the `kubectl config` command in order to output # information about the current user, based on the currently selected context -kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ .context.user }}{{ end }}{{ end }}' +kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}' ``` Running the above plugin gives us an output containing the user for the currently selected