VSCode Bridge to (EKS) kubernetes

Photo by Steve Adams on Unsplash

VSCode Bridge to (EKS) kubernetes

Getting bridge to kubernetes to work with AWS's EKS needs some fussin'.

If you are authorized via SSO, managed by aws-vault this should help.

You need to have the aws-vault exec <profile> loaded before running k-creds. Relevant AWS environment variables are written to ~/.envs_temp which is rigged to be automatically loaded in new (ZSH) shells' that will be available to VSCode.

You should now be able to see nodes in your cluster.

function k-creds () {                                                                                                                                                            
    RC_FILE="${RC_FILE:-~/.zshrc}"                                                                                                                                                
    DEV_PROFILE="${DEV_PROFILE:-dev-profile}"                                                                                                                             

    # load                                                                                                                                                                           
    grep -q envs_temp $RC_FILE || (echo "[ -f ~/.envs_temp ] && source ~/.envs_temp" >> $RC_FILE; echo "Updated $RC_FILE")
    aws-vault export $DEV_PROFILE | sed 's/^/export /' > ~/.envs_temp && echo "Got AWS '$DEV_PROFILE' credentials, please restart vs-code"                                     
}