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
gg
Move to the first line of the fileG
Move to the last linegg=G
Reindent the whole filegv
Reselect 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_lD
Delete all the trailing whitespace on the lineea
Append to the end of the current wordgf
Jump to the file name under the cursorxp
Swap character forwardXp
Swap character backwardyyp
Duplicate the current lineyapP
Duplicate the current paragraphdat
Delete around an HTML tag, including the tagdit
Delete inside an HTML tag, excluding the tagw
Move one word to the rightb
Move one word to the leftdd
Delete the current linezc
Close current foldzo
Open current foldza
Toggle current foldzi
Toggle folding entirely<<
Outdent current line>>
Indent current linez=
Show spelling correctionszg
Add to spelling dictionaryzw
Remove from spelling dictionary~
Toggle case of current charactergUw
Uppercase until end of word (u for lower, ~ to toggle)gUiw
Uppercase entire word (u for lower, ~ to toggle)gUU
Uppercase 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 lineS
Delete current line and go into insert modeI
insert at the beginning of the lineci"
Change what’s inside the next double-quoted stringca{
Change inside the curly braces (try [, (, etc.)vaw
Visually select worddap
Delete the whole paragraphr
Replace 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 linesZZ
Save the current file and quit Vim
Tags: cli, vim, cheatsheet, shortcuts, motd