Skip to main content

Command Palette

Search for a command to run...

Commonly used commands in Kubernetes

Published
2 min read
N

AWS certified solution architect – Associate with 2+ years of experience delivered training content to students to drive adoption and usage of AWS services. During this time I got an opportunity to combine a passion for teaching, with enthusiasm for technology, to drive learning. 8+ Months of hands-on experience on planning, designing dynamically scalable, reliable, available, fault-tolerant, cost efficient and secure infrastructure solutions for deploying various multi-tier applications on cloud using Amazon Web Services.

Here are some common commands related to Kubernetes:

  1. Cluster Management:

    • kubectl cluster-info: Display information about the Kubernetes cluster.

    • kubectl get nodes: List all the nodes in the cluster.

    • kubectl describe node <node-name>: Get detailed information about a specific node.

    • kubectl get namespaces: List all namespaces in the cluster.

    • kubectl create namespace <namespace-name>: Create a new namespace.

    • kubectl delete namespace <namespace-name>: Delete a namespace and all its resources.

  2. Workload Management:

    • kubectl create deployment <deployment-name> --image=<image-name>: Create a new deployment using a specified container image.

    • kubectl get deployments: List all deployments in the cluster.

    • kubectl describe deployment <deployment-name>: Get detailed information about a specific deployment.

    • kubectl scale deployment <deployment-name> --replicas=<replica-count>: Scale the number of replicas for a deployment.

    • kubectl delete deployment <deployment-name>: Delete a deployment and all its associated resources.

  3. Pod Management:

    • kubectl get pods: List all pods in the cluster.

    • kubectl describe pod <pod-name>: Get detailed information about a specific pod.

    • kubectl logs <pod-name>: View the logs of a specific pod.

    • kubectl exec -it <pod-name> -- <command>: Execute a command inside a pod.

    • kubectl delete pod <pod-name>: Delete a pod.

  4. Service Management:

    • kubectl get services: List all services in the cluster.

    • kubectl describe service <service-name>: Get detailed information about a specific service.

    • kubectl expose deployment <deployment-name> --port=<port> --target-port=<target-port> --type=<service-type>: Expose a deployment as a service.

    • kubectl delete service <service-name>: Delete a service.

These are just a few examples of commonly used commands in Kubernetes. There are many more commands and options available depending on your specific use cases and requirements.

More from this blog

Learn with Nikita Jadhav

40 posts