Skip to content

Commit a3690b6

Browse files
authored
Fix couple of issues - display issue for pipe char, output for flag --server-print, labels sample, exec extra --, config sample missing newline
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 '<label-key>=<label-value>'. kubectl delete pods,services -l <label-key>=<label-value>" Another way to write it could be: "# Delete all the pods and services that have the label 'name=<label-value>'. kubectl delete pods,services -l name=<label-value>" 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 ~]$
1 parent c211c0a commit a3690b6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

content/en/docs/reference/kubectl/overview.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Operation | Syntax | Description
9191
`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.
9292
`proxy` | `kubectl proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix] [flags]` | Run a proxy to the Kubernetes API server.
9393
`replace` | `kubectl replace -f FILENAME` | Replace a resource from a file or stdin.
94-
`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.
94+
`run` | </code>kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=server&#124;client&#124;none] [--overrides=inline-json] [flags]</code> | Run a specified image on the cluster.
9595
`scale` | <code>kubectl scale (-f FILENAME &#124; TYPE NAME &#124; TYPE/NAME) --replicas=COUNT [--resource-version=version] [--current-replicas=count] [flags]</code> | Update the size of the specified replication controller.
9696
`version` | `kubectl version [--client] [flags]` | Display the Kubernetes version running on the client and server.
9797

@@ -243,8 +243,8 @@ kubectl get pods <pod-name> --server-print=false
243243
Output looks like this:
244244

245245
```shell
246-
NAME READY STATUS RESTARTS AGE
247-
pod-name 1/1 Running 0 1m
246+
NAME AGE
247+
pod-name 1m
248248
```
249249

250250
### Sorting list objects
@@ -339,8 +339,8 @@ the pods running on it, the events generated for the node etc.
339339
# Delete a pod using the type and name specified in the pod.yaml file.
340340
kubectl delete -f pod.yaml
341341

342-
# Delete all the pods and services that have the label name=<label-name>.
343-
kubectl delete pods,services -l name=<label-name>
342+
# Delete all the pods and services that have the label '<label-key>=<label-value>'.
343+
kubectl delete pods,services -l <label-key>=<label-value>
344344

345345
# Delete all pods, including uninitialized ones.
346346
kubectl delete pods --all
@@ -350,13 +350,13 @@ kubectl delete pods --all
350350

351351
```shell
352352
# Get output from running 'date' from pod <pod-name>. By default, output is from the first container.
353-
kubectl exec <pod-name> date
353+
kubectl exec <pod-name> -- date
354354

355355
# Get output from running 'date' in container <container-name> of pod <pod-name>.
356-
kubectl exec <pod-name> -c <container-name> date
356+
kubectl exec <pod-name> -c <container-name> -- date
357357

358358
# Get an interactive TTY and run /bin/bash from pod <pod-name>. By default, output is from the first container.
359-
kubectl exec -ti <pod-name> /bin/bash
359+
kubectl exec -ti <pod-name> -- /bin/bash
360360
```
361361

362362
`kubectl logs` - Print the logs for a container in a pod.
@@ -451,7 +451,7 @@ cat ./kubectl-whoami
451451

452452
# this plugin makes use of the `kubectl config` command in order to output
453453
# information about the current user, based on the currently selected context
454-
kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ .context.user }}{{ end }}{{ end }}'
454+
kubectl config view --template='{{ range .contexts }}{{ if eq .name "'$(kubectl config current-context)'" }}Current user: {{ printf "%s\n" .context.user }}{{ end }}{{ end }}'
455455
```
456456

457457
Running the above plugin gives us an output containing the user for the currently selected

0 commit comments

Comments
 (0)