feat(helm): Add the --kubeconfig flag (#4235)

Adds the ability to specify a kubeconfig file that overrides $KUBECONFIG
pull/4379/head
Rohan Chakravarthy 7 years ago committed by Matt Butcher
parent 01da56f956
commit 4efa18a5ec

@ -169,7 +169,7 @@ func markDeprecated(cmd *cobra.Command, notice string) *cobra.Command {
func setupConnection() error {
if settings.TillerHost == "" {
config, client, err := getKubeClient(settings.KubeContext)
config, client, err := getKubeClient(settings.KubeContext, settings.KubeConfig)
if err != nil {
return err
}
@ -223,8 +223,8 @@ func prettyError(err error) error {
}
// configForContext creates a Kubernetes REST client configuration for a given kubeconfig context.
func configForContext(context string) (*rest.Config, error) {
config, err := kube.GetConfig(context).ClientConfig()
func configForContext(context string, kubeconfig string) (*rest.Config, error) {
config, err := kube.GetConfig(context, kubeconfig).ClientConfig()
if err != nil {
return nil, fmt.Errorf("could not get Kubernetes config for context %q: %s", context, err)
}
@ -232,8 +232,8 @@ func configForContext(context string) (*rest.Config, error) {
}
// getKubeClient creates a Kubernetes config and client for a given kubeconfig context.
func getKubeClient(context string) (*rest.Config, kubernetes.Interface, error) {
config, err := configForContext(context)
func getKubeClient(context string, kubeconfig string) (*rest.Config, kubernetes.Interface, error) {
config, err := configForContext(context, kubeconfig)
if err != nil {
return nil, nil, err
}
@ -247,8 +247,8 @@ func getKubeClient(context string) (*rest.Config, kubernetes.Interface, error) {
// getInternalKubeClient creates a Kubernetes config and an "internal" client for a given kubeconfig context.
//
// Prefer the similar getKubeClient if you don't need to use such an internal client.
func getInternalKubeClient(context string) (internalclientset.Interface, error) {
config, err := configForContext(context)
func getInternalKubeClient(context string, kubeconfig string) (internalclientset.Interface, error) {
config, err := configForContext(context, kubeconfig)
if err != nil {
return nil, err
}

@ -289,7 +289,7 @@ func (i *initCmd) run() error {
if !i.clientOnly {
if i.kubeClient == nil {
_, c, err := getKubeClient(settings.KubeContext)
_, c, err := getKubeClient(settings.KubeContext, settings.KubeConfig)
if err != nil {
return fmt.Errorf("could not get kubernetes client: %s", err)
}
@ -332,7 +332,7 @@ func (i *initCmd) run() error {
func (i *initCmd) ping() error {
if i.wait {
_, kubeClient, err := getKubeClient(settings.KubeContext)
_, kubeClient, err := getKubeClient(settings.KubeContext, settings.KubeConfig)
if err != nil {
return err
}

@ -491,7 +491,7 @@ func generateName(nameTemplate string) (string, error) {
}
func defaultNamespace() string {
if ns, _, err := kube.GetConfig(settings.KubeContext).Namespace(); err == nil {
if ns, _, err := kube.GetConfig(settings.KubeContext, settings.KubeConfig).Namespace(); err == nil {
return ns
}
return "default"

@ -86,7 +86,7 @@ func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
// runReset uninstalls tiller from Kubernetes Cluster and deletes local config
func (d *resetCmd) run() error {
if d.kubeClient == nil {
c, err := getInternalKubeClient(settings.KubeContext)
c, err := getInternalKubeClient(settings.KubeContext, settings.KubeConfig)
if err != nil {
return fmt.Errorf("could not get kubernetes client: %s", err)
}

@ -76,7 +76,10 @@ func newVersionCmd(c helm.Interface, out io.Writer) *cobra.Command {
if version.showServer {
// We do this manually instead of in PreRun because we only
// need a tunnel if server version is requested.
setupConnection()
err := setupConnection()
if err != nil {
return err
}
}
version.client = ensureHelmClient(version.client)
return version.run()
@ -115,7 +118,6 @@ func (v *versionCmd) run() error {
}
fmt.Fprintf(v.out, "Kubernetes: %#v\n", k8sVersion)
}
resp, err := v.client.GetVersion()
if err != nil {
if grpc.Code(err) == codes.Unimplemented {
@ -135,7 +137,7 @@ func (v *versionCmd) run() error {
func getK8sVersion() (*apiVersion.Info, error) {
var v *apiVersion.Info
_, client, err := getKubeClient(settings.KubeContext)
_, client, err := getKubeClient(settings.KubeContext, settings.KubeConfig)
if err != nil {
return v, err
}

@ -36,6 +36,7 @@ Environment:
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -68,4 +69,4 @@ Environment:
* [helm verify](helm_verify.md) - verify that a chart at the given path has been signed and is valid
* [helm version](helm_version.md) - print the client/server version information
###### Auto generated by spf13/cobra on 14-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -28,6 +28,7 @@ helm completion SHELL
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -35,4 +36,4 @@ helm completion SHELL
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -47,6 +47,7 @@ helm create NAME
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -54,4 +55,4 @@ helm create NAME
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -39,6 +39,7 @@ helm delete [flags] RELEASE_NAME [...]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -46,4 +47,4 @@ helm delete [flags] RELEASE_NAME [...]
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 13-Apr-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -61,6 +61,7 @@ for this case.
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -71,4 +72,4 @@ for this case.
* [helm dependency list](helm_dependency_list.md) - list the dependencies for the given chart
* [helm dependency update](helm_dependency_update.md) - update charts/ based on the contents of requirements.yaml
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -34,6 +34,7 @@ helm dependency build [flags] CHART
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -41,4 +42,4 @@ helm dependency build [flags] CHART
### SEE ALSO
* [helm dependency](helm_dependency.md) - manage a chart's dependencies
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -26,6 +26,7 @@ helm dependency list [flags] CHART
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -33,4 +34,4 @@ helm dependency list [flags] CHART
### SEE ALSO
* [helm dependency](helm_dependency.md) - manage a chart's dependencies
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -39,6 +39,7 @@ helm dependency update [flags] CHART
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -46,4 +47,4 @@ helm dependency update [flags] CHART
### SEE ALSO
* [helm dependency](helm_dependency.md) - manage a chart's dependencies
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -50,9 +50,12 @@ helm fetch [flags] [chart URL | repo/chartname] [...]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -40,6 +40,7 @@ helm get [flags] RELEASE_NAME
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -50,4 +51,4 @@ helm get [flags] RELEASE_NAME
* [helm get manifest](helm_get_manifest.md) - download the manifest for a named release
* [helm get values](helm_get_values.md) - download the values file for a named release
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -33,6 +33,7 @@ helm get hooks [flags] RELEASE_NAME
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -40,4 +41,4 @@ helm get hooks [flags] RELEASE_NAME
### SEE ALSO
* [helm get](helm_get.md) - download a named release
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -35,6 +35,7 @@ helm get manifest [flags] RELEASE_NAME
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -42,4 +43,4 @@ helm get manifest [flags] RELEASE_NAME
### SEE ALSO
* [helm get](helm_get.md) - download a named release
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -32,6 +32,7 @@ helm get values [flags] RELEASE_NAME
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -39,4 +40,4 @@ helm get values [flags] RELEASE_NAME
### SEE ALSO
* [helm get](helm_get.md) - download a named release
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -45,6 +45,7 @@ helm history [flags] RELEASE_NAME
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -52,4 +53,4 @@ helm history [flags] RELEASE_NAME
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 14-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -21,6 +21,7 @@ helm home
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -28,4 +29,4 @@ helm home
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -64,6 +64,7 @@ helm init
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -71,4 +72,4 @@ helm init
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -37,6 +37,7 @@ helm inspect [CHART]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -47,4 +48,4 @@ helm inspect [CHART]
* [helm inspect readme](helm_inspect_readme.md) - shows inspect readme
* [helm inspect values](helm_inspect_values.md) - shows inspect values
###### Auto generated by spf13/cobra on 14-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -35,6 +35,7 @@ helm inspect chart [CHART]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -42,4 +43,4 @@ helm inspect chart [CHART]
### SEE ALSO
* [helm inspect](helm_inspect.md) - inspect a chart
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -33,6 +33,7 @@ helm inspect readme [CHART]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -40,4 +41,4 @@ helm inspect readme [CHART]
### SEE ALSO
* [helm inspect](helm_inspect.md) - inspect a chart
###### Auto generated by spf13/cobra on 14-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -35,6 +35,7 @@ helm inspect values [CHART]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -42,4 +43,4 @@ helm inspect values [CHART]
### SEE ALSO
* [helm inspect](helm_inspect.md) - inspect a chart
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -112,6 +112,7 @@ helm install [CHART]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -119,4 +120,4 @@ helm install [CHART]
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 5-Jun-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -35,6 +35,7 @@ helm lint [flags] PATH
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -42,4 +43,4 @@ helm lint [flags] PATH
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 20-May-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -67,6 +67,7 @@ helm list [flags] [FILTER]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -74,4 +75,4 @@ helm list [flags] [FILTER]
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 17-Apr-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -40,6 +40,7 @@ helm package [flags] [CHART_PATH] [...]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -47,4 +48,4 @@ helm package [flags] [CHART_PATH] [...]
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 16-Apr-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -16,6 +16,7 @@ Manage client-side Helm plugins.
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -27,4 +28,4 @@ Manage client-side Helm plugins.
* [helm plugin remove](helm_plugin_remove.md) - remove one or more Helm plugins
* [helm plugin update](helm_plugin_update.md) - update one or more Helm plugins
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -29,6 +29,7 @@ helm plugin install [options] <path|url>...
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -36,4 +37,4 @@ helm plugin install [options] <path|url>...
### SEE ALSO
* [helm plugin](helm_plugin.md) - add, list, or remove Helm plugins
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -18,6 +18,7 @@ helm plugin list
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -25,4 +26,4 @@ helm plugin list
### SEE ALSO
* [helm plugin](helm_plugin.md) - add, list, or remove Helm plugins
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -18,6 +18,7 @@ helm plugin remove <plugin>...
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -25,4 +26,4 @@ helm plugin remove <plugin>...
### SEE ALSO
* [helm plugin](helm_plugin.md) - add, list, or remove Helm plugins
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -18,6 +18,7 @@ helm plugin update <plugin>...
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -25,4 +26,4 @@ helm plugin update <plugin>...
### SEE ALSO
* [helm plugin](helm_plugin.md) - add, list, or remove Helm plugins
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -20,6 +20,7 @@ Example usage:
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -32,4 +33,4 @@ Example usage:
* [helm repo remove](helm_repo_remove.md) - remove a chart repository
* [helm repo update](helm_repo_update.md) - update information of available charts locally from chart repositories
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -29,6 +29,7 @@ helm repo add [flags] [NAME] [URL]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -36,4 +37,4 @@ helm repo add [flags] [NAME] [URL]
### SEE ALSO
* [helm repo](helm_repo.md) - add, list, remove, update, and index chart repositories
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -34,6 +34,7 @@ helm repo index [flags] [DIR]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -41,4 +42,4 @@ helm repo index [flags] [DIR]
### SEE ALSO
* [helm repo](helm_repo.md) - add, list, remove, update, and index chart repositories
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -18,6 +18,7 @@ helm repo list [flags]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -25,4 +26,4 @@ helm repo list [flags]
### SEE ALSO
* [helm repo](helm_repo.md) - add, list, remove, update, and index chart repositories
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -18,6 +18,7 @@ helm repo remove [flags] [NAME]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -25,4 +26,4 @@ helm repo remove [flags] [NAME]
### SEE ALSO
* [helm repo](helm_repo.md) - add, list, remove, update, and index chart repositories
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -24,6 +24,7 @@ helm repo update
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -31,4 +32,4 @@ helm repo update
### SEE ALSO
* [helm repo](helm_repo.md) - add, list, remove, update, and index chart repositories
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -34,6 +34,7 @@ helm reset
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -41,4 +42,4 @@ helm reset
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -41,6 +41,7 @@ helm rollback [flags] [RELEASE] [REVISION]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -48,4 +49,4 @@ helm rollback [flags] [RELEASE] [REVISION]
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 13-Apr-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -32,6 +32,7 @@ helm search [keyword]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -39,4 +40,4 @@ helm search [keyword]
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 23-Apr-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -39,6 +39,7 @@ helm serve
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -46,4 +47,4 @@ helm serve
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -39,6 +39,7 @@ helm status [flags] RELEASE_NAME
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -46,4 +47,4 @@ helm status [flags] RELEASE_NAME
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -45,6 +45,7 @@ helm template [flags] CHART
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -52,4 +53,4 @@ helm template [flags] CHART
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 22-May-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -35,6 +35,7 @@ helm test [RELEASE]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -42,4 +43,4 @@ helm test [RELEASE]
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -75,6 +75,7 @@ helm upgrade [RELEASE] [CHART]
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -82,4 +83,4 @@ helm upgrade [RELEASE] [CHART]
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 4-Apr-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -33,6 +33,7 @@ helm verify [flags] PATH
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -40,4 +41,4 @@ helm verify [flags] PATH
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -48,6 +48,7 @@ helm version
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--kubeconfig string absolute path to the kubeconfig file to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
@ -55,4 +56,4 @@ helm version
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 8-Mar-2018
###### Auto generated by spf13/cobra on 17-Jun-2018

@ -49,6 +49,8 @@ type EnvSettings struct {
Debug bool
// KubeContext is the name of the kubeconfig context.
KubeContext string
// KubeConfig is the path to an explicit kubeconfig file. This overwrites the value in $KUBECONFIG
KubeConfig string
}
// AddFlags binds flags to the given flagset.
@ -56,6 +58,7 @@ func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
fs.StringVar((*string)(&s.Home), "home", DefaultHelmHome, "location of your Helm config. Overrides $HELM_HOME")
fs.StringVar(&s.TillerHost, "host", "", "address of Tiller. Overrides $HELM_HOST")
fs.StringVar(&s.KubeContext, "kube-context", "", "name of the kubeconfig context to use")
fs.StringVar(&s.KubeConfig, "kubeconfig", "", "absolute path to the kubeconfig file to use")
fs.BoolVar(&s.Debug, "debug", false, "enable verbose output")
fs.StringVar(&s.TillerNamespace, "tiller-namespace", "kube-system", "namespace of Tiller")
fs.Int64Var(&s.TillerConnectionTimeout, "tiller-connection-timeout", int64(300), "the duration (in seconds) Helm will wait to establish a connection to tiller")

@ -35,8 +35,8 @@ func TestEnvSettings(t *testing.T) {
envars map[string]string
// expected values
home, host, ns, kcontext, plugins string
debug bool
home, host, ns, kcontext, kconfig, plugins string
debug bool
}{
{
name: "defaults",
@ -47,11 +47,12 @@ func TestEnvSettings(t *testing.T) {
},
{
name: "with flags set",
args: []string{"--home", "/foo", "--host=here", "--debug", "--tiller-namespace=myns"},
args: []string{"--home", "/foo", "--host=here", "--debug", "--tiller-namespace=myns", "--kubeconfig", "/bar"},
home: "/foo",
plugins: helmpath.Home("/foo").Plugins(),
host: "here",
ns: "myns",
kconfig: "/bar",
debug: true,
},
{
@ -111,6 +112,9 @@ func TestEnvSettings(t *testing.T) {
if settings.KubeContext != tt.kcontext {
t.Errorf("expected kube-context %q, got %q", tt.kcontext, settings.KubeContext)
}
if settings.KubeConfig != tt.kconfig {
t.Errorf("expected kubeconfig %q, got %q", tt.kconfig, settings.KubeConfig)
}
cleanup()
})

@ -16,10 +16,12 @@ limitations under the License.
package kube // import "k8s.io/helm/pkg/kube"
import "k8s.io/client-go/tools/clientcmd"
import (
"k8s.io/client-go/tools/clientcmd"
)
// GetConfig returns a Kubernetes client config for a given context.
func GetConfig(context string) clientcmd.ClientConfig {
func GetConfig(context string, kubeconfig string) clientcmd.ClientConfig {
rules := clientcmd.NewDefaultClientConfigLoadingRules()
rules.DefaultClientConfig = &clientcmd.DefaultClientConfig
@ -28,5 +30,10 @@ func GetConfig(context string) clientcmd.ClientConfig {
if context != "" {
overrides.CurrentContext = context
}
if kubeconfig != "" {
rules.ExplicitPath = kubeconfig
}
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, overrides)
}

Loading…
Cancel
Save