mirror of https://github.com/k3s-io/k3s
Make local clusters work painlessly with kubeconfig
parent
18c1dfd61b
commit
61cc821506
|
@ -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[@]}}" "${@+$@}"
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue