π»π― Ninja Kubernetes Cheat Sheet for Ninja Developers π
Chetan
Posted on May 18, 2023
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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:
Bose Framework: An Open Source Framework that is Swiss Army Knife for Selenium. Read the docs at https://www.omkar.cloud/bose/
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/.
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/.
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/.
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.
Posted on May 18, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.