diff --git a/cmd/helm/installer/install.go b/cmd/helm/installer/install.go index 338e31ecaa7c61a028162a5f102a460825d377d2..b159ec6606b2d811912b32d7173a9e2c262b3887 100644 --- a/cmd/helm/installer/install.go +++ b/cmd/helm/installer/install.go @@ -20,7 +20,6 @@ import ( "io/ioutil" "github.com/ghodss/yaml" - "k8s.io/kubernetes/pkg/api" kerrors "k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/apis/extensions" @@ -57,6 +56,7 @@ func Upgrade(client internalclientset.Interface, opts *Options) error { return err } obj.Spec.Template.Spec.Containers[0].Image = opts.selectImage() + obj.Spec.Template.Spec.Containers[0].ImagePullPolicy = opts.pullPolicy() if _, err := client.Extensions().Deployments(opts.Namespace).Update(obj); err != nil { return err } @@ -138,7 +138,7 @@ func generateDeployment(opts *Options) *extensions.Deployment { { Name: "tiller", Image: opts.selectImage(), - ImagePullPolicy: "IfNotPresent", + ImagePullPolicy: opts.pullPolicy(), Ports: []api.ContainerPort{ {ContainerPort: 44134, Name: "tiller"}, }, diff --git a/cmd/helm/installer/install_test.go b/cmd/helm/installer/install_test.go index 4d9a2cbcafe29c7b1c4b085aba0c35b26416b1bf..7da65b42b45ddf3bb1fcd2c49c81cdb48a5672e3 100644 --- a/cmd/helm/installer/install_test.go +++ b/cmd/helm/installer/install_test.go @@ -34,14 +34,15 @@ import ( func TestDeploymentManifest(t *testing.T) { tests := []struct { - name string - image string - canary bool - expect string + name string + image string + canary bool + expect string + imagePullPolicy api.PullPolicy }{ - {"default", "", false, "gcr.io/kubernetes-helm/tiller:" + version.Version}, - {"canary", "example.com/tiller", true, "gcr.io/kubernetes-helm/tiller:canary"}, - {"custom", "example.com/tiller:latest", false, "example.com/tiller:latest"}, + {"default", "", false, "gcr.io/kubernetes-helm/tiller:" + version.Version, "IfNotPresent"}, + {"canary", "example.com/tiller", true, "gcr.io/kubernetes-helm/tiller:canary", "Always"}, + {"custom", "example.com/tiller:latest", false, "example.com/tiller:latest", "IfNotPresent"}, } for _, tt := range tests { @@ -58,6 +59,10 @@ func TestDeploymentManifest(t *testing.T) { t.Errorf("%s: expected image %q, got %q", tt.name, tt.expect, got) } + if got := dep.Spec.Template.Spec.Containers[0].ImagePullPolicy; got != tt.imagePullPolicy { + t.Errorf("%s: expected imagePullPolicy %q, got %q", tt.name, tt.imagePullPolicy, got) + } + if got := dep.Spec.Template.Spec.Containers[0].Env[0].Value; got != api.NamespaceDefault { t.Errorf("%s: expected namespace %q, got %q", tt.name, api.NamespaceDefault, got) } diff --git a/cmd/helm/installer/options.go b/cmd/helm/installer/options.go index 41f8aaf2a1f5bccf0b8f1f21c7a526acfb63b623..003bb1d708d0a7ba04b932ef1a9712326b120050 100644 --- a/cmd/helm/installer/options.go +++ b/cmd/helm/installer/options.go @@ -18,7 +18,9 @@ package installer // import "k8s.io/helm/cmd/helm/installer" import ( "fmt" + "k8s.io/helm/pkg/version" + "k8s.io/kubernetes/pkg/api" ) const defaultImage = "gcr.io/kubernetes-helm/tiller" @@ -76,4 +78,11 @@ func (opts *Options) selectImage() string { } } +func (opts *Options) pullPolicy() api.PullPolicy { + if opts.UseCanary { + return api.PullAlways + } + return api.PullIfNotPresent +} + func (opts *Options) tls() bool { return opts.EnableTLS || opts.VerifyTLS }