Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/awscliv2 #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ARG HELM_VERSION=3.2.1
ARG KUBECTL_VERSION=1.17.5
ARG KUSTOMIZE_VERSION=v3.8.1
ARG KUBESEAL_VERSION=v0.15.0
ARG AWS_CLI_VERSION=2.1.39

# Install helm (latest release)
# ENV BASE_URL="https://storage.googleapis.com/kubernetes-helm"
Expand Down Expand Up @@ -42,17 +43,28 @@ RUN curl -sL "https://github.com/weaveworks/eksctl/releases/latest/download/eksc
mv /tmp/eksctl /usr/bin && \
chmod +x /usr/bin/eksctl

# Install awscli
# Install awscli v1
RUN apk add --update --no-cache python3 && \
python3 -m ensurepip && \
pip3 install --upgrade pip && \
pip3 install awscli && \
pip3 cache purge
ln -s /usr/bin/python3 /usr/bin/python && \
curl -sL "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscliv1.zip" && \
unzip awscliv1.zip && \
./awscli-bundle/install -i /usr/local/aws-cli-v1 -b /usr/local/bin/awsv1 && \
chmod +x /usr/local/bin/awsv1 && \
rm -rf awscliv1.zip awscli-bundle

# Install awscli v2
RUN apk add --update --no-cache gcompat groff && \
curl -sL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install -i /usr/local/aws-cli-v2 -b /usr/local/bin && \
chmod +x /usr/local/bin/aws && \
mv /usr/local/bin/aws /usr/local/bin/awsv2 && \
rm -rf awscliv2.zip aws

# https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html
# Install aws-iam-authenticator
RUN authenticator=$(aws --no-sign-request s3 ls s3://amazon-eks --recursive |grep aws-iam-authenticator$|grep amd64 |awk '{print $NF}' |sort -V|tail -1) && \
aws --no-sign-request s3 cp s3://amazon-eks/${authenticator} /usr/bin/aws-iam-authenticator && \
RUN authenticator=$(awsv1 --no-sign-request s3 ls s3://amazon-eks --recursive |grep aws-iam-authenticator$|grep amd64 |awk '{print $NF}' |sort -V|tail -1) && \
awsv1 --no-sign-request s3 cp s3://amazon-eks/${authenticator} /usr/bin/aws-iam-authenticator && \
chmod +x /usr/bin/aws-iam-authenticator

# Install jq
Expand All @@ -66,4 +78,8 @@ RUN curl -sL https://github.com/bitnami-labs/sealed-secrets/releases/download/${
mv kubeseal /usr/bin/kubeseal && \
chmod +x /usr/bin/kubeseal

COPY entrypoint.sh entrypoint.sh

WORKDIR /apps

ENTRYPOINT ["/entrypoint.sh"]
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ There is no `latest` tag for this image
- [helm-push](https://github.com/chartmuseum/helm-push) (latest commit)
- [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator) (latest version when run the build)
- [eksctl](https://github.com/weaveworks/eksctl) (latest version when run the build)
- [awscli v1](https://github.com/aws/aws-cli) (latest version when run the build)
- [awscliv1](https://github.com/aws/aws-cli) (latest version when run the build)
- [awscliv2](https://github.com/aws/aws-cli) (v2.1.39)
ozbillwang marked this conversation as resolved.
Show resolved Hide resolved
- [kubeseal](https://github.com/bitnami-labs/sealed-secrets) (latest version when run the build)
- General tools, such as bash, curl

Expand All @@ -34,6 +35,15 @@ https://app.circleci.com/pipelines/github/alpine-docker/k8s

https://hub.docker.com/r/alpine/k8s/tags/

# Quick start
Set environmental variable `awscli` to `v2` to use awscliv2 by default, otherwise awscliv1 is used.

To pass an environmental variable to a docker image use the `-e` option:

```
docker -e awscli=v2 ...
```

# Why we need it

Mostly it is used during CI/CD (continuous integration and continuous delivery) or as part of an automated build/deployment
Expand Down
4 changes: 4 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
[ "v2" == "$awscli" ] && ln -s /usr/local/bin/awsv2 /usr/bin/aws || ln -s /usr/local/bin/awsv1 /usr/bin/aws

exec "$@"