mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #31437 from jszczepkowski/ha-poc-debian2
Automatic merge from submit-queue Implemented creation of HA master for GCE on debian.
This commit is contained in:
commit
60840140ab
@ -40,8 +40,32 @@ function create-master-instance {
|
||||
|
||||
write-master-env
|
||||
prepare-startup-script
|
||||
gcloud compute instances create "${MASTER_NAME}" \
|
||||
${address_opt} \
|
||||
create-master-instance-internal "${MASTER_NAME}" "${address_opt}" "${preemptible_master}"
|
||||
}
|
||||
|
||||
function replicate-master-instance() {
|
||||
local existing_master_zone="${1}"
|
||||
local existing_master_name="${2}"
|
||||
local existing_master_replicas="${3}"
|
||||
|
||||
local kube_env="$(get-metadata "${existing_master_zone}" "${existing_master_name}" kube-env)"
|
||||
# Substitute INITIAL_ETCD_CLUSTER to enable etcd clustering.
|
||||
kube_env="$(echo "${kube_env}" | grep -v "INITIAL_ETCD_CLUSTER")"
|
||||
kube_env="$(echo -e "${kube_env}\nINITIAL_ETCD_CLUSTER: '${existing_master_replicas},${REPLICA_NAME}'")"
|
||||
echo "${kube_env}" > ${KUBE_TEMP}/master-kube-env.yaml
|
||||
get-metadata "${existing_master_zone}" "${existing_master_name}" cluster-name > ${KUBE_TEMP}/cluster-name.txt
|
||||
get-metadata "${existing_master_zone}" "${existing_master_name}" startup-script > ${KUBE_TEMP}/configure-vm.sh
|
||||
|
||||
create-master-instance-internal "${REPLICA_NAME}"
|
||||
}
|
||||
|
||||
function create-master-instance-internal() {
|
||||
local -r master_name="${1}"
|
||||
local -r address_option="${2:-}"
|
||||
local -r preemptible_master="${3:-}"
|
||||
|
||||
gcloud compute instances create "${master_name}" \
|
||||
${address_option} \
|
||||
--project "${PROJECT}" \
|
||||
--zone "${ZONE}" \
|
||||
--machine-type "${MASTER_SIZE}" \
|
||||
@ -53,7 +77,18 @@ function create-master-instance {
|
||||
--can-ip-forward \
|
||||
--metadata-from-file \
|
||||
"startup-script=${KUBE_TEMP}/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" \
|
||||
--disk "name=${master_name}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no" \
|
||||
--boot-disk-size "${MASTER_ROOT_DISK_SIZE:-10}" \
|
||||
${preemptible_master}
|
||||
}
|
||||
|
||||
# TODO: This is most likely not the best way to read metadata from the existing master.
|
||||
function get-metadata() {
|
||||
local zone="${1}"
|
||||
local name="${2}"
|
||||
local key="${3}"
|
||||
gcloud compute ssh "${name}" \
|
||||
--project "${PROJECT}" \
|
||||
--zone="${zone}" \
|
||||
--command "curl \"http://metadata.google.internal/computeMetadata/v1/instance/attributes/${key}\" -H \"Metadata-Flavor: Google\"" 2>/dev/null
|
||||
}
|
||||
|
@ -601,9 +601,8 @@ function kube-up() {
|
||||
parse-master-env
|
||||
create-nodes
|
||||
elif [[ ${KUBE_EXPERIMENTAL_REPLICATE_EXISTING_MASTER:-} == "true" ]]; then
|
||||
# TODO(jsz): implement adding replica for other distributions.
|
||||
if [[ "${MASTER_OS_DISTRIBUTION}" != "gci" ]]; then
|
||||
echo "Master replication supported only for gci"
|
||||
if [[ "${MASTER_OS_DISTRIBUTION}" != "gci" && "${MASTER_OS_DISTRIBUTION}" != "debian" ]]; then
|
||||
echo "Master replication supported only for gci and debian"
|
||||
return 1
|
||||
fi
|
||||
create-loadbalancer
|
||||
|
Loading…
Reference in New Issue
Block a user