Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kadasz/kubectl-handy-cmd
My kubectl cheat sheet
https://github.com/kadasz/kubectl-handy-cmd
Last synced: 5 days ago
JSON representation
My kubectl cheat sheet
- Host: GitHub
- URL: https://github.com/kadasz/kubectl-handy-cmd
- Owner: kadasz
- Created: 2024-01-02T12:13:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-14T08:12:14.000Z (11 months ago)
- Last Synced: 2024-11-09T07:16:19.744Z (2 months ago)
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# My kubectl cheat sheet
List of kubectl commands which I've found useful for on a daily basis because may come in handy for sure.
### To get IP addresses of pods
```
kubectl get pods -o custom-columns=IP:.status.podIP
```### To get Name and Images of pods
```
kubectl get pods -o custom-columns=Name:.metadata.name,Image:..spec.containers[*].image
```### To get Name and Worker IP of pods
```
kubectl get pods -o custom-columns=Name:.metadata.name,WorkerIP:.status.hostIP
```### To get a list of all pods without pods from openshift-* namespaces
```
kubectl get pods -A --field-selector=metadata.namespace!=openshift-* -o wide
```### Rolling updates and Rollbacks
```
kubectl create -f app-deployment.yml
kubectl get deployments
kubectl apply -f app-deployment.yml
kubectl set image deployment/app-deployment nginx=nginx:1.25.1
kubectl rollout status deployment/app-deployment
kubectl rollout history deployment/app-deployment
kubectl rollout undo deployment/app-deployment
```### Lists external IP adress of all nodes
```
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}'
```### Lists all node of names with external IP address
```
kubectl get nodes -o custom-columns=NODE:.metadata.name,'IP:.status.addresses[?(@.type=="InternalIP")].address'
```### To get token from secret
```
kubectl -n jenkins get secret jenkins-token -o jsonpath="{.data.token}"|base64 -d; echo
```### StatefulSet - rolling update, scale up and down
```
kubectl rollout restart sts name_sts
kubectl scale --replicas=0 sts name_sts
kubectl scale --replicas=1 sts name_sts
```