diff --git a/cluster/kubectl.sh b/cluster/kubectl.sh index 9cf53d0e5fab0..0c30236eca0ce 100755 --- a/cluster/kubectl.sh +++ b/cluster/kubectl.sh @@ -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" @@ -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[@]}}" "${@+$@}" diff --git a/cluster/local/util.sh b/cluster/local/util.sh deleted file mode 100644 index 090bb74ad9c03..0000000000000 --- a/cluster/local/util.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Copyright 2014 Google Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -function detect-master () { - echo "Running locally" -} diff --git a/docs/getting-started-guides/locally.md b/docs/getting-started-guides/locally.md index d6b1b63fe579b..1e2d774bb4cb0 100644 --- a/docs/getting-started-guides/locally.md +++ b/docs/getting-started-guides/locally.md @@ -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 diff --git a/hack/local-up-cluster.sh b/hack/local-up-cluster.sh index afa574bdb279e..764844514f931 100755 --- a/hack/local-up-cluster.sh +++ b/hack/local-up-cluster.sh @@ -98,6 +98,7 @@ cleanup() [[ -n "${ETCD_PID-}" ]] && kill "${ETCD_PID}" [[ -n "${ETCD_DIR-}" ]] && rm -rf "${ETCD_DIR}" + exit 0 } @@ -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