Commit 264ad327 authored by Adam Reese's avatar Adam Reese

fix(init): use ImagePullPolicy Always for canary installs

fixes: #2155
parent 1cf37fd6
......@@ -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"},
},
......
......@@ -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)
}
......
......@@ -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 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment