What are other kubectl flags?

Here are some commonly used kubectl flags:

  1. -f or --filename: Specifies the file or directory containing the resource definitions to apply.

    kubectl apply -f my-deployment.yaml
  2. -o or --output: Defines the output format. Common formats include json, yaml, wide, and name.

    kubectl get pods -o json
  3. --namespace: Similar to -n, it specifies the namespace for the command.

    kubectl get services --namespace=my-namespace
  4. --kubeconfig: Specifies the path to the kubeconfig file to use for the command.

    kubectl get pods --kubeconfig=/path/to/kubeconfig
  5. --context: Specifies the context to use from the kubeconfig file.

    kubectl config use-context my-context
  6. --dry-run: Simulates the command without making any changes. Useful for testing.

    kubectl apply -f my-deployment.yaml --dry-run=client
  7. -l or --label-selector: Filters resources based on labels.

    kubectl get pods -l app=my-app
  8. --all-namespaces: Lists resources across all namespaces.

    kubectl get pods --all-namespaces

These flags can be combined to tailor the kubectl command to your specific needs.

0 Comments

no data
Be the first to share your comment!