-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kubectl frequently used commands
- Loading branch information
1 parent
d306bd2
commit 77c5c1f
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Tips for working with kubernetes | ||
|
||
## Show all pods in all namespaces | ||
|
||
```shell | ||
kubectl get pods --all-namespaces | ||
``` | ||
|
||
(you can use `-A` instead of `--all-namespaces`) | ||
|
||
## Show resource usage of all pods in all namespaces | ||
|
||
```shell | ||
kubectl top pods --all-namespaces --sum=true | ||
``` | ||
|
||
If you want to see resource usage with container granularity, add `--containers=true`: | ||
|
||
```shell | ||
kubectl top pods --all-namespaces --containers=true | ||
``` | ||
|
||
## Show resource usage of all nodes | ||
|
||
```shell | ||
$ kubectl top nodes | ||
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY% | ||
pp-hetzner01 4250m 35% 53130Mi 82% | ||
``` | ||
|
||
## Show resource limits and requests for all pods in all namespaces | ||
|
||
```shell | ||
kubectl get pods -o "custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,MEMORY_REQUESTS:.spec.containers[*].resources.requests.memory,MEMORY_LIMITS:.spec.containers[*].resources.limits.memory,CPU_REQUESTS:.spec.containers[*].resources.requests.cpu,CPU_LIMITS:.spec.containers[*].resources.limits.cpu" -A | sort | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters