If you’re like me, you may have those moments where you’re at the terminal, hands hovering over your keyboard, and … nothing. I always seem to freeze up and probably rely too much on bash history. (The up arrow is my friend.)

While learning Kubernetes, I ended up posting 14 or 15 sticky notes on my monitor to help me in those moments — but after a while, I could barely read what was on the screen. So finally, I created one small, easy-to-read piece of paper to reference when I, or you, get stuck. This Kubernetes Cheat Sheet is meant to get you started performing commands in Kubernetes and provide you with all the basic commands at a quick glance. (Check out the downloadable asset below!)

Command Results

Some of the commands on this cheat sheet might not return any results, but have no fear! See below for some resources you can create, then quickly turn around and run the commands in your cheat sheet to alter your resources any way you wish!

Let’s start with pods. Here is the YAML for a basic busybox pod:

apiVersion: v1
kind: Pod
name: busybox
- image: busybox:1.28.4
- sleep
- "3600"
name: busybox
restartPolicy: Always

Learn more about YAML here.

Create the pod with this command:

kubectl create -f busybox.yaml

Use this command to create a deployment:

kubectl run nginx --image=nginx

Use this command to create a service from the deployment above:

kubectl expose deployment nginx --port=80 --type=NodePort

Sign up for a free community account today and check out these free courses: Kubernetes Essentials and Beginner’s Guide to Containers and Orchestration to learn more about Kubernetes!

Here is the YAML for a simple persistent volume using local storage from the node:

apiVersion: v1
kind: PersistentVolume
name: data-pv
namespace: web
storageClassName: local-storage
storage: 1Gi
- ReadWriteOnce
path: /mnt/data

Use the following command to create the persistent volume:

kubectl apply -f my-pv.yaml

Here is the YAML for a simple ConfigMap:

apiVersion: v1
kind: ConfigMap
name: my-config-map
myKey: myValue
anotherKey: anotherValue

Use the following command to create the ConfigMap:

kubectl apply -f configmap.yaml

Here is the YAML for a secret:

apiVersion: v1
kind: Secret
name: my-secret
myKey: myPassword

Use this command to create the secret:

kubectl apply -f secret.yaml

Here is the YAML for a service account:

apiVersion: v1
kind: ServiceAccount
name: acr
namespace: default
- name: acr

Use this command to create the service account:

kubectl apply -f serviceaccount.yaml

Download Now!

This should be enough to get you started! I’ve also created this PDF for you to download and keep next to you for reference!

Kubernetes Cheat Sheet Cover


If you enjoyed these exercises and following along with the commands, check out the brand new Cloud Native Certified Kubernetes Administrator (CKA) course on Linux Academy to dig deeper into Kubernetes! Or check out these additional free resources:

New call-to-action

3 responses to “Kubernetes Cheat Sheet”

  1. Ash says:

    Very helpful, thank you!

  2. Ratik says:

    Thanks a lot

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get actionable training and tech advice

We'll email you our latest articles up to once per week.