Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

Kubernetes Cheatsheet

September 28, 2023 — Gregg Szumowski

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

September 02, 2023 — Gregg Szumowski
  1. gg Move to the first line of the file
  2. G Move to the last line
  3. gg=G Reindent the whole file
  4. gv Reselect the last visual selection
  5. < Jump to beginning of last visual selection
  6. > Jump to end of last visual selection
  7. ^ Move to first non-blank character of the line
  8. g_ Move the last non-blank character of the line (but you remove trailing whitespace, right)
  9. g_lD Delete all the trailing whitespace on the line
  10. ea Append to the end of the current word
  11. gf Jump to the file name under the cursor
  12. xp Swap character forward
  13. Xp Swap character backward
  14. yyp Duplicate the current line
  15. yapP Duplicate the current paragraph
  16. dat Delete around an HTML tag, including the tag
  17. dit Delete inside an HTML tag, excluding the tag
  18. w Move one word to the right
  19. b Move one word to the left
  20. dd Delete the current line
  21. zc Close current fold
  22. zo Open current fold
  23. za Toggle current fold
  24. zi Toggle folding entirely
  25. << Outdent current line
  26. >> Indent current line
  27. z= Show spelling corrections
  28. zg Add to spelling dictionary
  29. zw Remove from spelling dictionary
  30. ~ Toggle case of current character
  31. gUw Uppercase until end of word (u for lower, ~ to toggle)
  32. gUiw Uppercase entire word (u for lower, ~ to toggle)
  33. gUU Uppercase entire line
  34. gu$ Lowercase until the end of the line
  35. da" Delete the next double-quoted string
  36. + Move to the first non-whitespace character of the next line
  37. S Delete current line and go into insert mode
  38. I insert at the beginning of the line
  39. ci" Change what’s inside the next double-quoted string
  40. ca{ Change inside the curly braces (try [, (, etc.)
  41. vaw Visually select word
  42. dap Delete the whole paragraph
  43. r Replace a character
  44. [ Jump to beginning of last yanked text
  45. ] Jump to end of last yanked text
  46. g; Jump to the last change you made
  47. g, Jump back forward through the change list
  48. & Repeat last substitution on current line
  49. g& Repeat last substitution on all lines
  50. ZZ Save the current file and quit Vim

Tags: cli, vim, cheatsheet, shortcuts, motd