guessi / kubectl-grep

Filter Kubernetes resources by matching their names
Apache License 2.0
114 stars 8 forks source link

Question : How do I use contexts from kubeconfig using this project #42

Closed mailsanchu closed 1 year ago

mailsanchu commented 1 year ago

svarkey@svarkey-Precision-7760:~$ kubectl grep pods -l name=test --context cs-prod1 Error: unknown flag: --context Usage: kubectl-grep pods [flags]

Aliases: pods, po, pod

Flags: -h, --help help for pods -o, --output string Output format.

Global Flags: -A, --all-namespaces If present, list the requested object(s) across all namespaces. --field-selector string Selector (field query) to filter on. (e.g. --field-selector key1=value1,key2=value2) -n, --namespace string Namespace for search. (default: "default") -l, --selector string Selector (label query) to filter on. (e.g. -l key1=value1,key2=value2)

unknown flag: --context

guessi commented 1 year ago

Currently it does not support such flag.

As alternative solution, you can try KUBECONFIG=${path-to-config} kubectl grep ... instead.

Ref: https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/

mailsanchu commented 1 year ago

I do have contexts configured in KUBECONFIG. I need to use the following command to change the context I want kubectl config use-context && kubectl grep ...