Skip to content

Commit

Permalink
fix: Add option to disable Kaniko cache warming
Browse files Browse the repository at this point in the history
  • Loading branch information
asifdxtreme committed Sep 11, 2019
1 parent d52c19b commit 8b4a291
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
1 change: 1 addition & 0 deletions pkg/apis/camel/v1alpha1/integrationplatform_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type IntegrationPlatformBuildSpec struct {
PersistentVolumeClaim string `json:"persistentVolumeClaim,omitempty"`
Maven MavenSpec `json:"maven,omitempty"`
HTTPProxySecret string `json:"httpProxySecret,omitempty"`
SkipKanikoBuildCache bool `json:"skipKanikoBuildCache,omitempty"`
}

// IntegrationPlatformRegistrySpec --
Expand Down
3 changes: 2 additions & 1 deletion pkg/builder/kaniko/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"path"
"strconv"
"time"

"github.com/apache/camel-k/pkg/builder"
Expand Down Expand Up @@ -79,7 +80,7 @@ func publisher(ctx *builder.Context) error {
"--dockerfile=Dockerfile",
"--context=" + contextDir,
"--destination=" + image,
"--cache",
"--cache=" + strconv.FormatBool(ctx.Build.Platform.Build.SkipKanikoBuildCache),
"--cache-dir=/workspace/cache",
}

Expand Down
46 changes: 25 additions & 21 deletions pkg/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
cmd.Flags().StringVar(&impl.buildStrategy, "build-strategy", "", "Set the build strategy")
cmd.Flags().StringVar(&impl.buildTimeout, "build-timeout", "", "Set how long the build process can last")
cmd.Flags().StringVar(&impl.traitProfile, "trait-profile", "", "The profile to use for traits")
cmd.Flags().BoolVar(&impl.skipKanikoBuildCache, "skip-kaniko-build-cache", false, "To enable or disable the Kaniko Cache in building phase")
cmd.Flags().StringVar(&impl.httpProxySecret, "http-proxy-secret", "", "Configure the source of the secret holding HTTP proxy server details "+
"(HTTP_PROXY|HTTPS_PROXY|NO_PROXY)")

Expand All @@ -96,27 +97,28 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {

type installCmdOptions struct {
*RootCmdOptions
wait bool
clusterSetupOnly bool
skipOperatorSetup bool
skipClusterSetup bool
exampleSetup bool
global bool
outputFormat string
camelVersion string
runtimeVersion string
baseImage string
operatorImage string
localRepository string
buildStrategy string
buildTimeout string
mavenRepositories []string
mavenSettings string
properties []string
kits []string
registry v1alpha1.IntegrationPlatformRegistrySpec
traitProfile string
httpProxySecret string
wait bool
clusterSetupOnly bool
skipOperatorSetup bool
skipClusterSetup bool
exampleSetup bool
global bool
skipKanikoBuildCache bool
outputFormat string
camelVersion string
runtimeVersion string
baseImage string
operatorImage string
localRepository string
buildStrategy string
buildTimeout string
mavenRepositories []string
mavenSettings string
properties []string
kits []string
registry v1alpha1.IntegrationPlatformRegistrySpec
traitProfile string
httpProxySecret string
}

// nolint: gocyclo
Expand Down Expand Up @@ -235,6 +237,8 @@ func (o *installCmdOptions) install(_ *cobra.Command, _ []string) error {
platform.Spec.Build.HTTPProxySecret = o.httpProxySecret
}

platform.Spec.Build.SkipKanikoBuildCache = o.skipKanikoBuildCache

platform.Spec.Resources.Kits = o.kits

err = install.RuntimeObjectOrCollect(o.Context, c, namespace, collection, platform)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/integrationplatform/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (action *initializeAction) Handle(ctx context.Context, platform *v1alpha1.I
}

// Check if the operator is running in the same namespace before starting the cache warmer
if platform.Namespace == platformutil.GetOperatorNamespace() {
if platform.Namespace == platformutil.GetOperatorNamespace() && !platform.Spec.Build.SkipKanikoBuildCache {
// Create the Kaniko warmer pod that caches the base image into the Camel K builder volume
action.L.Info("Create Kaniko cache warmer pod")
err = createKanikoCacheWarmerPod(ctx, action.client, platform)
Expand Down

0 comments on commit 8b4a291

Please sign in to comment.