DEV Community

Cover image for πŸ’»πŸŽ― Ninja Kubernetes Cheat Sheet for Ninja Developers πŸ“œ
Chetan
Chetan

Posted on • Updated on • Originally published at omkar.cloud

πŸ’»πŸŽ― Ninja Kubernetes Cheat Sheet for Ninja Developers πŸ“œ

A small request

I'm trying to reach 1K GitHub stars for "Bose" - an open source bot development framework I just launched for easily creating advanced selenium based bots.
Can you help us out by starring the GitHub repository? It would help us a lot! Thank you! https://github.com/omkarcloud/bose

Popular

# Ger logs of Pods in a Deployment. This is the recommended way to fetch logs, as the deployment name remains the same even if pods change upon creation.
kubectl logs deploy/<deployment-name>

# View the latest logs from the end. This can be useful when there are a large number of logs generated by a pod.
kubectl logs deploy/<deployment-name> --tail=2000

# Access a Pod within a Deployment using an interactive bash shell. This is the recommended method as the deployment name remains the same, unlike the pods that change upon creation.
kubectl exec -it deploy/<deployment-name> -- bash

# Access a Pod within a Deployment using an interactive shell. Use this if the previous method fails, as the pod does not support bash.
kubectl exec -it deploy/<deployment-name> -- sh

# Apply a folder or file containing Kubernetes manifests.
kubectl apply -f <folder-name-or-filename>

# Delete a folder or file containing Kubernetes manifests.
kubectl delete -f <folder-name-or-filename>

# Delete a deployment.
kubectl delete deployment <deployment-name>

# Forcefully delete a deployment without waiting for graceful termination.
kubectl delete deployment <deployment-name> --grace-period=0 --force

# Display the logs of a specific pod.
kubectl logs <pod-name>

# Stream and display the logs of a specific pod.
kubectl logs <pod-name> --follow

# Delete all jobs.
kubectl delete jobs `kubectl get jobs -o custom-columns=:.name`

# Delete pods based on a selector.
kubectl delete pods -l <pod-selector-key>=<pod-selector-value>
Enter fullscreen mode Exit fullscreen mode

Pods

# List all pods in the current namespace.
kubectl get pods

# Get detailed information about a pod.
kubectl describe pod <pod-name>

# Create a new pod.
kubectl create pod <pod-name> 

# Delete a pod.
kubectl delete pod <pod-name> 
Enter fullscreen mode Exit fullscreen mode

Nodes

# List all nodes in the cluster.
kubectl get nodes 

# Get detailed information about a node.
kubectl describe node <node-name> 

# Create a new node
kubectl create node <node-name> 

# Delete a node
kubectl delete node <node-name> 
Enter fullscreen mode Exit fullscreen mode

Services

# List all services in the cluster.
kubectl get services 

# Get detailed information about a service.
kubectl describe service <service-name> 

# Create a new service.
kubectl create service <service-name> 

# Delete a service.
kubectl delete service <service-name> 
Enter fullscreen mode Exit fullscreen mode

Deployments

# List all deployments in the cluster.
kubectl get deployments 

# Get detailed information about a deployment.
kubectl describe deployment <deployment-name> 

# Create a new deployment.
kubectl create deployment <deployment-name> 

# Delete a deployment.
kubectl delete deployment <deployment-name> 
Enter fullscreen mode Exit fullscreen mode

ReplicaSets

# List all replica sets in the cluster.
kubectl get replicasets 

# Get detailed information about a replica set.
kubectl describe replicaset <replicaset-name> 

# Create a new replica set.
kubectl create replicaset <replicaset-name> 

# Delete a replica set.
kubectl delete replicaset <replicaset-name> 
Enter fullscreen mode Exit fullscreen mode

StatefulSets

# List all stateful sets in the cluster.
kubectl get statefulsets 

# Get detailed information about a stateful set.
kubectl describe statefulset <statefulset-name> 

# Create a new stateful set.
kubectl create statefulset <statefulset-name> 

# Delete a stateful set.
kubectl delete statefulset <statefulset-name> 

Enter fullscreen mode Exit fullscreen mode

Jobs

# List all jobs in the cluster.
kubectl get jobs 

# Get detailed information about a job.
kubectl describe job <job-name>

# Create a new job.
kubectl create job <job-name> 

# Delete a job.
kubectl delete job <job-name> 
Enter fullscreen mode Exit fullscreen mode

CronJobs

# List all cron jobs in the cluster.
kubectl get cronjobs 

# Get detailed information about a cron job.
kubectl describe cronjob <cronjob-name> 

# Create a new cron job.
kubectl create cronjob <cronjob-name> 

# Delete a cron job.
kubectl delete cronjob <cronjob-name> 
Enter fullscreen mode Exit fullscreen mode

ConfigMaps

# List all config maps in the cluster.
kubectl get configmaps 

# Get detailed information about a config map.
kubectl describe configmap <configmap-name> 

# Create a new config map.
kubectl create configmap <configmap-name> 

# Delete a config map.
kubectl delete configmap <configmap-name> 
Enter fullscreen mode Exit fullscreen mode

Secrets

# List all secrets in the cluster.
kubectl get secrets 

# Get detailed information about a secret.
kubectl describe secret <secret-name> 

# Create a new secret.
kubectl create secret <secret-name> 

# Delete a secret.
kubectl delete secret <secret-name> 
Enter fullscreen mode Exit fullscreen mode

Ingresses

# List all ingresses in the cluster.
kubectl get ingresses 

# Get detailed information about an ingress.
kubectl describe ingress <ingress-name>

# Create a new ingress.
kubectl create ingress <ingress-name> 

# Delete an ingress.
kubectl delete ingress <ingress-name> 
Enter fullscreen mode Exit fullscreen mode

PersistentVolumes

# List all persistent volumes in the cluster.
kubectl get pv 

# Get detailed information about a persistent volume.
kubectl describe pv <persistentvolume-name> 

# Create a new persistent volume.
kubectl create pv <persistentvolume-name> 

# Delete a persistent volume.
kubectl delete pv <persistentvolume-name> 
Enter fullscreen mode Exit fullscreen mode

PersistentVolumesClaims

# List all persistent volumes in the cluster.
kubectl get pvc

# Get detailed information about a persistent volume.
kubectl describe pvc <persistentvolumesclaim-name> 

# Create a new persistent volume.
kubectl create pvc <persistentvolumesclaim-name> 

# Delete a persistent volume.
kubectl delete pvc <persistentvolumesclaim-name> 
Enter fullscreen mode Exit fullscreen mode

Also, this article is licensed under MIT, so you are free to use it as you wish.

If you are a YouTuber, I encourage you to create a video of this article on your channel. By doing so, you can potentially help thousands of developers solve their deployment problems and earn great amounts of punya. Additionally, you can send me your Video URL and I will feature your video at the top of the article, boosting its views.


Some of my brilliant Creations, that you don’t want to miss out are:

  1. Bose Framework: An Open Source Framework that is Swiss Army Knife for Selenium. Read the docs at https://www.omkar.cloud/bose/

  2. Free Tools: Simplify your daily tasks with the Free Omkar Tools, an all-in-one dashboard that offers a range of free utilities. Whether it's formatting JSON, comparing text, or testing RegExp, these tools have got you covered. Say goodbye to unreliable websites and use it at https://www.omkar.cloud/tools/.

  3. Omkar Cloud: My Samurai Lead Generation Software allows you to access over 200M+ LinkedIn leads, enabling you to win clients. It's like Sales Navigator with superpowers. You can use it at https://www.omkar.cloud/.

  4. Omkar Cloud Datasets: Enhance your analysis with meticulously scraped datasets from Stack Overflow, G2, and many more reputable sources. These fresh datasets are readily available for your data analysis at https://www.omkar.cloud/datasets/.

  5. Kubernetes Consultation: Take your DevOps practices to the next level with our team of Ninja Developers. Through our Kubernetes Consultation service, we can help you turbocharge your DevOps processes and enable you to move at the speed of light. Whatsapp us for a consultation at https://www.omkar.cloud/l/whatsapp.

Top comments (2)

Collapse
 
bcouetil profile image
Benoit COUETIL πŸ’«

Man, there is little to no value to paste the get/describe/create/delete of a bunch of resources.

The official cheat sheet is something you should get example from, there are advanced commands : kubernetes.io/docs/reference/kubec...

Collapse
 
chetanam profile image
Chetan

Right, Even I think this Cheat sheet needs more work