mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
Providing kubeconfig file is now the switch for standalone mode
Replaces use of --api-servers with --kubeconfig in Kubelet args across the turnup scripts. In many cases this involves generating a kubeconfig file for the Kubelet and placing it in the correct location on the node.
This commit is contained in:
@@ -33,6 +33,38 @@ readonly POOL_PATH=/var/lib/libvirt/images/kubernetes
|
||||
|
||||
[ ! -d "${POOL_PATH}" ] && (echo "$POOL_PATH" does not exist ; exit 1 )
|
||||
|
||||
# Creates a kubeconfig file for the kubelet.
|
||||
# Args: address (e.g. "http://localhost:8080"), destination file path
|
||||
function create-kubelet-kubeconfig() {
|
||||
local apiserver_address="${1}"
|
||||
local destination="${2}"
|
||||
if [[ -z "${apiserver_address}" ]]; then
|
||||
echo "Must provide API server address to create Kubelet kubeconfig file!"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${destination}" ]]; then
|
||||
echo "Must provide destination path to create Kubelet kubeconfig file!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Creating Kubelet kubeconfig file"
|
||||
local dest_dir="$(dirname "${destination}")"
|
||||
mkdir -p "${dest_dir}" &>/dev/null || sudo mkdir -p "${dest_dir}"
|
||||
sudo=$(test -w "${dest_dir}" || echo "sudo -E")
|
||||
cat <<EOF | ${sudo} tee "${destination}" > /dev/null
|
||||
apiVersion: v1
|
||||
kind: Config
|
||||
clusters:
|
||||
- cluster:
|
||||
server: ${apiserver_address}
|
||||
name: local
|
||||
contexts:
|
||||
- context:
|
||||
cluster: local
|
||||
name: local
|
||||
current-context: local
|
||||
EOF
|
||||
}
|
||||
|
||||
# join <delim> <list...>
|
||||
# Concatenates the list elements with the delimiter passed as first parameter
|
||||
#
|
||||
@@ -279,6 +311,7 @@ function kube-up {
|
||||
export KUBE_SERVER="http://192.168.10.1:8080"
|
||||
export CONTEXT="libvirt-coreos"
|
||||
create-kubeconfig
|
||||
create-kubelet-kubeconfig "http://${MASTER_IP}:8080" "${POOL_PATH}/kubernetes/kubeconfig/kubelet.kubeconfig"
|
||||
|
||||
wait-cluster-readiness
|
||||
|
||||
|
||||
Reference in New Issue
Block a user