feat(helm): allow user to specify namespace

pull/660/head
Matt Butcher 9 years ago
parent 9d78c33b69
commit 37cf3eab92

@ -11,6 +11,9 @@ import (
var stdout = os.Stdout
var helmHome string
// flagVerbose is a signal that the user wants additional output.
var flagVerbose bool
var globalUsage = `The Kubernetes package manager
To begin working with Helm, run the 'helm init' command:
@ -41,6 +44,7 @@ var RootCommand = &cobra.Command{
func init() {
RootCommand.PersistentFlags().StringVar(&helmHome, "home", "$HOME/.helm", "location of you Helm files [$HELM_HOME]")
RootCommand.PersistentFlags().BoolVarP(&flagVerbose, "verbose", "v", false, "enable verbose output")
}
func main() {

@ -15,13 +15,15 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
`
var (
tillerImg string
clientOnly bool
tillerImg string
clientOnly bool
tillerNamespace string
)
func init() {
initCmd.Flags().StringVarP(&tillerImg, "tiller-image", "i", "", "override tiller image")
initCmd.Flags().BoolVarP(&clientOnly, "client-only", "c", false, "If set does not install tiller")
initCmd.Flags().StringVarP(&tillerNamespace, "namespace", "n", "helm", "set the tiller namespace")
RootCommand.AddCommand(initCmd)
}
@ -57,7 +59,8 @@ func runInit(cmd *cobra.Command, args []string) error {
func installTiller() error {
i := client.NewInstaller()
i.Tiller["Image"] = tillerImg
err := i.Install()
i.Tiller["Namespace"] = tillerNamespace
err := i.Install(flagVerbose)
if err != nil {
return fmt.Errorf("error installing: %s", err)

@ -2,6 +2,7 @@ package client
import (
"bytes"
"fmt"
"text/template"
"github.com/Masterminds/sprig"
@ -32,7 +33,7 @@ func NewInstaller() *Installer {
//
// Returns the string output received from the operation, and an error if the
// command failed.
func (i *Installer) Install() error {
func (i *Installer) Install(verbose bool) error {
var b bytes.Buffer
err := template.Must(template.New("manifest").Funcs(sprig.TxtFuncMap()).
@ -43,19 +44,23 @@ func (i *Installer) Install() error {
return err
}
if verbose {
fmt.Println(b.String())
}
return kube.New(nil).Create("helm", &b)
}
// InstallYAML is the installation YAML for DM.
const InstallYAML = `
---
---{{$namespace := default "helm" .Tiller.Namespace}}
apiVersion: v1
kind: Namespace
metadata:
labels:
app: helm
name: helm-namespace
name: helm
name: {{$namespace}}
---
apiVersion: v1
kind: ReplicationController
@ -64,7 +69,7 @@ metadata:
app: helm
name: tiller
name: tiller-rc
namespace: helm
namespace: {{$namespace}}
spec:
replicas: 1
selector:

Loading…
Cancel
Save