mirror of https://github.com/k3s-io/k3s
Add the GCE cluster name to instance metadata.
parent
80e201f74b
commit
30b78e4d7f
|
@ -427,6 +427,15 @@ function build-runtime-config() {
|
|||
:
|
||||
}
|
||||
|
||||
# Writes the cluster name into a temporary file.
|
||||
# Assumed vars
|
||||
# CLUSTER_NAME
|
||||
function write-cluster-name {
|
||||
cat >"${KUBE_TEMP}/cluster-name.txt" << EOF
|
||||
${CLUSTER_NAME}
|
||||
EOF
|
||||
}
|
||||
|
||||
function write-master-env {
|
||||
# If the user requested that the master be part of the cluster, set the
|
||||
# environment variable to program the master kubelet to register itself.
|
||||
|
|
|
@ -41,6 +41,7 @@ RKT_VERSION=${KUBE_RKT_VERSION:-0.5.5}
|
|||
|
||||
NETWORK=${KUBE_GCE_NETWORK:-default}
|
||||
INSTANCE_PREFIX="${KUBE_GCE_INSTANCE_PREFIX:-kubernetes}"
|
||||
CLUSTER_NAME="${CLUSTER_NAME:-${INSTANCE_PREFIX}}"
|
||||
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
||||
MASTER_TAG="${INSTANCE_PREFIX}-master"
|
||||
NODE_TAG="${INSTANCE_PREFIX}-minion"
|
||||
|
|
|
@ -41,6 +41,7 @@ RKT_VERSION=${KUBE_RKT_VERSION:-0.5.5}
|
|||
|
||||
NETWORK=${KUBE_GCE_NETWORK:-e2e}
|
||||
INSTANCE_PREFIX="${KUBE_GCE_INSTANCE_PREFIX:-e2e-test-${USER}}"
|
||||
CLUSTER_NAME="${CLUSTER_NAME:-${INSTANCE_PREFIX}}"
|
||||
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
||||
MASTER_TAG="${INSTANCE_PREFIX}-master"
|
||||
NODE_TAG="${INSTANCE_PREFIX}-minion"
|
||||
|
|
|
@ -25,7 +25,8 @@ function create-node-instance-template() {
|
|||
"kube-env=${KUBE_TEMP}/node-kube-env.yaml" \
|
||||
"user-data=${KUBE_ROOT}/cluster/gce/coreos/node.yaml" \
|
||||
"configure-node=${KUBE_ROOT}/cluster/gce/coreos/configure-node.sh" \
|
||||
"configure-kubelet=${KUBE_ROOT}/cluster/gce/coreos/configure-kubelet.sh"
|
||||
"configure-kubelet=${KUBE_ROOT}/cluster/gce/coreos/configure-kubelet.sh" \
|
||||
"cluster-name=${KUBE_TEMP}/cluster-name.txt"
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +65,7 @@ function create-master-instance() {
|
|||
--scopes "storage-ro,compute-rw,monitoring,logging-write" \
|
||||
--can-ip-forward \
|
||||
--metadata-from-file \
|
||||
"kube-env=${KUBE_TEMP}/master-kube-env.yaml,user-data=${KUBE_ROOT}/cluster/gce/coreos/master.yaml,configure-node=${KUBE_ROOT}/cluster/gce/coreos/configure-node.sh,configure-kubelet=${KUBE_ROOT}/cluster/gce/coreos/configure-kubelet.sh" \
|
||||
"kube-env=${KUBE_TEMP}/master-kube-env.yaml,user-data=${KUBE_ROOT}/cluster/gce/coreos/master.yaml,configure-node=${KUBE_ROOT}/cluster/gce/coreos/configure-node.sh,configure-kubelet=${KUBE_ROOT}/cluster/gce/coreos/configure-kubelet.sh,cluster-name=${KUBE_TEMP}/cluster-name.txt" \
|
||||
--disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no" \
|
||||
${preemptible_master}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ function create-master-instance {
|
|||
--scopes "storage-ro,compute-rw,monitoring,logging-write" \
|
||||
--can-ip-forward \
|
||||
--metadata-from-file \
|
||||
"startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh,kube-env=${KUBE_TEMP}/master-kube-env.yaml" \
|
||||
"startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh,kube-env=${KUBE_TEMP}/master-kube-env.yaml,cluster-name=${KUBE_TEMP}/cluster-name.txt" \
|
||||
--disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no" \
|
||||
${preemptible_master}
|
||||
}
|
||||
|
@ -61,5 +61,6 @@ function create-node-instance-template {
|
|||
local template_name="$1"
|
||||
create-node-template "$template_name" "${scope_flags}" \
|
||||
"startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh" \
|
||||
"kube-env=${KUBE_TEMP}/node-kube-env.yaml"
|
||||
"kube-env=${KUBE_TEMP}/node-kube-env.yaml" \
|
||||
"cluster-name=${KUBE_TEMP}/cluster-name.txt"
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ function create-node-instance-template {
|
|||
create-node-template "$template_name" "${scope_flags[*]}" \
|
||||
"kube-env=${KUBE_TEMP}/node-kube-env.yaml" \
|
||||
"user-data=${KUBE_ROOT}/cluster/gce/trusty/node.yaml" \
|
||||
"configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh"
|
||||
"configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh" \
|
||||
"cluster-name=${KUBE_TEMP}/cluster-name.txt"
|
||||
}
|
||||
|
||||
# create-master-instance creates the master instance. If called with
|
||||
|
@ -62,6 +63,6 @@ function create-master-instance {
|
|||
--scopes "storage-ro,compute-rw,monitoring,logging-write" \
|
||||
--can-ip-forward \
|
||||
--metadata-from-file \
|
||||
"kube-env=${KUBE_TEMP}/master-kube-env.yaml,user-data=${KUBE_ROOT}/cluster/gce/trusty/master.yaml,configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh" \
|
||||
"kube-env=${KUBE_TEMP}/master-kube-env.yaml,user-data=${KUBE_ROOT}/cluster/gce/trusty/master.yaml,configure-sh=${KUBE_ROOT}/cluster/gce/trusty/configure.sh,cluster-name=${KUBE_TEMP}/cluster-name.txt" \
|
||||
--disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no"
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ function detect-node-names {
|
|||
done
|
||||
echo "INSTANCE_GROUPS=${INSTANCE_GROUPS[*]}" >&2
|
||||
echo "NODE_NAMES=${NODE_NAMES[*]}" >&2
|
||||
else
|
||||
else
|
||||
echo "INSTANCE_GROUPS=" >&2
|
||||
echo "NODE_NAMES=" >&2
|
||||
fi
|
||||
|
@ -393,9 +393,7 @@ function get-template-name-from-version {
|
|||
# Robustly try to create an instance template.
|
||||
# $1: The name of the instance template.
|
||||
# $2: The scopes flag.
|
||||
# $3: The minion start script metadata from file.
|
||||
# $4: The kube-env metadata.
|
||||
# $5 and others: Additional user defined metadata.
|
||||
# $3 and others: Metadata entries (must all be from a file).
|
||||
function create-node-template {
|
||||
detect-project
|
||||
local template_name="$1"
|
||||
|
@ -530,6 +528,7 @@ function kube-up {
|
|||
else
|
||||
check-existing
|
||||
create-network
|
||||
write-cluster-name
|
||||
create-master
|
||||
create-nodes-firewall
|
||||
create-nodes-template
|
||||
|
@ -670,7 +669,7 @@ function create-nodes-template() {
|
|||
# Assumes:
|
||||
# - MAX_INSTANCES_PER_MIG
|
||||
# - NUM_NODES
|
||||
# exports:
|
||||
# exports:
|
||||
# - NUM_MIGS
|
||||
function set_num_migs() {
|
||||
local defaulted_max_instances_per_mig=${MAX_INSTANCES_PER_MIG:-500}
|
||||
|
|
Loading…
Reference in New Issue