Skip to content

Commit

Permalink
feat: pull kaniko images from private registry w/ pull secret
Browse files Browse the repository at this point in the history
  • Loading branch information
dherges committed Nov 21, 2023
1 parent 66cea29 commit dd23895
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/skaffold/build/cluster/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ func (b *Builder) kanikoPodSpec(artifact *latest.KanikoArtifact, tag string, pla
addSecretVolume(pod, kaniko.DefaultSecretName, b.ClusterDetails.PullSecretMountPath, b.ClusterDetails.PullSecretName)
}

// Add secret for pulling kaniko images from a private registry
if artifact.ImagePullSecret != "" {
pod.Spec.ImagePullSecrets = []v1.LocalObjectReference{{
Name: artifact.ImagePullSecret,
}}
}

// Add host path volume for cache
if artifact.Cache != nil && artifact.Cache.HostPath != "" {
addHostPathVolume(pod, kaniko.DefaultCacheDirName, kaniko.DefaultCacheDirMountPath, artifact.Cache.HostPath)
Expand Down
3 changes: 3 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,9 @@ type KanikoArtifact struct {
// Defaults to the latest released version of `gcr.io/kaniko-project/executor`.
Image string `yaml:"image,omitempty"`

// ImagePullSecret is the name of the Kubernetes secret for pulling kaniko image and kaniko init image from a private registry
ImagePullSecret string `yaml:"imagePullSecret,omitempty"`

// DigestFile to specify a file in the container. This file will receive the digest of a built image.
// This can be used to automatically track the exact image built by kaniko.
DigestFile string `yaml:"digestFile,omitempty"`
Expand Down

0 comments on commit dd23895

Please sign in to comment.