Skip to content

Commit

Permalink
feat(kaniko): Add CacheRunLayers into Kaniko config
Browse files Browse the repository at this point in the history
Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
  • Loading branch information
idsulik committed Aug 29, 2024
1 parent f68d017 commit 3a9bd0e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion docs-v2/content/en/schemas/v4beta12.json
Original file line number Diff line number Diff line change
Expand Up @@ -2934,6 +2934,11 @@
"x-intellij-html-description": "enables caching of copy layers.",
"default": "false"
},
"cacheRunLayers": {
"type": "boolean",
"description": "enables caching of run layers (default=true).",
"x-intellij-html-description": "enables caching of run layers (default=true)."
},
"hostPath": {
"type": "string",
"description": "specifies a path on the host that is mounted to each pod as read only cache volume containing base images. If set, must exist on each node and prepopulated with kaniko-warmer.",
Expand All @@ -2954,7 +2959,8 @@
"repo",
"hostPath",
"ttl",
"cacheCopyLayers"
"cacheCopyLayers",
"cacheRunLayers"
],
"additionalProperties": false,
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/kaniko/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Args(artifact *latest.KanikoArtifact, tag, context string) ([]string, error
if artifact.Cache.CacheCopyLayers {
args = append(args, CacheCopyLayersFlag)
}
if artifact.Cache.CacheRunLayers != nil{
if artifact.Cache.CacheRunLayers != nil {
args = append(args, fmt.Sprintf("%s=%t", CacheRunLayersFlag, *artifact.Cache.CacheRunLayers))
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/skaffold/schema/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ func setKanikoArtifactDefaults(a *latest.KanikoArtifact) {
a.DockerfilePath = valueOrDefault(a.DockerfilePath, constants.DefaultDockerfilePath)
a.InitImage = valueOrDefault(a.InitImage, constants.DefaultBusyboxImage)
a.DigestFile = valueOrDefault(a.DigestFile, constants.DefaultKanikoDigestFile)
a.Cache.CacheRunLayers = valueOrDefaultBool(a.Cache.CacheRunLayers, true)
if a.Cache != nil {
a.Cache.CacheRunLayers = valueOrDefaultBool(a.Cache.CacheRunLayers, true)
}
a.CopyMaxRetries = valueOrDefaultInt(a.CopyMaxRetries, kaniko.DefaultCopyMaxRetries)
a.CopyTimeout = valueOrDefault(a.CopyTimeout, kaniko.DefaultCopyTimeout)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ type KanikoCache struct {
TTL string `yaml:"ttl,omitempty"`
// CacheCopyLayers enables caching of copy layers.
CacheCopyLayers bool `yaml:"cacheCopyLayers,omitempty"`
// CacheRunLayers enables caching of run layers (default=true).
CacheRunLayers *bool `yaml:"cacheRunLayers,omitempty"`
}

// ClusterDetails *beta* describes how to do an on-cluster build.
Expand Down

0 comments on commit 3a9bd0e

Please sign in to comment.