fix(tunnel): allow tunneling to non-default namespace

pull/852/head
Adam Reese 8 years ago
parent 46501db528
commit 47398de71c

@ -17,8 +17,11 @@ const (
hostEnvVar = "HELM_HOST"
)
var helmHome string
var tillerHost string
var (
helmHome string
tillerHost string
tillerNamespace string
)
// flagDebug is a signal that the user wants additional output.
var flagDebug bool
@ -61,6 +64,7 @@ func init() {
p := RootCommand.PersistentFlags()
p.StringVar(&helmHome, "home", home, "location of your Helm config. Overrides $HELM_HOME.")
p.StringVar(&tillerHost, "host", thost, "address of tiller. Overrides $HELM_HOST.")
p.StringVarP(&tillerNamespace, "namespace", "n", "", "kubernetes namespace")
p.BoolVarP(&flagDebug, "debug", "", false, "enable verbose output")
}
@ -72,8 +76,7 @@ func main() {
func setupConnection(c *cobra.Command, args []string) error {
if tillerHost == "" {
// Should failure fall back to default host?
tunnel, err := newTillerPortForwarder()
tunnel, err := newTillerPortForwarder(tillerNamespace)
if err != nil {
return err
}

@ -17,7 +17,6 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
var (
tillerImg string
tillerNamespace string
clientOnly bool
initSkipNamespace bool
defaultRepository = "kubernetes-charts"
@ -29,7 +28,6 @@ func init() {
f.StringVarP(&tillerImg, "tiller-image", "i", "", "override tiller image")
f.BoolVarP(&clientOnly, "client-only", "c", false, "If set does not install tiller")
f.BoolVarP(&initSkipNamespace, "skip-namespace", "s", false, "Do not attempt to create a namespace. Assume the namespace is already there.")
f.StringVarP(&tillerNamespace, "namespace", "n", "helm", "set the tiller namespace")
RootCommand.AddCommand(initCmd)
}

@ -12,14 +12,14 @@ import (
// TODO refactor out this global var
var tunnel *kube.Tunnel
func newTillerPortForwarder() (*kube.Tunnel, error) {
podName, err := getTillerPodName("helm")
func newTillerPortForwarder(namespace string) (*kube.Tunnel, error) {
podName, err := getTillerPodName(namespace)
if err != nil {
return nil, err
}
// FIXME use a constain that is accessible on init
const tillerPort = 44134
return kube.New(nil).ForwardPort("helm", podName, tillerPort)
return kube.New(nil).ForwardPort(namespace, podName, tillerPort)
}
func getTillerPodName(namespace string) (string, error) {

Loading…
Cancel
Save