kubeswitch
kubeswitch copied to clipboard
Custom Store from CLI Command
It would be cool to have a custom store based on a custom command. One could set the backend like so:
kind: SwitchConfig
version: "v1alpha1"
kubeconfigStores:
- kind: custom
id: id-only-required-if-there-are-more-than-one-store
config:
command: custom-command
env:
KEY: value
The config contains a command
- the command to run - as well as an optional map of environment variables for the command context.
Under the hood, the command should implement a specific interface:
- list: outputs a json object of all clusters. There is a
clusters
key that has a list of cluster objects, with aname
that can be displayed in the ui and anid
that is the internal cluster id.{ "clusters": [ {"name": "test": "id": "some-id"} ] }
- kubeconfig: Takes an
id
and writes a kubeconfig to stdout.
With these two, we'd create a custom store that calls the list
command in StartSearch
, and then again when returning a kubeconfig in GetKubeconfigForPath
.
The KubeConfig would then be written to a path like custom_${id}-${name-slug}
.
I am not sure how expired KubeConfigs might work - is there some tracking for that? - but this would provide folks the ability to customize where their KubeConfig comes from in the case of custom tooling.
Is this something you'd be interested in taking a pull request for?
Hi, sorry for the delay. Yes, I would very much be interested in taking a pull request for that.