Skip to content

Commit

Permalink
feat(helm): add service account flag to helm init
Browse files Browse the repository at this point in the history
helps with half of helm#2224
  • Loading branch information
Michelle Noorali committed May 1, 2017
1 parent 1230074 commit 084b8ca
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
25 changes: 14 additions & 11 deletions cmd/helm/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ var (
)

type initCmd struct {
image string
clientOnly bool
canary bool
upgrade bool
namespace string
dryRun bool
skipRefresh bool
out io.Writer
home helmpath.Home
opts installer.Options
kubeClient internalclientset.Interface
image string
clientOnly bool
canary bool
upgrade bool
namespace string
dryRun bool
skipRefresh bool
out io.Writer
home helmpath.Home
opts installer.Options
kubeClient internalclientset.Interface
serviceAccount string
}

func newInitCmd(out io.Writer) *cobra.Command {
Expand Down Expand Up @@ -116,6 +117,7 @@ func newInitCmd(out io.Writer) *cobra.Command {
f.StringVar(&localRepositoryURL, "local-repo-url", localRepositoryURL, "URL for local repository")

f.BoolVar(&i.opts.EnableHostNetwork, "net-host", false, "install tiller with net=host")
f.StringVar(&i.serviceAccount, "service-account", "", "name of service account")

return cmd
}
Expand Down Expand Up @@ -154,6 +156,7 @@ func (i *initCmd) run() error {
i.opts.Namespace = i.namespace
i.opts.UseCanary = i.canary
i.opts.ImageSpec = i.image
i.opts.ServiceAccount = i.serviceAccount

if settings.Debug {
writeYAMLManifest := func(apiVersion, kind, body string, first, last bool) error {
Expand Down
1 change: 1 addition & 0 deletions cmd/helm/installer/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func generateDeployment(opts *Options) *extensions.Deployment {
Labels: labels,
},
Spec: api.PodSpec{
ServiceAccountName: opts.ServiceAccount,
Containers: []api.Container{
{
Name: "tiller",
Expand Down
3 changes: 3 additions & 0 deletions cmd/helm/installer/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type Options struct {
// Namespace is the kubernetes namespace to use to deploy tiller.
Namespace string

// ServiceAccount is the Kubernetes service account to add to tiller
ServiceAccount string

// ImageSpec indentifies the image tiller will use when deployed.
//
// Valid if and only if UseCanary is false.
Expand Down
3 changes: 2 additions & 1 deletion docs/helm/helm_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ helm init
--dry-run do not install local or remote
--local-repo-url string URL for local repository (default "http://127.0.0.1:8879/charts")
--net-host install tiller with net=host
--service-account string name of service account
--skip-refresh do not refresh (download) the local repository cache
--stable-repo-url string URL for stable repository (default "https://kubernetes-charts.storage.googleapis.com")
-i, --tiller-image string override tiller image
Expand All @@ -62,4 +63,4 @@ helm init
### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes.

###### Auto generated by spf13/cobra on 18-Apr-2017
###### Auto generated by spf13/cobra on 1-May-2017
8 changes: 6 additions & 2 deletions docs/man/man1/helm_init.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "HELM" "1" "Apr 2017" "Auto generated by spf13/cobra" ""
.TH "HELM" "1" "May 2017" "Auto generated by spf13/cobra" ""
.nh
.ad l

Expand Down Expand Up @@ -61,6 +61,10 @@ To dump a manifest containing the Tiller deployment YAML, combine the
\fB\-\-net\-host\fP[=false]
install tiller with net=host

.PP
\fB\-\-service\-account\fP=""
name of service account

.PP
\fB\-\-skip\-refresh\fP[=false]
do not refresh (download) the local repository cache
Expand Down Expand Up @@ -128,4 +132,4 @@ To dump a manifest containing the Tiller deployment YAML, combine the

.SH HISTORY
.PP
18\-Apr\-2017 Auto generated by spf13/cobra
1\-May\-2017 Auto generated by spf13/cobra
2 changes: 2 additions & 0 deletions scripts/completions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,8 @@ _helm_init()
local_nonpersistent_flags+=("--local-repo-url=")
flags+=("--net-host")
local_nonpersistent_flags+=("--net-host")
flags+=("--service-account=")
local_nonpersistent_flags+=("--service-account=")
flags+=("--skip-refresh")
local_nonpersistent_flags+=("--skip-refresh")
flags+=("--stable-repo-url=")
Expand Down

0 comments on commit 084b8ca

Please sign in to comment.