diff --git a/pkg/skaffold/build/cluster/pod.go b/pkg/skaffold/build/cluster/pod.go index e3eaf911097..e852607554b 100644 --- a/pkg/skaffold/build/cluster/pod.go +++ b/pkg/skaffold/build/cluster/pod.go @@ -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) diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 7e1f34303ca..d4a350d6e67 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -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"`