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

make initContainer in localDir type of kaniko build param #1727

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions docs/content/en/schemas/v1beta6.json
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,17 @@
"x-intellij-html-description": "<em>beta</em> describes how to do a build on the local docker daemon and optionally push to a repository."
},
"LocalDir": {
"properties": {
"initImage": {
"type": "string",
"description": "image used to run init container which mounts kaniko context.",
"x-intellij-html-description": "image used to run init container which mounts kaniko context."
}
},
"preferredOrder": [
"initImage"
],
"additionalProperties": false,
"description": "configures how Kaniko mounts sources directly via an `emptyDir` volume.",
"x-intellij-html-description": "configures how Kaniko mounts sources directly via an <code>emptyDir</code> volume."
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/kaniko/sources/localdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (g *LocalDir) Pod(args []string) *v1.Pod {
// Generate the init container, which will run until the /tmp/complete file is created
ic := v1.Container{
Name: initContainer,
Image: constants.DefaultBusyboxImage,
Image: g.cfg.BuildContext.LocalDir.InitImage,
Command: []string{"sh", "-c", "while [ ! -f /tmp/complete ]; do sleep 1; done"},
VolumeMounts: []v1.VolumeMount{vm},
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/skaffold/schema/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func Set(c *latest.SkaffoldPipeline) error {
if err := withKanikoConfig(c,
setDefaultKanikoTimeout,
setDefaultKanikoImage,
setDefaultKanikoInitImage,
setDefaultKanikoNamespace,
setDefaultKanikoSecret,
setDefaultKanikoBuildContext,
Expand Down Expand Up @@ -216,6 +217,14 @@ func setDefaultKanikoTimeout(kaniko *latest.KanikoBuild) error {
return nil
}

func setDefaultKanikoInitImage(kaniko *latest.KanikoBuild) error {
if kaniko.BuildContext != nil && kaniko.BuildContext.LocalDir != nil {
localDir := kaniko.BuildContext.LocalDir
localDir.InitImage = valueOrDefault(localDir.InitImage, constants.DefaultBusyboxImage)
}
return nil
}

func setDefaultKanikoImage(kaniko *latest.KanikoBuild) error {
kaniko.Image = valueOrDefault(kaniko.Image, constants.DefaultKanikoImage)
return nil
Expand Down
5 changes: 4 additions & 1 deletion pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ type GoogleCloudBuild struct {
}

// LocalDir configures how Kaniko mounts sources directly via an `emptyDir` volume.
type LocalDir struct{}
type LocalDir struct {
// InitImage is the image used to run init container which mounts kaniko context.
InitImage string `yaml:"initImage,omitempty"`
}

// KanikoBuildContext contains the different fields available to specify
// a Kaniko build context.
Expand Down