Kubernetes Commands & Best Practices Curriculum
12 chapters
1. View merged kubeconfig
[Verse 1]
When you're working with clusters scattered far and wide
Multiple configs living side by side
Kubernetes contexts all merged into one
Let me show you how to see what you've done
[Chorus]
View merged kubeconfig, see it all
Current context standing tall
Users, clusters, context names
Config view shows all the chains
Kubectl config view command
Shows the merged file at your hand
[Verse 2]
From your home directory dot kube folder
To environment variables that make you bolder
KUBECONFIG paths get combined as one
Multiple sources merged when kubectl runs
[Chorus]
View merged kubeconfig, see it all
Current context standing tall
Users, clusters, context names
Config view shows all the chains
Kubectl config view command
Shows the merged file at your hand
[Bridge]
Secrets hidden by default you'll see
Add raw flag for full transparency
Minify output keeps it clean and tight
Flatten nested structure for clearer sight
[Verse 3]
Authentication details side by side
Certificate data where credentials hide
Server endpoints for each cluster shown
Now you see how all configs have grown
[Chorus]
View merged kubeconfig, see it all
Current context standing tall
Users, clusters, context names
Config view shows all the chains
Kubectl config view command
Shows the merged file at your hand
[Outro]
Config view, config view
Shows you everything in merged review
One command to rule them all
Kubernetes configs answer your call
2. Set a default namespace for your current context
[Verse 1]
When you're working with your cluster every day
Switching namespaces in the kubectl way
There's a shortcut that will save you precious time
Set a default and everything's fine
You're typing namespace flags with every call
Getting tired of writing them all
But there's a better way to make this smooth
Let me show you how to get in the groove
[Chorus]
Config set context current namespace
No more typing it every single place
Current context gets the default space
Config set context current namespace
Remember the pattern, it's easy to trace
Set your context with the namespace
Current means now, no need to specify
Config set context and you're flying high
[Verse 2]
First you use config then set context next
Current flag means your active text
Namespace equals the one you choose
Production, staging, whatever you use
Double dash current is the magic word
Points to the context you're working with right now
No more guessing which one is preferred
Your default namespace shows you how
[Chorus]
Config set context current namespace
No more typing it every single place
Current context gets the default space
Config set context current namespace
Remember the pattern, it's easy to trace
Set your context with the namespace
Current means now, no need to specify
Config set context and you're flying high
[Bridge]
When you run your pods and services too
They'll land in the space that you set as true
No more dash n flags on every command
Your workflow flows like you planned
[Chorus]
Config set context current namespace
No more typing it every single place
Current context gets the default space
Config set context current namespace
[Outro]
Set it once and you're good to go
Default namespace in the flow
Kubectl config makes it clear
Your context namespace is always here
3. Switch to a different context
[Verse 1]
When you're working with your clusters
And you need to make a switch
From development to staging
There's a command that does the trick
Your config holds the contexts
Like different doors to walk through
But you can only use one at a time
So here's what you should do
[Chorus]
Use context, switch it up
kubectl config use dash context
Pick the name and fire it up
kubectl config use dash context
When you need to change your view
To a different cluster too
Use context, that's the way
To switch where kubectl will play
[Verse 2]
Every context is a gateway
To a specific cluster space
With its own authentication
And its own namespace place
Before you run your pod commands
Or check your service state
Make sure you're in the right context
Don't let confusion be your fate
[Chorus]
Use context, switch it up
kubectl config use dash context
Pick the name and fire it up
kubectl config use dash context
When you need to change your view
To a different cluster too
Use context, that's the way
To switch where kubectl will play
[Bridge]
First list them with get dash contexts
See all the options there
Then choose the one you're targeting
Handle switching with care
Production, staging, local dev
Each context has its role
One command line will take you there
And give you full control
[Chorus]
Use context, switch it up
kubectl config use dash context
Pick the name and fire it up
kubectl config use dash context
When you need to change your view
To a different cluster too
Use context, that's the way
To switch where kubectl will play
[Outro]
Context switching made simple
Just remember the command
kubectl config use dash context
And you'll have control in hand
4. List all contexts (clusters you can connect to)
[Verse 1]
When you're working with your clusters every day
Multiple environments in your Kubernetes way
There's a command that shows you all the choices that you've got
kubectl config get-contexts shows the lot
[Chorus]
Get contexts, see them all
Current cluster, namespace call
Asterisk shows where you are
Switch between them near and far
Get contexts, list them clear
All your clusters waiting here
[Verse 2]
Three columns tell the story that you need to know
Name and cluster, namespace in a row
The current context has a star beside its name
That's your active cluster in this kubectl game
[Chorus]
Get contexts, see them all
Current cluster, namespace call
Asterisk shows where you are
Switch between them near and far
Get contexts, list them clear
All your clusters waiting here
[Bridge]
Production, staging, development too
Each context knows exactly what to do
Authentication settings stored inside
Your kubeconfig file is your guide
[Verse 3]
When you're lost and don't know where your kubectl points
Check your contexts, see all the joints
Between your terminal and clusters in the cloud
Get contexts makes the connections loud
[Chorus]
Get contexts, see them all
Current cluster, namespace call
Asterisk shows where you are
Switch between them near and far
Get contexts, list them clear
All your clusters waiting here
[Outro]
kubectl config get-contexts
Shows you all your choices
kubectl config get-contexts
Listen to those voices
5. View current cluster info
[Verse 1]
When you're working with containers in the cloud
And your pods are running but you're not sure how
There's a command that shows you what you need to know
About the cluster where your workloads go
kubectl cluster dash info is the key
Shows the master and the API
Control plane endpoints clearly displayed
DNS and dashboard, all information laid
[Chorus]
Cluster info, cluster info
Shows you where your system flows
Master URL and DNS too
Everything you need to view
Cluster info, cluster info
kubectl makes it crystal clear
All the endpoints you hold dear
Your cluster's heart is right here
[Verse 2]
The control plane's the brain of your design
API server on the master's front line
CoreDNS handles name resolution
Every service finds its distribution
When you run the command you'll see URLs
Master endpoint where the magic dwells
Kubernetes dashboard if it's running there
All the pieces of your cluster's care
[Chorus]
Cluster info, cluster info
Shows you where your system flows
Master URL and DNS too
Everything you need to view
Cluster info, cluster info
kubectl makes it crystal clear
All the endpoints you hold dear
Your cluster's heart is right here
[Bridge]
No more guessing where components are
This command shows you near and far
Troubleshooting made so simple now
Just one line shows you what and how
[Verse 3]
If your cluster's healthy it will show
Green responses, good to go
If there's trouble with connectivity
You'll see the errors immediately
Add dump flag for detailed inspection
Every component's full reflection
But for basics just the simple call
Shows the cluster's core through it all
[Chorus]
Cluster info, cluster info
Shows you where your system flows
Master URL and DNS too
Everything you need to view
Cluster info, cluster info
kubectl makes it crystal clear
All the endpoints you hold dear
Your cluster's heart is right here
[Outro]
So remember when you need to see
Your cluster's architecture free
kubectl cluster dash info today
Shows your Kubernetes the easy way
6. View just the current context
[Verse 1]
Before you run a single command today
Stop and check where kubectl wants to play
One simple line will show you where you stand
Current context in your steady hand
Type kubectl config current dash context now
See which cluster you're connected to somehow
Production staging or your local test
Know your target before you do the rest
[Chorus]
Current context current context
Know exactly where you are
Current context current context
Like a kubernetes north star
Never operate blind never take that chance
Check your context first give safety a glance
Current context saves the day
[Verse 2]
Namespaces are your folders in the cloud
Logical isolation clean and proud
Think of them as rooms inside your house
Each one contains what it's about
RBAC boundaries scope your resources tight
Like filing cabinets organized just right
Before you kubectl apply or delete
Make sure you're in the context that you need
[Chorus]
Current context current context
Know exactly where you are
Current context current context
Like a kubernetes north star
Never operate blind never take that chance
Check your context first give safety a glance
Current context saves the day
[Bridge]
Kubectx and kubens are tools for switching fast
Color code your prompt make safety habits last
Green for development red alerts for prod
Context confirmation is your safety guard
[Verse 3]
Best practice says to always double check
Production clusters need your full respect
One wrong command in the wrong place
Could bring disaster to your workspace
So type that line and read it twice
Current context is your best advice
Know your cluster know your namespace too
Context awareness will see you through
[Chorus]
Current context current context
Know exactly where you are
Current context current context
Like a kubernetes north star
Never operate blind never take that chance
Check your context first give safety a glance
Current context saves the day
[Outro]
Kubectl config current dash context
Your safety net your guiding light
Check it first check it right
Current context every time
7. Kubernetes Commands & Best Practices Curriculum
[Verse 1]
In the world of Kubernetes, there's a pattern to know
Master-worker architecture, watch the data flow
Control plane at the center, keeping everything in line
API server listening, etcd stores the design
Scheduler finds the best spot, controller keeps the state
While worker nodes are running what you create
[Chorus]
Every kubectl command is an API call
To the control plane managing it all
Context switching, cluster hopping
Never let your workflow stopping
Kube config holds the keys
To your cluster mysteries
[Verse 2]
Kubelet on each worker node, makes the pods come alive
Kube-proxy routes the traffic, helps your apps survive
Before you start commanding, understand the flow
From your terminal typing to the pods below
Mental model matters most, when you're learning how to play
In the Kubernetes orchestra every single day
[Chorus]
Every kubectl command is an API call
To the control plane managing it all
Context switching, cluster hopping
Never let your workflow stopping
Kube config holds the keys
To your cluster mysteries
[Bridge]
Tilde slash kube slash config file
Stores your connection profile
Dev and staging, production too
Context switching sees you through
Current context, current cluster
Don't let environments bluster
[Verse 3]
Three environments waiting, development to prod
Context management saves you from the troubleshooting squad
Check your current context before you run that command
Wrong cluster deployments weren't part of the plan
Architecture understanding makes the rest make sense
API calls and contexts, that's your first defense
[Chorus]
Every kubectl command is an API call
To the control plane managing it all
Context switching, cluster hopping
Never let your workflow stopping
Kube config holds the keys
To your cluster mysteries
[Outro]
Master-worker model, keep it in your head
Control plane and worker nodes, that's the way ahead
Context first, command second, that's the golden rule
Kubernetes foundations, welcome to the school
8. Create a namespace
[Verse 1]
In the world of Kubernetes where containers play
We need organization to keep chaos at bay
Namespaces are folders that help us divide
Resources and workloads all running inside
[Chorus]
kubectl create namespace my-app
Simple command that fills the gap
Isolation boundaries clean and neat
kubectl create makes it complete
Namespace born with just one line
Organization by design
[Verse 2]
Think of it like folders on your desktop screen
Keeping projects separate and environments clean
Development here and production there
Each namespace gets its own little square
[Chorus]
kubectl create namespace my-app
Simple command that fills the gap
Isolation boundaries clean and neat
kubectl create makes it complete
Namespace born with just one line
Organization by design
[Bridge]
Default namespace comes for free
But structure's what we need to see
Test and staging side by side
Each team gets their own divide
One command and you're all set
Best practice you won't regret
[Verse 3]
Name it clearly what it's for
Frontend, backend, and much more
Policies and quotas can apply
To each namespace in the sky
[Chorus]
kubectl create namespace my-app
Simple command that fills the gap
Isolation boundaries clean and neat
kubectl create makes it complete
Namespace born with just one line
Organization by design
[Outro]
kubectl create namespace
Your container's happy place
kubectl create namespace
Organized without a trace
9. Delete a namespace (WARNING: deletes ALL resources inside)
[Verse 1]
In the cluster where your pods all play
There's a boundary that keeps them safe
Called a namespace, like a room with walls
Where your services and secrets stay
But sometimes you need to clean house
Clear everything out, start fresh somehow
There's a command that's swift and clean
But dangerous too, if you know what I mean
[Chorus]
Delete namespace, wipe it all away
K-U-B-E-C-T-L the kubectl way
Everything inside will disappear
Pods and services, secrets and all, my dear
Delete namespace, think before you say
Warning warning, there's no undo today
[Verse 2]
First you type kubectl delete
Then namespace comes next, so neat
Add the name of what you want gone
Hit enter and it won't take long
All the deployments living there
ConfigMaps floating in the air
Persistent volumes, ingress rules
All your carefully crafted tools
[Chorus]
Delete namespace, wipe it all away
K-U-B-E-C-T-L the kubectl way
Everything inside will disappear
Pods and services, secrets and all, my dear
Delete namespace, think before you say
Warning warning, there's no undo today
[Bridge]
Like burning down the whole hotel
Not just checking out, but oh well
Every guest and every key
Gone for all eternity
Double check the name you type
Make sure the namespace is right
Production, staging, or just test
One wrong move, you'll lose the rest
[Chorus]
Delete namespace, wipe it all away
K-U-B-E-C-T-L the kubectl way
Everything inside will disappear
Pods and services, secrets and all, my dear
Delete namespace, think before you say
Warning warning, there's no undo today
[Outro]
When you need a fresh clean slate
This command will seal your fate
But remember what we've learned today
Check twice, delete once, the kubectl way
10. List all namespaces
[Verse 1]
When you're working with your cluster every day
Need to see what spaces hold your workloads at play
Kubernetes divides resources nice and clean
Namespaces keep things organized, know what I mean
[Chorus]
kubectl get namespaces, list them all
See every space from big to small
Get namespaces, one command will show
All the divisions where your apps can go
kubectl get namespaces, that's the way
To see your cluster's layout every day
[Verse 2]
Default namespace is where most things live
Kube-system holds what the cluster has to give
Public space for all to see and share
Node lease tracks the nodes with care
[Chorus]
kubectl get namespaces, list them all
See every space from big to small
Get namespaces, one command will show
All the divisions where your apps can go
kubectl get namespaces, that's the way
To see your cluster's layout every day
[Bridge]
Some are system spaces, some are yours to claim
Each one has a purpose, each one has a name
Age and status columns tell the story true
Active namespaces working hard for you
[Verse 3]
You can make your own for teams and environments
Dev and prod and staging, all with different intents
Isolation matters when you scale up high
Namespaces help you organize and keep things dry
[Chorus]
kubectl get namespaces, list them all
See every space from big to small
Get namespaces, one command will show
All the divisions where your apps can go
kubectl get namespaces, that's the way
To see your cluster's layout every day
[Outro]
One simple command to rule them all
kubectl get namespaces answers the call
11. Run any command in a specific namespace
[Verse 1]
When you're working with your cluster and pods are scattered wide
Different namespaces hold them like rooms you need to find
The default view won't show you all the secrets that they keep
You need to specify the space where your applications sleep
[Chorus]
Dash N is the key, dash N sets you free
Point it to the namespace where your pods should be
Get pods dash N, then the name you choose
That's the magic formula you never want to lose
Dash N namespace, that's the way to go
See exactly what you need, and nothing you don't know
[Verse 2]
Production, staging, development, each has its own domain
Without the namespace flag, your search will be in vain
The kubectl command is waiting for that extra piece of info
Tell it where to look and watch your pod list start to flow
[Chorus]
Dash N is the key, dash N sets you free
Point it to the namespace where your pods should be
Get pods dash N, then the name you choose
That's the magic formula you never want to lose
Dash N namespace, that's the way to go
See exactly what you need, and nothing you don't know
[Bridge]
Kube-system, monitoring, whatever space you've made
Every namespace has its treasures waiting to be displayed
Don't forget the angle brackets mean you type your own
Replace that placeholder text with names you've grown to know
[Verse 3]
Now you're navigating clusters like a captain of the sea
Each namespace is an island with its own topology
The power is in your hands now, you control what you can see
With dash N and the name, you've unlocked the master key
[Final Chorus]
Dash N is the key, dash N sets you free
Point it to the namespace where your pods should be
Get pods dash N, then the name you choose
That's the magic formula you never want to lose
Dash N namespace, now you know the way
Navigate your clusters every single day
[Outro]
Remember dash N namespace
That's how you find your place
12. Get resources across ALL namespaces
[Verse 1]
When you need to see what's running everywhere
Across your cluster wide and far
Default namespace shows you just a piece
But there's so much more beyond what you can see
Pods are hiding in their separate homes
System services, apps, and more
[Chorus]
Get all namespaces, dash dash all namespaces
Kubectl get pods, see everything that lives
All namespaces, dash dash all namespaces
Every corner of your cluster, now it gives
No more guessing where your workloads hide
All namespaces brings them to your side
[Verse 2]
Kube system holds the vital parts
Ingress controllers in their space apart
Your applications spread across the zones
Each namespace like a separate home
Without the flag you're looking through one door
But clusters have so much more in store
[Chorus]
Get all namespaces, dash dash all namespaces
Kubectl get pods, see everything that lives
All namespaces, dash dash all namespaces
Every corner of your cluster, now it gives
No more guessing where your workloads hide
All namespaces brings them to your side
[Bridge]
From kube system to your custom names
Default, monitoring, all the same
One command to rule them all
Watch your pods both big and small
Cross the boundaries, break the walls
All namespaces shows them all
[Chorus]
Get all namespaces, dash dash all namespaces
Kubectl get pods, see everything that lives
All namespaces, dash dash all namespaces
Every corner of your cluster, now it gives
No more guessing where your workloads hide
All namespaces brings them to your side
[Outro]
When you're lost in Kubernetes maze
All namespaces lights the way
Every pod in every place
All namespaces shows the way
Back to Home