Created
April 11, 2019 08:01
-
-
Save keirbadger/8e3e065b2a9585126c17d7b916c2591b to your computer and use it in GitHub Desktop.
Script to automatically login to EKS Kubernetes dashboard using aws-iam-authenticator (from Mac)
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
| kubectl config use-context new-prod;aws-iam-authenticator token -i [CLUSTER NAME] -r [AWS IAM ACCOUNT WITH ACCESS TO EKS] | jq -r .status.token |pbcopy | |
| kill -9 $(ps -ef | grep "kubectl proxy" | grep -v grep | cut -c6-13) | |
| kubectl proxy & | |
| python k8sdash_login.py |
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
| from selenium.webdriver.common.keys import Keys | |
| from selenium import webdriver | |
| import pyperclip | |
| browser = webdriver.Chrome() | |
| browser.get('http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login') | |
| browser.find_element_by_xpath("//*[@id='radio_6']").click() | |
| inputElement = browser.find_element_by_xpath("//*[@id='input_7']") | |
| inputElement.send_keys(pyperclip.paste()) | |
| inputElement.send_keys(Keys.ENTER) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to be authenticated with AWS user/role before running script