Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kodermax committed May 4, 2022
2 parents d3d3ce3 + 7f823cd commit de30cf9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
FROM amazon/aws-cli
FROM amazon/aws-cli:latest

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 && \
curl -L -o /usr/local/bin/aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.5.7/aws-iam-authenticator_0.5.7_linux_amd64 && \
chmod +x /usr/local/bin/aws-iam-authenticator && \
chmod +x ./kubectl && \
mv ./kubectl /usr/bin/kubectl
RUN yum install jq -y && curl -sL -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
curl -sL -o /usr/bin/aws-iam-authenticator $(curl -s https://api.github.com/repos/kubernetes-sigs/aws-iam-authenticator/releases/latest | jq -r ' .assets[] | select(.name | contains("linux_amd64") )' | jq -r '.browser_download_url') && \
chmod +x /usr/bin/aws-iam-authenticator && \
chmod +x /usr/bin/kubectl

RUN kubectl version --client
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
22 changes: 21 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,24 @@ set -e
echo "$KUBE_CONFIG_DATA" | base64 -d > /tmp/config
export KUBECONFIG=/tmp/config

sh -c "kubectl $*"
if [ -z ${KUBECTL_VERSION+x} ] ; then
echo "Using kubectl version: $(kubectl version --client --short)"
else
echo "Pulling kubectl for version $KUBECTL_VERSION"
rm /usr/bin/kubectl
curl -sL -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/"$KUBECTL_VERSION"/bin/linux/amd64/kubectl && \
chmod +x /usr/bin/kubectl
echo "Using kubectl version: $(kubectl version --client --short)"
fi

if [ -z ${IAM_VERSION+x} ] ; then
echo "Using aws-iam-authenticator version: $(aws-iam-authenticator version)"
else
echo "Pulling aws-iam-authenticator for version $IAM_VERSION"
rm /usr/bin/aws-iam-authenticator
curl -sL -o /usr/bin/aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v"$IAM_VERSION"/aws-iam-authenticator_"$IAM_VERSION"_linux_amd64 && \
chmod +x /usr/bin/aws-iam-authenticator
echo "Using aws-iam-authenticator version: $(aws-iam-authenticator version)"
fi

sh -c "kubectl $*"

0 comments on commit de30cf9

Please sign in to comment.