Kubectl is a command-line tool that is used for managing Kubernetes clusters. It provides a way to interact with Kubernetes API and allows developers to deploy, inspect, and manage their applications. In this article, we will discuss a list of kubectl commands with examples that will help you to get started with Kubernetes.
Basic Commands
- kubectl version - This command is used to check the version of kubectl that is installed on your system.
Example:
kubectl version
- kubectl cluster-info - This command is used to display the cluster information.
Example:
kubectl cluster-info
- kubectl get - This command is used to list the resources in a particular namespace.
Example:
kubectl get pods
- kubectl describe - This command is used to get detailed information about a particular resource.
Example:
kubectl describe pod my-pod
- kubectl create - This command is used to create a new resource from a file or standard input.
Example:
kubectl create -f my-deployment.yaml
- kubectl delete - This command is used to delete a particular resource.
Example:
kubectl delete pod my-pod
- kubectl edit - This command is used to edit a particular resource.
Example:
kubectl edit pod my-pod
- kubectl apply - This command is used to apply changes to a resource.
Example:
kubectl apply -f my-deployment.yaml
- kubectl exec - This command is used to execute a command in a container.
Example:
kubectl exec my-pod ls
- kubectl logs - This command is used to get the logs of a container.
Example:
kubectl logs my-pod
Advanced Commands
- kubectl rollout - This command is used to manage rollouts of a deployment.
Example:
kubectl rollout status my-deployment
- kubectl autoscale - This command is used to automatically scale a deployment based on CPU usage.
Example:
kubectl autoscale deployment my-deployment --cpu-percent=50 --min=1 --max=10
- kubectl label - This command is used to add or remove labels from a resource.
Example:
kubectl label pod my-pod app=myapp
- kubectl annotate - This command is used to add or remove annotations from a resource.
Example:
kubectl annotate pod my-pod description='This is my pod'
- kubectl proxy - This command is used to create a proxy server between your machine and Kubernetes API server.
Example:
kubectl proxy --port=8080
Kubectl is a powerful tool that allows developers to manage their Kubernetes clusters from the command line. In this article, we have discussed a list of kubectl commands with examples that will help you to get started with Kubernetes. Whether you are a beginner or an experienced Kubernetes user, these commands will help you to be more productive and efficient in managing your Kubernetes clusters.
Related Searches and Questions asked:
That's it for this post. Keep practicing and have fun. Leave your comments if any.
0 Comments