-
-
Save fincd-aws/b0bdda615bc4ca5eaf4b467d1e246521 to your computer and use it in GitHub Desktop.
EKS K8s Cloud9 Setup
This file contains hidden or 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
| #!/usr/bin/env bash | |
| function curl-options(){ | |
| curl -sL "$@" | |
| } | |
| ## pre-configure | |
| opsys=$(uname -s | tr '[:upper:]' '[:lower:]') | |
| ## Install | |
| pip install -q --user --upgrade pip awscli aws-shell cfn-flip yamllint \ | |
| && echo "installed user-level pip things: aws-shell awscli cfn-flip yamllint" | |
| mkdir ~/.local/bin #doesn't get made by `pip --user` if your python comes from brew? | |
| pushd ~/.local/bin #now this should work | |
| # Getting Started with Amazon EKS - Install and Configure <b>kubectl</b> for Amazon EKS - https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html#get-started-kubectl | |
| curl-options -O "https://amazon-eks.s3-us-west-2.amazonaws.com/1.12.7/2019-03-27/bin/${opsys}/amd64/aws-iam-authenticator" \ | |
| && chmod 700 aws-iam-authenticator \ | |
| && echo "installed aws-iam-authenticator" | |
| curl-options -O "https://amazon-eks.s3-us-west-2.amazonaws.com/1.12.7/2019-03-27/bin/${opsys}/amd64/kubectl" \ | |
| && chmod 700 kubectl \ | |
| && echo "installed kubectl" | |
| #kubectx/kubens #os independent bash only | |
| curl-options -O https://raw.githubusercontent.com/ahmetb/kubectx/master/kubectx \ | |
| && chmod 700 kubectx \ | |
| && echo "installed kubectx" | |
| curl-options -O https://raw.githubusercontent.com/ahmetb/kubectx/master/kubens \ | |
| && chmod 700 kubens \ | |
| && echo "installed kubens" | |
| # Kustomize install script | |
| #opsys=linux # or darwin, or windows | |
| # //TODO: check for rate-limiting by GitHub API, lol. | |
| #curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases/latest |\ | |
| # grep browser_download |\ | |
| # grep -i ${opsys} |\ | |
| # cut -d '"' -f 4 |\ | |
| # xargs curl -s -O -L | |
| # NOPE, just doing it my way, w/ explicit versioning | |
| curl-options -O "https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_${opsys}_amd64" | |
| mv kustomize_*_${opsys}_amd64 ~/.local/bin/kustomize | |
| chmod u+x ~/.local/bin/kustomize \ | |
| && echo "installed kustomize" | |
| # jq - JSON Query - awk for JSON | |
| case ${opsys} in | |
| linux) curl-options -O "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-${opsys}64" | |
| ;; | |
| darwin) curl-options -O "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64" | |
| ;; | |
| # does any of this actually work in windows? WSL vs other bash on windows things? | |
| windows) curl-options -O "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-win64" | |
| ;; | |
| esac | |
| chmod u+x ~/.local/bin/jq \ | |
| && echo "installed jq" | |
| ## Download archive-based things to /tmp/ | |
| pushd /tmp | |
| # Helm | |
| # I don't use -O, since tar supports streaming | |
| curl-options "https://storage.googleapis.com/kubernetes-helm/helm-v2.13.1-${opsys}-amd64.tar.gz" | tar xz -C /tmp | |
| mv /tmp/${opsys}-amd64/helm ~/.local/bin/ | |
| echo "installed helm 2" | |
| ~/.local/bin/helm init --client-only | |
| # eksctl eksctl.io written by weaveworks | |
| # I don't use -O, since tar supports streaming | |
| curl-options "https://github.com/weaveworks/eksctl/releases/download/latest_release/eksctl_${opsys}_amd64.tar.gz" | tar xz -C /tmp | |
| mv /tmp/eksctl ~/.local/bin | |
| echo "installed eksctl" | |
| # JSON Incremental Digger - interactive jq-ish | |
| curl-options -O "https://github.com/simeji/jid/releases/download/v0.7.6/jid_${opsys}_amd64.zip" | |
| unzip "/tmp/jid_${opsys}_amd64.zip" #unzip can't accept a stream on stdin | |
| mv /tmp/jiq ~/.local/bin | |
| echo "installed jid" | |
| #kubectl 1.12+ only, install the krew kubectl plugin manager, *exactly* with their published instructions to ~/.krew/bin/ | |
| ( | |
| set -x; cd "$(mktemp -d)" && | |
| curl -fsSLO "https://storage.googleapis.com/krew/v0.2.1/krew.{tar.gz,yaml}" && | |
| tar zxvf krew.tar.gz && | |
| ./krew-"$(uname | tr '[:upper:]' '[:lower:]')_amd64" install \ | |
| --manifest=krew.yaml --archive=krew.tar.gz | |
| ) | |
| #end archive downloads | |
| popd | |
| ## Config Files | |
| if [ ! -d ~/.kube ]; then mkdir ~/.kube; fi | |
| # **IF** you made the cluster with this user | |
| # aws eks update-kubeconfig --name cluster_name | |
| # else | |
| #echo "export KUBECONFIG=~/.kube/<thing>:$KUBECONFIG" >> ~/.bashrc | |
| echo "remember to add ~/.krew/bin to your PATH and add KUBECONFIG variable in ~/.bashrc or equivalent and source it" | |
| ## END | |
| popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment