ref(*): remove HELM_HOST

pull/3945/head
Adam Reese 7 years ago
parent fc4c095cf0
commit 358746fee6
No known key found for this signature in database
GPG Key ID: 06F35E60A7A18DD6

@ -42,8 +42,7 @@ To begin working with Helm, run the 'helm init' command:
$ helm init
This will install Tiller to your running Kubernetes cluster.
It will also set up any necessary local configuration.
This will set up any necessary local configuration.
Common actions from this point include:
@ -54,7 +53,6 @@ Common actions from this point include:
Environment:
$HELM_HOME set an alternative location for Helm files. By default, these are stored in ~/.helm
$HELM_HOST set an alternative Tiller host. The format is host:port
$HELM_NO_PLUGINS disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins.
$TILLER_NAMESPACE set an alternative Tiller namespace (default "kube-system")
$KUBECONFIG set an alternative Kubernetes configuration file (default "~/.kube/config")

@ -30,24 +30,7 @@ import (
)
const initDesc = `
This command installs Tiller (the Helm server-side component) onto your
Kubernetes Cluster and sets up local configuration in $HELM_HOME (default ~/.helm/).
As with the rest of the Helm commands, 'helm init' discovers Kubernetes clusters
by reading $KUBECONFIG (default '~/.kube/config') and using the default context.
To set up just a local environment, use '--client-only'. That will configure
$HELM_HOME, but not attempt to connect to a Kubernetes cluster and install the Tiller
deployment.
When installing Tiller, 'helm init' will attempt to install the latest released
version. You can specify an alternative image with '--tiller-image'. For those
frequently working on the latest code, the flag '--canary-image' will install
the latest pre-release version of Tiller (e.g. the HEAD commit in the GitHub
repository on the master branch).
To dump a manifest containing the Tiller deployment YAML, combine the
'--dry-run' and '--debug' flags.
This command sets up local configuration in $HELM_HOME (default ~/.helm/).
`
const (

@ -97,14 +97,6 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) {
DisableFlagParsing: true,
}
if md.UseTunnel {
c.PreRunE = func(cmd *cobra.Command, args []string) error {
// Parse the parent flag, but not the local flags.
_, err := processParent(cmd, args)
return err
}
}
// TODO: Make sure a command with this name does not already exist.
baseCmd.AddCommand(c)
}
@ -116,7 +108,7 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) {
func manuallyProcessArgs(args []string) ([]string, []string) {
known := []string{}
unknown := []string{}
kvargs := []string{"--host", "--kube-context", "--home", "--tiller-namespace"}
kvargs := []string{"--kube-context", "--home", "--tiller-namespace"}
knownArg := func(a string) bool {
for _, pre := range kvargs {
if strings.HasPrefix(a, pre+"=") {
@ -129,7 +121,7 @@ func manuallyProcessArgs(args []string) ([]string, []string) {
switch a := args[i]; a {
case "--debug":
known = append(known, a)
case "--host", "--kube-context", "--home":
case "--kube-context", "--home":
known = append(known, a, args[i+1])
i++
default:

@ -47,7 +47,7 @@ func newPluginCmd(out io.Writer) *cobra.Command {
// runHook will execute a plugin hook.
func runHook(p *plugin.Plugin, event string) error {
hook := p.Metadata.Hooks.Get(event)
hook := p.Metadata.Hooks[event]
if hook == "" {
return nil
}

@ -33,7 +33,6 @@ func TestManuallyProcessArgs(t *testing.T) {
input := []string{
"--debug",
"--foo", "bar",
"--host", "example.com",
"--kube-context", "test1",
"--home=/tmp",
"--tiller-namespace=hello",
@ -41,7 +40,7 @@ func TestManuallyProcessArgs(t *testing.T) {
}
expectKnown := []string{
"--debug", "--host", "example.com", "--kube-context", "test1", "--home=/tmp", "--tiller-namespace=hello",
"--debug", "--kube-context", "test1", "--home=/tmp", "--tiller-namespace=hello",
}
expectUnknown := []string{
@ -177,7 +176,6 @@ func TestSetupEnv(t *testing.T) {
{"HELM_PATH_CACHE", settings.Home.Cache()},
{"HELM_PATH_LOCAL_REPOSITORY", settings.Home.LocalRepository()},
{"HELM_PATH_STARTER", settings.Home.Starters()},
{"TILLER_HOST", settings.TillerHost},
{"TILLER_NAMESPACE", settings.TillerNamespace},
} {
if got := os.Getenv(tt.name); got != tt.expect {

@ -44,7 +44,6 @@ func TestVersion(t *testing.T) {
expected: lver,
},
}
settings.TillerHost = "fake-localhost"
runReleaseCases(t, tests, func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newVersionCmd(out)
})

@ -332,8 +332,8 @@ in JSON format.
By default, `tiller` stores release information in `ConfigMaps` in the namespace
where it is running. As of Helm 2.7.0, there is now a beta storage backend that
uses `Secrets` for storing release information. This was added for additional
security in protecting charts in conjunction with the release of `Secret`
encryption in Kubernetes.
security in protecting charts in conjunction with the release of `Secret`
encryption in Kubernetes.
To enable the secrets backend, you'll need to init Tiller with the following
options:

@ -70,7 +70,6 @@ usage: "Integrate Keybase.io tools with Helm"
description: |-
This plugin provides Keybase services to Helm.
ignoreFlags: false
useTunnel: false
command: "$HELM_PLUGIN_DIR/keybase.sh"
```
@ -92,12 +91,6 @@ The `ignoreFlags` switch tells Helm to _not_ pass flags to the plugin. So if a
plugin is called with `helm myplugin --foo` and `ignoreFlags: true`, then `--foo`
is silently discarded.
The `useTunnel` switch indicates that the plugin needs a tunnel to Tiller. This
should be set to `true` _anytime a plugin talks to Tiller_. It will cause Helm
to open a tunnel, and then set `$TILLER_HOST` to the right local address for that
tunnel. But don't worry: if Helm detects that a tunnel is not necessary because
Tiller is running locally, it will not create the tunnel.
Finally, and most importantly, `command` is the command that this plugin will
execute when it is called. Environment variables are interpolated before the plugin
is executed. The pattern above illustrates the preferred way to indicate where
@ -162,29 +155,6 @@ The following variables are guaranteed to be set:
- `HELM_HOME`: The path to the Helm home.
- `HELM_PATH_*`: Paths to important Helm files and directories are stored in
environment variables prefixed by `HELM_PATH`.
- `TILLER_HOST`: The `domain:port` to Tiller. If a tunnel is created, this
will point to the local endpoint for the tunnel. Otherwise, it will point
to `$HELM_HOST`, `--host`, or the default host (according to Helm's rules of
precedence).
While `HELM_HOST` _may_ be set, there is no guarantee that it will point to the
correct Tiller instance. This is done to allow plugin developer to access
`HELM_HOST` in its raw state when the plugin itself needs to manually configure
a connection.
## A Note on `useTunnel`
If a plugin specifies `useTunnel: true`, Helm will do the following (in order):
1. Parse global flags and the environment
2. Create the tunnel
3. Set `TILLER_HOST`
4. Execute the plugin
5. Close the tunnel
The tunnel is removed as soon as the `command` returns. So, for example, a
command cannot background a process and assume that that process will be able
to use the tunnel.
## A Note on Flag Parsing
@ -193,9 +163,7 @@ these flags are _not_ passed on to the plugin.
- `--debug`: If this is specified, `$HELM_DEBUG` is set to `1`
- `--home`: This is converted to `$HELM_HOME`
- `--host`: This is converted to `$HELM_HOST`
- `--kube-context`: This is simply dropped. If your plugin uses `useTunnel`, this
is used to set up the tunnel for you.
- `--kube-context`: This is simply dropped.
Plugins _should_ display help text and then exit for `-h` and `--help`. In all
other cases, plugins may use flags as appropriate.

@ -28,6 +28,7 @@ import (
"github.com/spf13/pflag"
"k8s.io/client-go/util/homedir"
"k8s.io/helm/pkg/helm/helmpath"
)
@ -36,10 +37,6 @@ var DefaultHelmHome = filepath.Join(homedir.HomeDir(), ".helm")
// EnvSettings describes all of the environment settings.
type EnvSettings struct {
// TillerHost is the host and port of Tiller.
TillerHost string
// TillerConnectionTimeout is the duration (in seconds) helm will wait to establish a connection to tiller.
TillerConnectionTimeout int64
// TillerNamespace is the namespace in which Tiller runs.
TillerNamespace string
// Home is the local path to the Helm home directory.
@ -53,11 +50,9 @@ type EnvSettings struct {
// AddFlags binds flags to the given flagset.
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.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")
}
// Init sets values from the environment.
@ -79,7 +74,6 @@ func (s EnvSettings) PluginDirs() string {
var envMap = map[string]string{
"debug": "HELM_DEBUG",
"home": "HELM_HOME",
"host": "HELM_HOST",
"tiller-namespace": "TILLER_NAMESPACE",
}
@ -97,6 +91,5 @@ const (
HomeEnvVar = "HELM_HOME"
PluginEnvVar = "HELM_PLUGIN"
PluginDisableEnvVar = "HELM_NO_PLUGINS"
HostEnvVar = "HELM_HOST"
DebugEnvVar = "HELM_DEBUG"
)

@ -35,8 +35,8 @@ func TestEnvSettings(t *testing.T) {
envars map[string]string
// expected values
home, host, ns, kcontext, plugins string
debug bool
home, ns, kcontext, plugins string
debug bool
}{
{
name: "defaults",
@ -47,30 +47,27 @@ func TestEnvSettings(t *testing.T) {
},
{
name: "with flags set",
args: []string{"--home", "/foo", "--host=here", "--debug", "--tiller-namespace=myns"},
args: []string{"--home", "/foo", "--debug", "--tiller-namespace=myns"},
home: "/foo",
plugins: helmpath.Home("/foo").Plugins(),
host: "here",
ns: "myns",
debug: true,
},
{
name: "with envvars set",
args: []string{},
envars: map[string]string{"HELM_HOME": "/bar", "HELM_HOST": "there", "HELM_DEBUG": "1", "TILLER_NAMESPACE": "yourns"},
envars: map[string]string{"HELM_HOME": "/bar", "HELM_DEBUG": "1", "TILLER_NAMESPACE": "yourns"},
home: "/bar",
plugins: helmpath.Home("/bar").Plugins(),
host: "there",
ns: "yourns",
debug: true,
},
{
name: "with flags and envvars set",
args: []string{"--home", "/foo", "--host=here", "--debug", "--tiller-namespace=myns"},
envars: map[string]string{"HELM_HOME": "/bar", "HELM_HOST": "there", "HELM_DEBUG": "1", "TILLER_NAMESPACE": "yourns", "HELM_PLUGIN": "glade"},
args: []string{"--home", "/foo", "--debug", "--tiller-namespace=myns"},
envars: map[string]string{"HELM_HOME": "/bar", "HELM_DEBUG": "1", "TILLER_NAMESPACE": "yourns", "HELM_PLUGIN": "glade"},
home: "/foo",
plugins: "glade",
host: "here",
ns: "myns",
debug: true,
},
@ -99,9 +96,6 @@ func TestEnvSettings(t *testing.T) {
if settings.PluginDirs() != tt.plugins {
t.Errorf("expected plugins %q, got %q", tt.plugins, settings.PluginDirs())
}
if settings.TillerHost != tt.host {
t.Errorf("expected host %q, got %q", tt.host, settings.TillerHost)
}
if settings.Debug != tt.debug {
t.Errorf("expected debug %t, got %t", tt.debug, settings.Debug)
}

@ -33,8 +33,6 @@ type Option func(*options)
// options specify optional settings used by the helm client.
type options struct {
// value of helm home override
host string
// if set dry-run helm client calls
dryRun bool
// if set, re-use an existing name

@ -27,9 +27,3 @@ const (
// Hooks is a map of events to commands.
type Hooks map[string]string
// Get returns a hook for an event.
func (hooks Hooks) Get(event string) string {
h, _ := hooks[event]
return h
}

@ -71,11 +71,6 @@ type Metadata struct {
// the `--debug` flag will be discarded.
IgnoreFlags bool `json:"ignoreFlags"`
// UseTunnel indicates that this command needs a tunnel.
// Setting this will cause a number of side effects, such as the
// automatic setting of HELM_HOST.
UseTunnel bool `json:"useTunnel"`
// Hooks are commands that will run on events.
Hooks Hooks
@ -188,7 +183,6 @@ func SetupPluginEnv(settings helm_env.EnvSettings,
"HELM_PATH_LOCAL_REPOSITORY": settings.Home.LocalRepository(),
"HELM_PATH_STARTER": settings.Home.Starters(),
"TILLER_HOST": settings.TillerHost,
"TILLER_NAMESPACE": settings.TillerNamespace,
} {
os.Setenv(key, val)

@ -80,7 +80,6 @@ func TestLoadDir(t *testing.T) {
Usage: "usage",
Description: "description",
Command: "$HELM_PLUGIN_SELF/hello.sh",
UseTunnel: true,
IgnoreFlags: true,
Hooks: map[string]string{
Install: "echo installing...",

@ -4,7 +4,6 @@ usage: "usage"
description: |-
description
command: "$HELM_PLUGIN_SELF/hello.sh"
useTunnel: true
ignoreFlags: true
install: "echo installing..."
hooks:

Loading…
Cancel
Save