Merge branch 'master' of github.com:GoogleContainerTools/kaniko into busybox
This commit is contained in:
commit
bb90bdef2f
52
README.md
52
README.md
|
|
@ -147,8 +147,58 @@ To run kaniko in Docker, run the following command:
|
||||||
|
|
||||||
kaniko uses Docker credential helpers to push images to a registry.
|
kaniko uses Docker credential helpers to push images to a registry.
|
||||||
|
|
||||||
kaniko comes with support for GCR, but configuring another credential helper should allow pushing to a different registry.
|
kaniko comes with support for GCR and Amazon ECR, but configuring another credential helper should allow pushing to a different registry.
|
||||||
|
|
||||||
|
#### Pushing to Amazon ECR
|
||||||
|
The Amazon ECR [credential helper](https://github.com/awslabs/amazon-ecr-credential-helper) is built in to the kaniko executor image.
|
||||||
|
To configure credentials, you will need to do the following:
|
||||||
|
1. Update the `credHelpers` section of [config.json](https://github.com/GoogleContainerTools/kaniko/blob/master/files/config.json) with the specific URI of your ECR registry:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"credHelpers": {
|
||||||
|
"aws_account_id.dkr.ecr.region.amazonaws.com": "ecr-login"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
You can mount in the new config as a configMap:
|
||||||
|
```shell
|
||||||
|
kubectl create configmap docker-config --from-file=<path to config.json>
|
||||||
|
```
|
||||||
|
2. Create a Kubernetes secret for your `~/.aws/credentials` file so that credentials can be accessed within the cluster.
|
||||||
|
To create the secret, run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
kubectl create secret generic aws-secret --from-file=<path to .aws/credentials>
|
||||||
|
```
|
||||||
|
|
||||||
|
The Kubernetes Pod spec should look similar to this, with the args parameters filled in:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: kaniko
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: kaniko
|
||||||
|
image: gcr.io/kaniko-project/executor:latest
|
||||||
|
args: ["--dockerfile=<path to Dockerfile>",
|
||||||
|
"--context=<path to build context>",
|
||||||
|
"--destination=<aws_account_id.dkr.ecr.region.amazonaws.com/my-repository:my-tag>"]
|
||||||
|
volumeMounts:
|
||||||
|
- name: aws-secret
|
||||||
|
mountPath: /root/.aws/
|
||||||
|
- name: docker-config
|
||||||
|
mountPath: /root/.docker/
|
||||||
|
restartPolicy: Never
|
||||||
|
volumes:
|
||||||
|
- name: aws-secret
|
||||||
|
secret:
|
||||||
|
secretName: aws-secret
|
||||||
|
- name: docker-config
|
||||||
|
configMap:
|
||||||
|
name: docker-config
|
||||||
|
```
|
||||||
### Debug Image
|
### Debug Image
|
||||||
|
|
||||||
The kaniko executor image is based off of scratch and doesn't contain a shell.
|
The kaniko executor image is based off of scratch and doesn't contain a shell.
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ func init() {
|
||||||
RootCmd.PersistentFlags().StringVarP(&srcContext, "context", "c", "/workspace/", "Path to the dockerfile build context.")
|
RootCmd.PersistentFlags().StringVarP(&srcContext, "context", "c", "/workspace/", "Path to the dockerfile build context.")
|
||||||
RootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "", "Name of the GCS bucket from which to access build context as tarball.")
|
RootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "", "Name of the GCS bucket from which to access build context as tarball.")
|
||||||
RootCmd.PersistentFlags().StringVarP(&destination, "destination", "d", "", "Registry the final image should be pushed to (ex: gcr.io/test/example:latest)")
|
RootCmd.PersistentFlags().StringVarP(&destination, "destination", "d", "", "Registry the final image should be pushed to (ex: gcr.io/test/example:latest)")
|
||||||
|
RootCmd.MarkPersistentFlagRequired("destination")
|
||||||
RootCmd.PersistentFlags().StringVarP(&snapshotMode, "snapshotMode", "", "full", "Set this flag to change the file attributes inspected during snapshotting")
|
RootCmd.PersistentFlags().StringVarP(&snapshotMode, "snapshotMode", "", "full", "Set this flag to change the file attributes inspected during snapshotting")
|
||||||
RootCmd.PersistentFlags().BoolVarP(&dockerInsecureSkipTLSVerify, "insecure-skip-tls-verify", "", false, "Push to insecure registry ignoring TLS verify")
|
RootCmd.PersistentFlags().BoolVarP(&dockerInsecureSkipTLSVerify, "insecure-skip-tls-verify", "", false, "Push to insecure registry ignoring TLS verify")
|
||||||
RootCmd.PersistentFlags().StringVarP(&logLevel, "verbosity", "v", constants.DefaultLogLevel, "Log level (debug, info, warn, error, fatal, panic")
|
RootCmd.PersistentFlags().StringVarP(&logLevel, "verbosity", "v", constants.DefaultLogLevel, "Log level (debug, info, warn, error, fatal, panic")
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,17 @@ FROM golang:1.10
|
||||||
WORKDIR /go/src/github.com/GoogleContainerTools/kaniko
|
WORKDIR /go/src/github.com/GoogleContainerTools/kaniko
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make
|
RUN make
|
||||||
WORKDIR /usr/local/bin
|
# Get GCR credential helper
|
||||||
ADD https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v1.4.3-static/docker-credential-gcr_linux_amd64-1.4.3.tar.gz .
|
ADD https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v1.4.3-static/docker-credential-gcr_linux_amd64-1.4.3.tar.gz /usr/local/bin/
|
||||||
RUN tar -xvzf /usr/local/bin/docker-credential-gcr_linux_amd64-1.4.3.tar.gz
|
RUN tar -C /usr/local/bin/ -xvzf /usr/local/bin/docker-credential-gcr_linux_amd64-1.4.3.tar.gz
|
||||||
|
# Get Amazon ECR credential helper
|
||||||
|
RUN go get -u github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login
|
||||||
|
RUN make -C /go/src/github.com/awslabs/amazon-ecr-credential-helper linux-amd64
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=0 /go/src/github.com/GoogleContainerTools/kaniko/out/executor /kaniko/executor
|
COPY --from=0 /go/src/github.com/GoogleContainerTools/kaniko/out/executor /kaniko/executor
|
||||||
COPY --from=0 /usr/local/bin/docker-credential-gcr /usr/local/bin/docker-credential-gcr
|
COPY --from=0 /usr/local/bin/docker-credential-gcr /usr/local/bin/docker-credential-gcr
|
||||||
|
COPY --from=0 /go/src/github.com/awslabs/amazon-ecr-credential-helper/bin/linux-amd64/docker-credential-ecr-login /usr/local/bin/docker-credential-ecr-login
|
||||||
COPY files/ca-certificates.crt /kaniko/ssl/certs/
|
COPY files/ca-certificates.crt /kaniko/ssl/certs/
|
||||||
COPY files/config.json /root/.docker/
|
COPY files/config.json /root/.docker/
|
||||||
RUN ["docker-credential-gcr", "config", "--token-source=env"]
|
RUN ["docker-credential-gcr", "config", "--token-source=env"]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
FROM gcr.io/distroless/base
|
FROM alpine:3.7
|
||||||
COPY context/foo foo
|
COPY context/foo foo
|
||||||
COPY context/foo /foodir/
|
COPY context/foo /foodir/
|
||||||
COPY context/bar/b* bar/
|
COPY context/bar/b* bar/
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,8 @@ func GetCommand(cmd instructions.Command, buildcontext string) (DockerCommand, e
|
||||||
return &VolumeCommand{cmd: c}, nil
|
return &VolumeCommand{cmd: c}, nil
|
||||||
case *instructions.StopSignalCommand:
|
case *instructions.StopSignalCommand:
|
||||||
return &StopSignalCommand{cmd: c}, nil
|
return &StopSignalCommand{cmd: c}, nil
|
||||||
|
case *instructions.ShellCommand:
|
||||||
|
return &ShellCommand{cmd: c}, nil
|
||||||
case *instructions.MaintainerCommand:
|
case *instructions.MaintainerCommand:
|
||||||
logrus.Warnf("%s is deprecated, skipping", cmd.Name())
|
logrus.Warnf("%s is deprecated, skipping", cmd.Name())
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,12 @@ func GetFSFromImage(img v1.Image) error {
|
||||||
logrus.Infof("Not adding %s because it is whitelisted", path)
|
logrus.Infof("Not adding %s because it is whitelisted", path)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if hdr.Typeflag == tar.TypeSymlink {
|
||||||
|
if checkWhitelist(hdr.Linkname, whitelist) {
|
||||||
|
logrus.Debugf("skipping symlink from %s to %s because %s is whitelisted", hdr.Linkname, path, hdr.Linkname)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
fs[path] = struct{}{}
|
fs[path] = struct{}{}
|
||||||
|
|
||||||
if err := extractFile("/", hdr, tr); err != nil {
|
if err := extractFile("/", hdr, tr); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue