Skip to content

Instantly share code, notes, and snippets.

@timperrett
Created November 27, 2018 17:25
Show Gist options
  • Save timperrett/74308cc6ff40b95df2304577f36b2735 to your computer and use it in GitHub Desktop.
Save timperrett/74308cc6ff40b95df2304577f36b2735 to your computer and use it in GitHub Desktop.
function kubeui(){
if [ ! "$#" -eq 1 ]; then
echo -e "Usage:"
echo -e "kubeui <clustername>"
else
cluster_name="${1}"
if kubectl config use-context "${cluster_name}"; then
echo "[INFO] switched to cluster '${cluster_name}'"
awsaccess renew-role admin@lyft-level5
if [ $(lsof -nP -i4TCP:8001 | grep LISTEN | wc -l | awk '{print $1}') = "0" ]; then
kubectl proxy 1> /dev/null &
else
kill -9 $(lsof -nP -i4TCP:8001 | grep LISTEN | awk '{print $2}')
kubectl proxy 1> /dev/null &
fi
aws-iam-authenticator token -i "${cluster_name}" | jq -r .status.token | pbcopy
echo "[OK] login token copied onto your pasteboard"
open http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
else
echo "[ERROR] unable to switch to cluster context '${cluster_name}'"
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment