Last active
June 20, 2021 12:46
-
-
Save akshedu/8d33ddbac51ce8005754ab666a6b8c71 to your computer and use it in GitHub Desktop.
Dockerfile to create an image which can run kops, kubectl and kustomize commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use a builder layer while adding ecr-login to minimise the size of final image | |
FROM golang:alpine AS builder | |
RUN apk --no-cache add git && \ | |
git clone https://github.com/awslabs/amazon-ecr-credential-helper /go/src/github.com/awslabs/amazon-ecr-credential-helper && \ | |
go build -o /assets/docker-credential-ecr-login github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login | |
FROM alpine AS resource | |
COPY --from=builder /assets/docker-credential-ecr-login /usr/local/bin/docker-credential-ecr-login | |
# OpenSSH is required to create a ssh key while creating a new cluster | |
RUN apk add --no-cache --update openssh-keygen | |
RUN apk add --no-cache curl | |
RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" | |
RUN chmod +x ./kubectl | |
RUN mv ./kubectl /usr/local/bin/kubectl | |
RUN curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64 | |
RUN chmod +x kops-linux-amd64 | |
RUN mv kops-linux-amd64 /usr/local/bin/kops | |
RUN curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases | grep browser_download | grep linux | cut -d '"' -f 4 | grep /kustomize/$version.*amd64 | sort -r | head -1 | xargs curl -sL --output kustomize_linux_amd64.tar.gz | |
RUN tar xzf ./kustomize_linux_amd64.tar.gz | |
RUN mv kustomize /usr/local/bin/kustomize | |
RUN rm ./kustomize_linux_amd64.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment