Skip to content

Instantly share code, notes, and snippets.

@gbevan
Last active January 19, 2019 11:26
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 gbevan/42e1b6bd4d6e2b9f81b23c7b55945162 to your computer and use it in GitHub Desktop.
Save gbevan/42e1b6bd4d6e2b9f81b23c7b55945162 to your computer and use it in GitHub Desktop.
Simple kubernetes environment selector from command line
#!/bin/bash
# List your kubernetes environments here, they will each equate to a
# rc file named k8s_envname.rc in the same folder as this script:
ENVS="
openstack
k8sdev6443
"
# Prompt user to select environment:
export k8ssel=$(
zenity --list \
--title="Choose k8s env" \
--column="k8s" \
$ENVS \
2>/dev/null
)
if [ "$k8ssel" == "" ]
then
echo "aborting..."
exit 0
fi
BINDIR=$(dirname $0)
# Start a new shell for the selected environment
bash --rcfile $BINDIR/k8s_${k8ssel}.rc -i
. ~/.bashrc
export PS1="$PS1[$k8ssel] "
export KUBECONFIG=~/k8s/k8sdev/admin.conf
# add any other environment settings as needed
export VAULT_SKIP_VERIFY=1
export VAULT_ADDR=https://your.vault.host/vault
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment