Skip to content

Commit

Permalink
Make local clusters work painlessly with kubeconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
j3ffml committed Feb 13, 2015
1 parent 18c1dfd commit 61cc821
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 38 deletions.
20 changes: 7 additions & 13 deletions cluster/kubectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ if [[ "$KUBERNETES_PROVIDER" == "gke" ]]; then
detect-project &> /dev/null
export PATH=$(get_absolute_dirname $kubectl):$PATH
kubectl="${GCLOUD}"
fi

if [[ "$KUBERNETES_PROVIDER" == "vagrant" ]]; then
# When we are using vagrant it has hard coded auth. We repeat that here so that
# we don't clobber auth that might be used for a publicly facing cluster.
config=(
"--auth-path=$HOME/.kubernetes_vagrant_auth"
)
elif [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
# GKE runs kubectl through gcloud.
config=(
"preview"
Expand All @@ -121,12 +112,15 @@ elif [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
"--zone=${ZONE}"
"--cluster=${CLUSTER_NAME}"
)
elif [[ "$KUBERNETES_PROVIDER" == "vagrant" ]]; then
# When we are using vagrant it has hard coded auth. We repeat that here so that
# we don't clobber auth that might be used for a publicly facing cluster.
config=(
"--auth-path=$HOME/.kubernetes_vagrant_auth"
)
fi

detect-master > /dev/null
if [[ -n "${KUBE_MASTER_IP-}" && -z "${KUBERNETES_MASTER-}" ]]; then
export KUBERNETES_MASTER=https://${KUBE_MASTER_IP}
fi
echo "current-context: \"$(${kubectl} config view -o template --template='{{index . "current-context"}}')\""

echo "Running:" "${kubectl}" "${config[@]:+${config[@]}}" "${@+$@}" >&2
"${kubectl}" "${config[@]:+${config[@]}}" "${@+$@}"
19 changes: 0 additions & 19 deletions cluster/local/util.sh

This file was deleted.

7 changes: 2 additions & 5 deletions docs/getting-started-guides/locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ hack/local-up-cluster.sh
This will build and start a lightweight local cluster, consisting of a master
and a single minion. Type Control-C to shut it down.

You can use the cluster/kubectl.sh script to interact with the local cluster.
You must set the KUBERNETES_PROVIDER environment variable.
You can use the cluster/kubectl.sh script to interact with the local cluster. hack/local-up-cluster.sh will
print the commands to run to point kubectl at the local cluster.

```
export KUBERNETES_PROVIDER=local
```

### Running a container

Expand Down
5 changes: 4 additions & 1 deletion hack/local-up-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ cleanup()

[[ -n "${ETCD_PID-}" ]] && kill "${ETCD_PID}"
[[ -n "${ETCD_DIR-}" ]] && rm -rf "${ETCD_DIR}"

exit 0
}

Expand Down Expand Up @@ -160,7 +161,9 @@ Logs:
To start using your cluster, open up another terminal/tab and run:
export KUBERNETES_PROVIDER=local
cluster/kubectl.sh config set-cluster local --server=http://${API_HOST}:${API_PORT} --insecure-skip-tls-verify=true --global
cluster/kubectl.sh config set-context local --cluster=local --global
cluster/kubectl.sh config use-context local
cluster/kubectl.sh
EOF

Expand Down

0 comments on commit 61cc821

Please sign in to comment.