Add --kubeconfig option to tridentctl
Describe the solution you'd like
It would be useful to have an optional argument to specify the kubeconfig file to use, similar to kubectl --kubeconfig
Use case is when multiple ssh sessions are used on the same login to run tridentctl on different k8s clusters for example to cleanup/uninstall trident from a CI cleanup script.
Describe alternatives you've considered The tridentctl binary always uses the default kubectl context which is stored in $HOME/.kube/config and thus does not support mutliple ssh sessions operating on different clusters.
Additional context Example of usage:
$ tridentctl get volume --kubeconfig ~/.kube/config2 -n trident-operator
+------------------------------------------+--------+---------------+----------+--------------------------------------+--------+---------+
| NAME | SIZE | STORAGE CLASS | PROTOCOL | BACKEND UUID | STATE | MANAGED |
+------------------------------------------+--------+---------------+----------+--------------------------------------+--------+---------+
| pvc-14057e31-aeb0-4d41-80cd-d66e9cf19503 | 10 GiB | ontap-nas-hdd | file | b34aa240-dbe1-4b6c-b7ac-3d2ff97c6c89 | online | true |
| pvc-16e64ca9-0267-4674-80f9-71fcf549d02f | 10 GiB | ontap-nas-hdd | file | b34aa240-dbe1-4b6c-b7ac-3d2ff97c6c89 | online | true |
| pvc-2a88c8f0-c554-4463-a779-e8709723c9a6 | 50 GiB | ontap-nas-hdd | file | b34aa240-dbe1-4b6c-b7ac-3d2ff97c6c89 | online | true |
+------------------------------------------+--------+---------------+----------+--------------------------------------+--------+---------+
$ tridentctl get volume --kubeconfig ~/.kube/config -n trident-operator
+------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+
| NAME | SIZE | STORAGE CLASS | PROTOCOL | BACKEND UUID | STATE | MANAGED |
+------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+
| pvc-0fe8b18d-7158-43e5-b881-93b764afbecd | 1.0 GiB | ontap-nas-hdd | file | a9c18cfd-326a-46e9-9fd6-2928b6fe416c | online | true |
| pvc-16850d56-93a5-4f20-b907-5bb74fecffd0 | 5.0 GiB | ontap-nas-ssd | file | a9c18cfd-326a-46e9-9fd6-2928b6fe416c | online | true |
+------------------------------------------+---------+---------------+----------+--------------------------------------+--------+---------+
Thanks, @ahothan. This is on my personal wish list as well.
@ahothan - You could try to set the KUBECONFIG environment variable on the line with execution of the command as a workaround- depending on how it gets called.
e.g.
KUBECONFIG=path/to/kubeconfig tridentctl get backends -n trident
Not entirely sure it would solve it short term, but it is an option.
You're right @obassett - setting the KUBECONFIG env variable works. I will still submit a PR if there is interest to get tridenctl on par with kubectl and oc.