Add kubeconfig flag for k8s plugin (#296)
This commit is contained in:
parent
f172d2b155
commit
22af927e77
3 changed files with 13 additions and 3 deletions
|
|
@ -8,6 +8,8 @@ this plugin is inpsired by the [first version kubernetes plugin](https://github.
|
|||
|
||||
Start plugin with flag `--all-namespaces` or environment variable `SSHPIPERD_KUBERNETES_ALL_NAMESPACES=true` for cluster-wide usage, or it will listen to the namespace where it is in by default.
|
||||
|
||||
Start plugin with flag `--kubeconfig` or environment variable `SSHPIPERD_KUBERNETES_KUBECONFIG=/path/to/kubeconfig` to specify the kubeconfig file.
|
||||
|
||||
### Helm
|
||||
|
||||
[](https://artifacthub.io/packages/helm/sshpiper/sshpiper)
|
||||
|
|
|
|||
|
|
@ -33,9 +33,11 @@ type plugin struct {
|
|||
cache *gocache.Cache
|
||||
}
|
||||
|
||||
func newKubernetesPlugin(allNamespaces bool) (*plugin, error) {
|
||||
func newKubernetesPlugin(allNamespaces bool, kubeConfigPath string) (*plugin, error) {
|
||||
loader := clientcmd.NewDefaultClientConfigLoadingRules()
|
||||
loader.ExplicitPath = kubeConfigPath
|
||||
kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
clientcmd.NewDefaultClientConfigLoadingRules(),
|
||||
loader,
|
||||
&clientcmd.ConfigOverrides{},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,15 @@ func main() {
|
|||
EnvVars: []string{"SSHPIPERD_KUBERNETES_ALL_NAMESPACES"},
|
||||
Required: false,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "kubeconfig",
|
||||
Usage: "Path to kubeconfig file",
|
||||
EnvVars: []string{"SSHPIPERD_KUBERNETES_KUBECONFIG", "KUBECONFIG"},
|
||||
Required: false,
|
||||
},
|
||||
},
|
||||
CreateConfig: func(c *cli.Context) (*libplugin.SshPiperPluginConfig, error) {
|
||||
plugin, err := newKubernetesPlugin(c.Bool("all-namespaces"))
|
||||
plugin, err := newKubernetesPlugin(c.Bool("all-namespaces"), c.String("kubeconfig"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue