Commit ad7d009b authored by Robert Bailey's avatar Robert Bailey

Merge pull request #6990 from jlowdermilk/fix-kubeconfig

Retry Move KUBECONFIG into common.sh, change default to new location
parents 26a70a52 2a8291a6
...@@ -22,6 +22,8 @@ set -o pipefail ...@@ -22,6 +22,8 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
DEFAULT_KUBECONFIG="${HOME}/.kube/config"
# Generate kubeconfig data for the created cluster. # Generate kubeconfig data for the created cluster.
# Assumed vars: # Assumed vars:
# KUBE_USER # KUBE_USER
...@@ -36,6 +38,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. ...@@ -36,6 +38,7 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
function create-kubeconfig() { function create-kubeconfig() {
local kubectl="${KUBE_ROOT}/cluster/kubectl.sh" local kubectl="${KUBE_ROOT}/cluster/kubectl.sh"
KUBECONFIG=${KUBECONFIG:-$DEFAULT_KUBECONFIG}
# KUBECONFIG determines the file we write to, but it may not exist yet # KUBECONFIG determines the file we write to, but it may not exist yet
if [[ ! -e "${KUBECONFIG}" ]]; then if [[ ! -e "${KUBECONFIG}" ]]; then
mkdir -p $(dirname "${KUBECONFIG}") mkdir -p $(dirname "${KUBECONFIG}")
...@@ -60,6 +63,7 @@ function create-kubeconfig() { ...@@ -60,6 +63,7 @@ function create-kubeconfig() {
# KUBECONFIG # KUBECONFIG
# CONTEXT # CONTEXT
function clear-kubeconfig() { function clear-kubeconfig() {
KUBECONFIG=${KUBECONFIG:-$DEFAULT_KUBECONFIG}
local kubectl="${KUBE_ROOT}/cluster/kubectl.sh" local kubectl="${KUBE_ROOT}/cluster/kubectl.sh"
"${kubectl}" config unset "clusters.${CONTEXT}" "${kubectl}" config unset "clusters.${CONTEXT}"
"${kubectl}" config unset "users.${CONTEXT}" "${kubectl}" config unset "users.${CONTEXT}"
...@@ -85,6 +89,7 @@ function clear-kubeconfig() { ...@@ -85,6 +89,7 @@ function clear-kubeconfig() {
# KUBE_USER,KUBE_PASSWORD will be empty if no current-context is set, or # KUBE_USER,KUBE_PASSWORD will be empty if no current-context is set, or
# the current-context user does not exist or contain basicauth entries. # the current-context user does not exist or contain basicauth entries.
function get-kubeconfig-basicauth() { function get-kubeconfig-basicauth() {
KUBECONFIG=${KUBECONFIG:-$DEFAULT_KUBECONFIG}
# Templates to safely extract the username,password for the current-context # Templates to safely extract the username,password for the current-context
# user. The long chain of 'with' commands avoids indexing nil if any of the # user. The long chain of 'with' commands avoids indexing nil if any of the
# entries ("current-context", "contexts"."current-context", "users", etc) # entries ("current-context", "contexts"."current-context", "users", etc)
......
...@@ -673,7 +673,6 @@ function kube-up { ...@@ -673,7 +673,6 @@ function kube-up {
echo "Kubernetes cluster created." echo "Kubernetes cluster created."
# TODO use token instead of basic auth # TODO use token instead of basic auth
export KUBECONFIG="${HOME}/.kube/.kubeconfig"
export KUBE_CERT="/tmp/kubecfg.crt" export KUBE_CERT="/tmp/kubecfg.crt"
export KUBE_KEY="/tmp/kubecfg.key" export KUBE_KEY="/tmp/kubecfg.key"
export CA_CERT="/tmp/kubernetes.ca.crt" export CA_CERT="/tmp/kubernetes.ca.crt"
......
...@@ -19,6 +19,7 @@ set -o nounset ...@@ -19,6 +19,7 @@ set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/cluster/common.sh"
# --- Find local test binaries. # --- Find local test binaries.
...@@ -104,7 +105,7 @@ if [[ -z "${AUTH_CONFIG:-}" ]]; then ...@@ -104,7 +105,7 @@ if [[ -z "${AUTH_CONFIG:-}" ]]; then
) )
elif [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then elif [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then
auth_config=( auth_config=(
"--kubeconfig=${HOME}/.kube/.kubeconfig" "--kubeconfig=${KUBECONFIG:-$DEFAULT_KUBECONFIG}"
) )
elif [[ "${KUBERNETES_PROVIDER}" == "aws" ]]; then elif [[ "${KUBERNETES_PROVIDER}" == "aws" ]]; then
auth_config=( auth_config=(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment