Repository navigation
Tips & Tricks
Nicholas Wilde edited this page Feb 9, 2021
·
6 revisions
Some tips & tricks using kubernetes.
I use krew with some plugins to help manage my cluster.
I use the ns krew plugin to quickly change between namespaces.
$ kubectl ns chartnamespace
Context "default" modified.
Active namespace is "chartnamespace".The watch command can be used to watch the status of your kubernetes cluster and update every 2 seconds by default. This is useful when you're waiting for a pod to finish starting.
$ watch kubectl get pods -n chartnamespace
Every 2.0s: kubectl get all amd: Tue Feb 9 08:48:43 2021
NAME READY STATUS RESTARTS AGE
pod/novnc-85c8f5c876-m8rkw 1/1 Running 0 5d10hThe -o wide output switch for kubectl is useful for diplaying more information about your cluster.
kubectl get pods -n chartnamespace -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
haste-7bd595bf64-cdcdg 1/1 Running 0 68m 10.42.6.97 worker-07 <none> <none>$ kubectl rollout restart deployment -n chartnamespaceBash aliases may be used to as kubectl shortcuts.
# .bash_aliases
...
if command -v kubectl &> /dev/null; then
alias k=kubectl
alias ke='kubectl edit'
alias kg='kubectl get'
alias kd='kubectl describe'
alias kgp='kubectl get pods'
alias kgn='kubectl get namespaces'
alias kga='kubectl get all'
alias kgi='kubectl get ingress'
alias kl='kubectl logs'
alias kdesc='kubectl describe'
alias kdel='kubectl delete'
alias wkp='watch kubectl get pods'
alias wkns='watch kubectl get ns'
alias wka='watch kubectl get all'
alias restartpod='kubectl rollout restart deployment'
alias geting="kubectl get all -n kube-system | grep '^service/traefik ' | awk '{print \$4}'"
fi
...$ source ~/.bashrc- Home
- Deployment
- Integration
- Development
- Scripts
- Requests
- Tips & Tricks
- Troubleshooting
- FAQ
- Contributing
- Code of Conduct