Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to override the pull policy of the controller in 'kudo init' #1507

Merged
merged 4 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hack/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ docker build . \
-t "kudobuilder/controller:$VERSION"

# Generate the kudo.yaml that is used to install KUDO while running e2e-test
./bin/kubectl-kudo init --webhook InstanceValidation --unsafe-self-signed-webhook-ca --dry-run --output yaml --kudo-image kudobuilder/controller:$VERSION \
| sed -E -e '/imagePullPolicy/ s/Always/Never/' \
./bin/kubectl-kudo init --webhook InstanceValidation \
--unsafe-self-signed-webhook-ca --dry-run --output yaml \
--kudo-image kudobuilder/controller:$VERSION \
--pull-policy Never \
nfnt marked this conversation as resolved.
Show resolved Hide resolved
> test/manifests/kudo.yaml

sed "s/%version%/$VERSION/" kudo-e2e-test.yaml.tmpl > kudo-e2e-test.yaml
Expand Down
5 changes: 5 additions & 0 deletions pkg/kudoctl/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type initCmd struct {
out io.Writer
fs afero.Fs
image string
imagePullPolicy string
dryRun bool
output string
version string
Expand Down Expand Up @@ -102,6 +103,7 @@ func newInitCmd(fs afero.Fs, out io.Writer) *cobra.Command {
f := cmd.Flags()
f.BoolVarP(&i.clientOnly, "client-only", "c", false, "If set does not install KUDO on the server")
f.StringVarP(&i.image, "kudo-image", "i", "", "Override KUDO controller image and/or version")
f.StringVarP(&i.imagePullPolicy, "kudo-image-pull-policy", "", "", "Override KUDO controller image pull policy")
f.StringVarP(&i.version, "version", "", "", "Override KUDO controller version of the KUDO image")
f.StringVarP(&i.output, "output", "o", "", "Output format")
f.BoolVar(&i.dryRun, "dry-run", false, "Do not install local or remote")
Expand Down Expand Up @@ -148,6 +150,9 @@ func (initCmd *initCmd) run() error {
if initCmd.image != "" {
opts.Image = initCmd.image
}
if initCmd.imagePullPolicy != "" {
opts.ImagePullPolicy = initCmd.imagePullPolicy
}
nfnt marked this conversation as resolved.
Show resolved Hide resolved

//TODO: implement output=yaml|json (define a type for output to constrain)
//define an Encoder to replace YAMLWriter
Expand Down
3 changes: 2 additions & 1 deletion pkg/kudoctl/kudoinit/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func generateDeployment(opts kudoinit.Options) *appsv1.StatefulSet {

secretDefaultMode := int32(420)
image := opts.Image
imagePullPolicy := v1.PullPolicy(opts.ImagePullPolicy)
s := &appsv1.StatefulSet{
TypeMeta: metav1.TypeMeta{
Kind: "StatefulSet",
Expand Down Expand Up @@ -127,7 +128,7 @@ func generateDeployment(opts kudoinit.Options) *appsv1.StatefulSet {
{Name: "ENABLE_WEBHOOKS", Value: strconv.FormatBool(opts.HasWebhooksEnabled())},
},
Image: image,
ImagePullPolicy: "Always",
ImagePullPolicy: imagePullPolicy,
Name: "manager",
Ports: []v1.ContainerPort{
// name matters for service
Expand Down
3 changes: 3 additions & 0 deletions pkg/kudoctl/kudoinit/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Options struct {
TerminationGracePeriodSeconds int64
// Image defines the image to be used
Image string
// ImagePullPolicy sets the pull policy of the image
ImagePullPolicy string
// List of enabled webhooks
Webhooks []string
// Using self-signed webhook CA bundle
Expand All @@ -40,6 +42,7 @@ func NewOptions(v string, ns string, sa string, webhooks []string, selfSignedWeb
Namespace: ns,
TerminationGracePeriodSeconds: defaultGracePeriod,
Image: fmt.Sprintf("kudobuilder/controller:v%v", v),
ImagePullPolicy: "Always",
Webhooks: webhooks,
ServiceAccount: sa,
SelfSignedWebhookCA: selfSignedWebhookCA,
Expand Down