Forrest logo
tool overview
On this page you find all important commands for the CLI tool kubectl. If the command you are looking for is missing please ask our AI.

kubectl

kubectl is a command line tool used for controlling Kubernetes clusters. It is the main interface through which users manage their Kubernetes resources. Created by Google, kubectl is an essential component in the Kubernetes ecosystem.

With kubectl, users can create, read, update, and delete various Kubernetes objects such as pods, deployments, services, and secrets. It allows administrators to manage clusters, namespaces, and configurations with ease.

Kubectl provides a powerful set of commands that enable users to interact with the Kubernetes API server. It supports imperative commands, which directly modify the desired state of resources, as well as declarative configuration with YAML files.

This tool offers various features to manage and monitor Kubernetes clusters efficiently. Users can view resource information, check status, and access logs for debugging purposes. It also allows scaling applications, rolling out updates, and managing network policies.

Kubectl provides extensive support for managing resources across multiple clusters, making it convenient for users overseeing complex deployments. It supports authentication, multi-tenancy, and RBAC (Role-Based Access Control) to ensure secure operations.

The tool integrates well with other Kubernetes components and ecosystem tools, such as kubeconfig for handling configuration files, kustomize for managing overlays, and kubectl plugins for extending functionality.

Kubectl is built for extensibility, with a plugin architecture that enables developers to add custom commands and features. This extensibility allows users to tailor kubectl to their specific requirements and integrate it with external tools or workflows.

The tool is actively developed and maintained by the Kubernetes community, ensuring frequent updates and bug fixes. It supports a wide range of platforms, including Linux, macOS, and Windows, making it accessible to users with diverse environments.

Kubectl documentation and tutorials are available online, providing comprehensive guidance on its usage and capabilities. Additionally, the Kubernetes community offers extensive support through forums and online communities, making it easier for users to get assistance if needed.

List of commands for kubectl:

  • kubectl-delete:tldr:06c73 kubectl-delete: Delete a specific pod.
    $ kubectl delete pod ${pod_name}
    try on your machine
    explain this command
  • kubectl-delete:tldr:18c8e kubectl-delete: Delete all nodes.
    $ kubectl delete nodes --all
    try on your machine
    explain this command
  • kubectl-delete:tldr:3445e kubectl-delete: Delete a specific node.
    $ kubectl delete node ${node_name}
    try on your machine
    explain this command
  • kubectl-delete:tldr:4b1c1 kubectl-delete: Delete all pods in a specified namespace.
    $ kubectl delete pods --all --namespace ${namespace}
    try on your machine
    explain this command
  • kubectl-delete:tldr:539ec kubectl-delete: Delete resources defined in a YAML manifest.
    $ kubectl delete --filename ${path-to-manifest-yaml}
    try on your machine
    explain this command
  • kubectl-delete:tldr:add32 kubectl-delete: Delete a specific deployment.
    $ kubectl delete deployment ${deployment_name}
    try on your machine
    explain this command
  • kubectl-delete:tldr:ff2b7 kubectl-delete: Delete all deployments and services in a specified namespace.
    $ kubectl delete deployments,services --all --namespace ${namespace}
    try on your machine
    explain this command
  • kubectl-describe:tldr:7207f kubectl-describe: Show details of Kubernetes objects defined in a YAML manifest.
    $ kubectl describe -f ${path-to-manifest-yaml}
    try on your machine
    explain this command
  • kubectl-describe:tldr:8beb0 kubectl-describe: Show details of pods in a namespace.
    $ kubectl describe pods -n ${namespace}
    try on your machine
    explain this command
  • kubectl-describe:tldr:bd141 kubectl-describe: Show details of nodes in a namespace.
    $ kubectl describe nodes -n ${namespace}
    try on your machine
    explain this command
  • kubectl-describe:tldr:c90a6 kubectl-describe: Show the details of a specific node in a namespace.
    $ kubectl describe nodes ${node_name} -n ${namespace}
    try on your machine
    explain this command
  • kubectl-describe:tldr:fc9e8 kubectl-describe: Show the details of a specific pod in a namespace.
    $ kubectl describe pods ${pod_name} -n ${namespace}
    try on your machine
    explain this command
  • kubectl-edit:tldr:211d3 kubectl-edit: Edit a resource in JSON format.
    $ kubectl edit ${resource}/${resource_name} --output json
    try on your machine
    explain this command
  • kubectl-edit:tldr:d979f kubectl-edit: Edit a pod.
    $ kubectl edit pod/${pod_name}
    try on your machine
    explain this command
  • kubectl-edit:tldr:e6703 kubectl-edit: Edit a service.
    $ kubectl edit svc/${service_name}
    try on your machine
    explain this command
  • kubectl-edit:tldr:ebad6 kubectl-edit: Edit a deployment.
    $ kubectl edit deployment/${deployment_name}
    try on your machine
    explain this command
  • kubectl-get:tldr:173b2 kubectl-get: Get deployments in a specified namespace.
    $ kubectl get deployments -n ${namespace}
    try on your machine
    explain this command
  • kubectl-get:tldr:4d08c kubectl-get: Get services in a specified namespace.
    $ kubectl get services -n ${namespace}
    try on your machine
    explain this command
  • kubectl-get:tldr:78a9f kubectl-get: Get pods in a specified namespace.
    $ kubectl get pods -n ${namespace}
    try on your machine
    explain this command
  • kubectl-get:tldr:877b9 kubectl-get: Get all resources in a specified namespace.
    $ kubectl get all -n ${namespace}
    try on your machine
    explain this command
  • kubectl-get:tldr:8f97f kubectl-get: Get all namespaces in the current cluster.
    $ kubectl get namespaces
    try on your machine
    explain this command
  • kubectl-get:tldr:ab6ae kubectl-get: Get nodes in a specified namespace.
    $ kubectl get nodes -n ${namespace}
    try on your machine
    explain this command
  • kubectl-get:tldr:d66df kubectl-get: Get Kubernetes objects defined in a YAML manifest.
    $ kubectl get -f ${path-to-manifest-yaml}
    try on your machine
    explain this command
  • kubectl-logs:tldr:1edd6 kubectl-logs: Show pod logs newer than a relative time like `10s`, `5m`, or `1h`.
    $ kubectl logs --since=${relative_time} ${pod_name}
    try on your machine
    explain this command
  • kubectl-logs:tldr:2a82b kubectl-logs: Show logs for all containers in a pod.
    $ kubectl logs --all-containers=${true} ${pod_name}
    try on your machine
    explain this command
  • kubectl-logs:tldr:3dc81 kubectl-logs: Show logs for a single-container pod.
    $ kubectl logs ${pod_name}
    try on your machine
    explain this command
  • kubectl-logs:tldr:5581e kubectl-logs: Stream pod logs.
    $ kubectl logs --follow ${pod_name}
    try on your machine
    explain this command
  • kubectl-logs:tldr:88770 kubectl-logs: Stream logs for a specified container in a pod.
    $ kubectl logs --follow --container ${container_name} ${pod_name}
    try on your machine
    explain this command
  • kubectl-logs:tldr:93c59 kubectl-logs: Show logs for a specified container in a pod.
    $ kubectl logs --container ${container_name} ${pod_name}
    try on your machine
    explain this command
  • kubectl-logs:tldr:d5506 kubectl-logs: Show the 10 most recent logs in a pod.
    $ kubectl logs --tail=${10} ${pod_name}
    try on your machine
    explain this command
  • kubectl-rollout:tldr:2147f kubectl-rollout: View the rollout history of a resource.
    $ kubectl rollout history ${resource_type}/${resource_name}
    try on your machine
    explain this command
  • kubectl-rollout:tldr:41a17 kubectl-rollout: Start a rolling restart of a resource.
    $ kubectl rollout restart ${resource_type}/${resource_name}
    try on your machine
    explain this command
  • kubectl-rollout:tldr:853ce kubectl-rollout: Watch the rolling update status of a resource.
    $ kubectl rollout status ${resource_type}/${resource_name}
    try on your machine
    explain this command
  • kubectl-rollout:tldr:c65e9 kubectl-rollout: Roll back a resource to the previous revision.
    $ kubectl rollout undo ${resource_type}/${resource_name}
    try on your machine
    explain this command
  • kubectl-run:tldr:2b385 kubectl-run: Run an nginx pod, setting the TEST_VAR environment variable.
    $ kubectl run --generator=run-pod/v1 nginx --image=nginx --env="TEST_VAR=testing"
    try on your machine
    explain this command
  • kubectl-run:tldr:884bd kubectl-run: Run an nginx pod and expose port 80.
    $ kubectl run --generator=run-pod/v1 nginx --image=nginx --port 80
    try on your machine
    explain this command
  • kubectl-run:tldr:8e44e kubectl-run: Show API calls that would be made to create an nginx container.
    $ kubectl run --generator=run-pod/v1 nginx --image=nginx --dry-run
    try on your machine
    explain this command
  • kubectl:tldr:09582 kubectl: List information about a resource with more details.
    $ kubectl get ${select} -o wide
    try on your machine
    explain this command
  • kubectl:tldr:1a134 kubectl: Update specified pod with the label 'unhealthy' and the value 'true'.
    $ kubectl label pods ${name} unhealthy=true
    try on your machine
    explain this command
  • kubectl:tldr:21733 kubectl: List all resources with different types.
    $ kubectl get all
    try on your machine
    explain this command
  • kubectl:tldr:7e05c kubectl: Print the address of the master and cluster services.
    $ kubectl cluster-info
    try on your machine
    explain this command
  • kubectl:tldr:c72ce kubectl: Display resource (CPU/Memory/Storage) usage of nodes or pods.
    $ kubectl top ${select}
    try on your machine
    explain this command
  • kubectl:tldr:f7373 kubectl: Display an explanation of a specific field.
    $ kubectl explain ${pods-spec-containers}
    try on your machine
    explain this command
  • kubernetes:warp:27402 Mark node as schedulable
    $ kubectl uncordon ${node}
    try on your machine
    explain this command
  • kubernetes:warp:28e25 List events for a single Kubernetes pod
    $ kubectl get event --namespace ${namespace} --field-selector involvedObject.name=${pod_name}
    try on your machine
    explain this command
  • kubernetes:warp:3b6af Set a new size for a deployment.
    $ kubectl scale deployment/${deployment_name} --replicas=${count}
    try on your machine
    explain this command
  • kubernetes:warp:523ac Run a Bash command within a Kubernetes pod
    $ kubectl exec -it --namespace=${namespace} ${pod_name} -- bash -c "${bash_command}"
    try on your machine
    explain this command
  • kubernetes:warp:61f04 Forward one or more local ports to a pod.
    $ kubectl port-forward pod/${pod_name} ${local_port}:${pod_port}
    try on your machine
    explain this command
  • kubernetes:warp:7cf9f Show a continuous stream of Kubernetes logs
    $ kubectl logs -f ${pod_id}
    try on your machine
    explain this command
  • kubernetes:warp:8c686 Mark node as unschedulable
    $ kubectl cordon ${node}
    try on your machine
    explain this command
  • kubernetes:warp:8f804 Opens a Bash shell into Kubernetes pod
    $ kubectl -n ${namespace} exec -it ${pod_name} -- /bin/sh
    try on your machine
    explain this command
  • kubernetes:warp:c897a Report when a Kubernetes job has finished
    $ kubectl wait --for=condition=complete job/${job_name}
    try on your machine
    explain this command
  • kubernetes:warp:e5221 Rollback to the previous deployment
    $ kubectl rollout undo deployment/${deployment_name}
    try on your machine
    explain this command
  • kubernetes:warp:ef853 Sort Kubernetes pods by age
    $ kubectl get po --sort-by=.status.startTime
    try on your machine
    explain this command
  • kubernetes:warp:ff75c Forward one or more local ports of a service
    $ kubectl port-forward svc/${service_name} ${local_port}:${service_port}
    try on your machine
    explain this command
tool overview