Kubernetes Cheatsheet
The get parameter is a powerful way of discovering your
kubenetes resources. You can use it to query: * namespace * pod * node *
deployment * service * replicasets
$ kubectl get nodes
$ kubectl get ns # ns is an abreviation for namespace
$ kubectl get pods -n kube-system
The create command can do just that for:
- service
- cronjob
- deployment
- job
- namespace (or ns)
$ kubectl create ns hello-world
$ kubectl create cronjob my-cronjob --image=alpine --schedule="*/15 * * * *" -- echo "hi there"
You can also use cj as an abreviation for
cronjob
$ kubectl create cj my-cronjob --image=alpine --schedule="*/15 * * * *" -- echo "hi there"
The edit parameter allows you to update resources:
$ kubectr edit my-cronjob
The delete parameter allows you to remove resources:
$ kubectl delete cronjob my-cronjob
The apply parameter allows you to apply configurations
from files
$ kubectl apply -f jenkins.yaml
The describe parameter provides details of your
resources which could be:
- nodes
- pods
- services
- deployments
- replicasets
- cronjobs
$ kubectl describe cronjob my-cronjob
The logs parameter displays the contents of the
resource’s log:
$ kubectl logs my-resource -n charts
The exec parameter allows you to exec into a
container:
$ kubectl exec -it my-resource -n charts -- /bin/bash
The cp parameter lets you copy files and directories to
and from containers:
$ kubectl cp file1.txt my-resource:file1.txt
Tags: cli, kubernetes, cheatsheet, motd
Vim Keyboard Shortcuts
ggMove to the first line of the fileGMove to the last linegg=GReindent the whole filegvReselect the last visual selection<Jump to beginning of last visual selection>Jump to end of last visual selection^Move to first non-blank character of the lineg_Move the last non-blank character of the line (but you remove trailing whitespace, right)g_lDDelete all the trailing whitespace on the lineeaAppend to the end of the current wordgfJump to the file name under the cursorxpSwap character forwardXpSwap character backwardyypDuplicate the current lineyapPDuplicate the current paragraphdatDelete around an HTML tag, including the tagditDelete inside an HTML tag, excluding the tagwMove one word to the rightbMove one word to the leftddDelete the current linezcClose current foldzoOpen current foldzaToggle current foldziToggle folding entirely<<Outdent current line>>Indent current linez=Show spelling correctionszgAdd to spelling dictionaryzwRemove from spelling dictionary~Toggle case of current charactergUwUppercase until end of word (u for lower, ~ to toggle)gUiwUppercase entire word (u for lower, ~ to toggle)gUUUppercase entire linegu$Lowercase until the end of the lineda"Delete the next double-quoted string+Move to the first non-whitespace character of the next lineSDelete current line and go into insert modeIinsert at the beginning of the lineci"Change what’s inside the next double-quoted stringca{Change inside the curly braces (try [, (, etc.)vawVisually select worddapDelete the whole paragraphrReplace a character[Jump to beginning of last yanked text]Jump to end of last yanked textg;Jump to the last change you madeg,Jump back forward through the change list&Repeat last substitution on current lineg&Repeat last substitution on all linesZZSave the current file and quit Vim
Tags: cli, vim, cheatsheet, shortcuts, motd