Skip to content

Instantly share code, notes, and snippets.

@shiopon01
Last active July 20, 2018 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiopon01/af49b2b26d467f160f9491e65e7011ed to your computer and use it in GitHub Desktop.
Save shiopon01/af49b2b26d467f160f9491e65e7011ed to your computer and use it in GitHub Desktop.
# Prerequisites:
# You must be create config file.
#
# $ touch ~/.kube/config-<cluster-name>
# Reference: https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html
#
# Build:
# $ docker build -t kubectl .
#
# Run:
# $ docker run --rm -it -v <.aws dir>/:/.aws/ -v <.kube dir>/:/.kube/ -e KUBECONFIG=/.kube/config-<cluster name> kubectl get svc
#
# Alias:
# You may setup an alias to run.
#
# function akubectl () {
# docker run --rm -it \
# -v <.aws dir>/:/.aws/ -v <.kube dir>/:/.kube/ -v $PWD:/work/ \
# -e KUBECONFIG=/.kube/config-<cluster name> \
# -p 8001:8001 \
# kubectl "$@"
# }
#
# For example, in my setting..
#
# function akubectl () {
# docker run --rm -it \
# -v ~/.aws/:/.aws/ -v ~/.kube/:/.kube/ -v $PWD:/work/ \
# -e KUBECONFIG=/.kube/config-sample-cluster \
# -p 8001:8001 \
# kubectl "$@"
# }
#
# !! Supplement !!
# Please change the address when executing `kubectl proxy`:
# $ akubectl proxy --address=0.0.0.0
FROM alpine
LABEL maintainer="shiopon01 <shio.0323@gmail.com>"
ENV EKS_KUBE_KEY "1.10.3/2018-06-05"
ENV AWS_CONFIG_FILE /.aws/config
ENV AWS_SHARED_CREDENTIALS_FILE /.aws/credentials
RUN apk add --update ca-certificates \
&& apk add --update -t deps curl \
&& curl -o /usr/local/bin/kubectl https://amazon-eks.s3-us-west-2.amazonaws.com/${EKS_KUBE_KEY}/bin/linux/amd64/kubectl \
&& chmod +x /usr/local/bin/kubectl \
&& curl -o /usr/local/bin/heptio-authenticator-aws https://amazon-eks.s3-us-west-2.amazonaws.com/${EKS_KUBE_KEY}/bin/linux/amd64/heptio-authenticator-aws \
&& chmod +x /usr/local/bin/heptio-authenticator-aws \
&& apk del --purge deps \
&& rm /var/cache/apk/*
WORKDIR /work
ENTRYPOINT ["kubectl"]
CMD ["help"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment