You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2020/07/17 07:49:44 UTC

[camel-k] branch master updated: feat: expose Operator ImagePullPolicy option and set it to Always in CRC's install script.

This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/master by this push:
     new 813275f  feat: expose Operator ImagePullPolicy option and set it to Always in CRC's install script.
813275f is described below

commit 813275f856ba3c346c6b3518c3a4947e98f31d43
Author: John Poth <po...@gmail.com>
AuthorDate: Fri Jul 10 11:40:27 2020 +0200

    feat: expose Operator ImagePullPolicy option and set it to Always in CRC's install script.
---
 pkg/cmd/install.go      | 61 ++++++++++++++++++++++++++-----------------------
 pkg/install/operator.go | 18 +++++++++++----
 script/install_crc.sh   |  2 +-
 3 files changed, 47 insertions(+), 34 deletions(-)

diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index 7948344..b5c9c44 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -92,6 +92,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO
 	cmd.Flags().String("runtime-version", "", "Set the camel-k runtime version")
 	cmd.Flags().String("base-image", "", "Set the base Image used to run integrations")
 	cmd.Flags().String("operator-image", "", "Set the operator Image used for the operator deployment")
+	cmd.Flags().String("operator-image-pull-policy", "", "Set the operator ImagePullPolicy used for the operator deployment")
 	cmd.Flags().StringArray("kit", nil, "Add an integration kit to build at startup")
 	cmd.Flags().String("build-strategy", "", "Set the build strategy")
 	cmd.Flags().String("build-publish-strategy", "", "Set the build publish strategy")
@@ -135,31 +136,32 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO
 
 type installCmdOptions struct {
 	*RootCmdOptions
-	Wait                 bool     `mapstructure:"wait"`
-	ClusterSetupOnly     bool     `mapstructure:"cluster-setup"`
-	SkipOperatorSetup    bool     `mapstructure:"skip-operator-setup"`
-	SkipClusterSetup     bool     `mapstructure:"skip-cluster-setup"`
-	ExampleSetup         bool     `mapstructure:"example"`
-	Global               bool     `mapstructure:"global"`
-	KanikoBuildCache     bool     `mapstructure:"kaniko-build-cache"`
-	Save                 bool     `mapstructure:"save" kamel:"omitsave"`
-	Force                bool     `mapstructure:"force"`
-	Olm                  bool     `mapstructure:"olm"`
-	ClusterType          string   `mapstructure:"cluster-type"`
-	OutputFormat         string   `mapstructure:"output"`
-	RuntimeVersion       string   `mapstructure:"runtime-version"`
-	BaseImage            string   `mapstructure:"base-image"`
-	OperatorImage        string   `mapstructure:"operator-image"`
-	LocalRepository      string   `mapstructure:"local-repository"`
-	BuildStrategy        string   `mapstructure:"build-strategy"`
-	BuildPublishStrategy string   `mapstructure:"build-publish-strategy"`
-	BuildTimeout         string   `mapstructure:"build-timeout"`
-	MavenRepositories    []string `mapstructure:"maven-repositories"`
-	MavenSettings        string   `mapstructure:"maven-settings"`
-	Properties           []string `mapstructure:"properties"`
-	Kits                 []string `mapstructure:"kits"`
-	TraitProfile         string   `mapstructure:"trait-profile"`
-	HTTPProxySecret      string   `mapstructure:"http-proxy-secret"`
+	Wait                    bool     `mapstructure:"wait"`
+	ClusterSetupOnly        bool     `mapstructure:"cluster-setup"`
+	SkipOperatorSetup       bool     `mapstructure:"skip-operator-setup"`
+	SkipClusterSetup        bool     `mapstructure:"skip-cluster-setup"`
+	ExampleSetup            bool     `mapstructure:"example"`
+	Global                  bool     `mapstructure:"global"`
+	KanikoBuildCache        bool     `mapstructure:"kaniko-build-cache"`
+	Save                    bool     `mapstructure:"save" kamel:"omitsave"`
+	Force                   bool     `mapstructure:"force"`
+	Olm                     bool     `mapstructure:"olm"`
+	ClusterType             string   `mapstructure:"cluster-type"`
+	OutputFormat            string   `mapstructure:"output"`
+	RuntimeVersion          string   `mapstructure:"runtime-version"`
+	BaseImage               string   `mapstructure:"base-image"`
+	OperatorImage           string   `mapstructure:"operator-image"`
+	OperatorImagePullPolicy string   `mapstructure:"operator-image-pull-policy"`
+	LocalRepository         string   `mapstructure:"local-repository"`
+	BuildStrategy           string   `mapstructure:"build-strategy"`
+	BuildPublishStrategy    string   `mapstructure:"build-publish-strategy"`
+	BuildTimeout            string   `mapstructure:"build-timeout"`
+	MavenRepositories       []string `mapstructure:"maven-repositories"`
+	MavenSettings           string   `mapstructure:"maven-settings"`
+	Properties              []string `mapstructure:"properties"`
+	Kits                    []string `mapstructure:"kits"`
+	TraitProfile            string   `mapstructure:"trait-profile"`
+	HTTPProxySecret         string   `mapstructure:"http-proxy-secret"`
 
 	registry     v1.IntegrationPlatformRegistrySpec
 	registryAuth registry.Auth
@@ -241,10 +243,11 @@ func (o *installCmdOptions) install(cobraCmd *cobra.Command, _ []string) error {
 
 		if !o.SkipOperatorSetup && !installViaOLM {
 			cfg := install.OperatorConfiguration{
-				CustomImage: o.OperatorImage,
-				Namespace:   namespace,
-				Global:      o.Global,
-				ClusterType: o.ClusterType,
+				CustomImage:           o.OperatorImage,
+				CustomImagePullPolicy: o.OperatorImagePullPolicy,
+				Namespace:             namespace,
+				Global:                o.Global,
+				ClusterType:           o.ClusterType,
 			}
 			err = install.OperatorOrCollect(o.Context, c, cfg, collection, o.Force)
 			if err != nil {
diff --git a/pkg/install/operator.go b/pkg/install/operator.go
index d156162..37215fe 100644
--- a/pkg/install/operator.go
+++ b/pkg/install/operator.go
@@ -24,6 +24,7 @@ import (
 	"strings"
 
 	appsv1 "k8s.io/api/apps/v1"
+	corev1 "k8s.io/api/core/v1"
 	"k8s.io/api/rbac/v1beta1"
 	k8serrors "k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -40,10 +41,11 @@ import (
 
 // OperatorConfiguration --
 type OperatorConfiguration struct {
-	CustomImage string
-	Namespace   string
-	Global      bool
-	ClusterType string
+	CustomImage           string
+	CustomImagePullPolicy string
+	Namespace             string
+	Global                bool
+	ClusterType           string
 }
 
 // Operator installs the operator resources in the given namespace
@@ -62,6 +64,14 @@ func OperatorOrCollect(ctx context.Context, c client.Client, cfg OperatorConfigu
 			}
 		}
 
+		if cfg.CustomImagePullPolicy != "" {
+			if d, ok := o.(*appsv1.Deployment); ok {
+				if d.Labels["camel.apache.org/component"] == "operator" {
+					d.Spec.Template.Spec.Containers[0].ImagePullPolicy = corev1.PullPolicy(cfg.CustomImagePullPolicy)
+				}
+			}
+		}
+
 		if cfg.Global {
 			if d, ok := o.(*appsv1.Deployment); ok {
 				if d.Labels["camel.apache.org/component"] == "operator" {
diff --git a/script/install_crc.sh b/script/install_crc.sh
index 766ae7c..884c177 100755
--- a/script/install_crc.sh
+++ b/script/install_crc.sh
@@ -46,7 +46,7 @@ docker push default-route-openshift-image-registry.apps-crc.testing/$project/cam
 
 # Try setup with standard user
 ret=0
-cmd="./kamel install --olm=false --operator-image=image-registry.openshift-image-registry.svc:5000/$project/camel-k:$1"
+cmd="./kamel install --olm=false --operator-image=image-registry.openshift-image-registry.svc:5000/$project/camel-k:$1 --operator-image-pull-policy=Always"
 eval "$cmd -n $project 2>/dev/null || export ret=\$?"
 
 if [ $ret -ne 0 ]; then