Sunday, March 14, 2021

Kubernetes: kubectl config management.

 Config kubectl

Script to set current contexts:

clear


production="true"


[[ $0 != $BASH_SOURCE ]] && contextName=$BASH_SOURCE || contextName=$0


contextName=${contextName##*/}


export KUBECONFIG=~/.kube/config.${contextName}


kubectl config use-context ${contextName}


#starts 38;5; for the foreground and 48;5; for the background, then the color number


if [ $production == "true" ]; then

  export PS1="\e[38;5;016;0;48;5;166m\u@\H:\w - \e[5m$contextName\e[25m $ "

else

  export PS1="\e[38;5;012;48;5;015m\u@\H:\w - $contextName $ "

fi

  

kubectl config get-contexts

No comments:

Post a Comment