
# get token from service account
# token=$(kubectl --kubeconfig ~/.kube/config_$CLUSTER_NAME -n kube-system get secret $DEFAULT_SECRET_NAME -o json | jq '.data.token' | tr -d '"' | base64 --decode)
token=$(kubectl --kubeconfig $KUBECONFIG -n kube-system get secret $DEFAULT_SECRET_NAME -o json | jq '.data.token' | tr -d '"' | base64 --decode)

# get current context to pull data directly from the local kube config file
# context=`kubectl --kubeconfig ~/.kube/config_$CLUSTER_NAME config current-context`
context=`kubectl --kubeconfig $KUBECONFIG config current-context`

# get cluster name of context
# name=`kubectl --kubeconfig ~/.kube/config_$CLUSTER_NAME config get-contexts $context | awk '{print $3}' | tail -n 1`
name=`kubectl --kubeconfig $KUBECONFIG config get-contexts $context | awk '{print $3}' | tail -n 1`

# get endpoint of current context 
# endpoint=`kubectl --kubeconfig ~/.kube/config_$CLUSTER_NAME config view -o jsonpath="{.clusters[?(@.name == \"$name\")].cluster.server}"`