Skip to content

Commit

Permalink
Add skip tls verify option to kaniko builder
Browse files Browse the repository at this point in the history
I was able to recreate the error in GoogleContainerTools#1961 by using a kaniko image
without a cert & pushing to an unauthenticated registry in Cloud Run.

Adding this flag resolves that bug.
  • Loading branch information
Priya Wadhwa committed Oct 2, 2019
1 parent 08551a7 commit d50f1e4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/skaffold/build/cluster/kaniko.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubernetes"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/google/go-containerregistry/pkg/name"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -139,5 +140,21 @@ func args(artifact *latest.KanikoArtifact, context, tag string) ([]string, error
args = append(args, "--reproducible")
}

if artifact.SkipTLS {
reg, err := artifactRegistry(tag)
if err != nil {
return nil, err
}
args = append(args, "--skip-tls-verify-registry", reg)
}

return args, nil
}

func artifactRegistry(i string) (string, error) {
ref, err := name.ParseReference(i)
if err != nil {
return "", err
}
return ref.Context().RegistryStr(), nil
}
3 changes: 3 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ type KanikoArtifact struct {

// Reproducible is used to strip timestamps out of the built image.
Reproducible bool `yaml:"reproducible,omitempty"`

// SkipTLS skips TLS verification when pulling and pushing the image.
SkipTLS bool `yaml:"skipTLS,omitempty"`
}

// DockerArtifact *beta* describes an artifact built from a Dockerfile,
Expand Down

0 comments on commit d50f1e4

Please sign in to comment.