alias k='kubectl'
alias kgp='kubectl get pods'
alias kgpa='kubectl get pods --all-namespaces'
alias kgs='kubectl get svc'
alias kgsa='kubectl get svc --all-namespace
export dry='--dry-run=client -o yaml'
k run nginx --image=nginx --restart=Never $dry
source <(kubectl completion zsh)
echo 'alias k=kubectl' >>/.zshrc
echo 'complete -F __start_kubectl k' >>/.zshrc
kubectl config get-contexts kubectl config set-context kind-kind
kubectl config view --minify | grep namespace kubectl config set-context --current --namespace=default
can be added to ~/.vimrc
set number
set ignorecase
set expandtab
set ts=2 sw=2 sts=2
-
Fast save/exit: Instead of
:wq
, useZZ
-
Return to bash without exiting wim:
:w
andCTL-Z
to pause vim and job %1 to reenter vim -
Delete to end of line: Position cursor and hit D
-
Delete entire line: DD
-
Force write a file that needs root permission:
:w !sudo tee %
-
Indentation ** Put the cursor anywhere in the first line. ** Press V then jj to visually select the three lines. ** Press > to indent or < to unindent. ** Press . to repeat the indent, or u to undo if you have shifted too far.
-
Copy and paste lines ** :20 and V, select lines ** Copy using y eller Cut using d ** p Also delete lines using dd and undo using u
(or ) then typing your search pattern. Press Esc to cancel or press Enter to perform the search. Then press n to search forwards for the next occurrence, or N to search backwards. Type ggn to jump to the first match, or GN to jump to the last.
- search ** /something and ENTER or ESC ** n og N to continue search forwrd /backward
echo "foo" | sudo tee -a file
Editing objects:
kubectl edit
For labels prefer
k label deployment/myapp app=myapp --overwrite
For images prefer
k set image nginx --image=nginx:1.7.9
k api-resources
kubectl api-versions```
# List available fields
```k explain pod.spec.securityContext --recursive```
# Get help for a particular field
```k explain pod.spec.securityContext.runAsNonRoot```
restart all pods in a namespace
```kubectl -n {NAMESPACE} rollout restart deploy```