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

@ -17,7 +17,6 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
var ( var (
tillerImg string tillerImg string
tillerNamespace string
clientOnly bool clientOnly bool
initSkipNamespace bool initSkipNamespace bool
defaultRepository = "kubernetes-charts" defaultRepository = "kubernetes-charts"
@ -29,7 +28,6 @@ func init() {
f.StringVarP(&tillerImg, "tiller-image", "i", "", "override tiller image") f.StringVarP(&tillerImg, "tiller-image", "i", "", "override tiller image")
f.BoolVarP(&clientOnly, "client-only", "c", false, "If set does not install tiller") 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.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) RootCommand.AddCommand(initCmd)
} }

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

Loading…
Cancel
Save