Commit 3541a93f authored by Alan Grosskurth's avatar Alan Grosskurth

gce: Prefer MASTER_ADVERTISE_ADDRESS in apiserver setup

MASTER_ADVERTISE_ADDRESS is used to set the --advertise-address flag for the apiserver. It's useful for running the apiserver behind a load balancer. However, if PROJECT_ID, TOKEN_URL, TOKEN_BODY, and NODE_NETWORK are all set, the GCE VM's external IP address will be fetched and used instead and MASTER_ADVERTISE_ADDRESS will be ignored. Change this behavior so that MASTER_ADVERTISE_ADDRESS takes precedence because it's more specific. We still fall back to using the VM's external IP address if the other variables are set. Also: Pass --ssh-user and --ssh-keyfile flags if both PROXY_SSH_USER and MASTER_ADVERTISE_ADDRESS is set.
parent b726b2ef
...@@ -1622,15 +1622,19 @@ function start-kube-apiserver { ...@@ -1622,15 +1622,19 @@ function start-kube-apiserver {
if [[ -n "${FEATURE_GATES:-}" ]]; then if [[ -n "${FEATURE_GATES:-}" ]]; then
params+=" --feature-gates=${FEATURE_GATES}" params+=" --feature-gates=${FEATURE_GATES}"
fi fi
if [[ -n "${PROJECT_ID:-}" && -n "${TOKEN_URL:-}" && -n "${TOKEN_BODY:-}" && -n "${NODE_NETWORK:-}" ]]; then if [[ -n "${MASTER_ADVERTISE_ADDRESS:-}" ]]; then
params+=" --advertise-address=${MASTER_ADVERTISE_ADDRESS}"
if [[ -n "${PROXY_SSH_USER:-}" ]]; then
params+=" --ssh-user=${PROXY_SSH_USER}"
params+=" --ssh-keyfile=/etc/srv/sshproxy/.sshkeyfile"
fi
elif [[ -n "${PROJECT_ID:-}" && -n "${TOKEN_URL:-}" && -n "${TOKEN_BODY:-}" && -n "${NODE_NETWORK:-}" ]]; then
local -r vm_external_ip=$(get-metadata-value "instance/network-interfaces/0/access-configs/0/external-ip") local -r vm_external_ip=$(get-metadata-value "instance/network-interfaces/0/access-configs/0/external-ip")
if [[ -n "${PROXY_SSH_USER:-}" ]]; then if [[ -n "${PROXY_SSH_USER:-}" ]]; then
params+=" --advertise-address=${vm_external_ip}" params+=" --advertise-address=${vm_external_ip}"
params+=" --ssh-user=${PROXY_SSH_USER}" params+=" --ssh-user=${PROXY_SSH_USER}"
params+=" --ssh-keyfile=/etc/srv/sshproxy/.sshkeyfile" params+=" --ssh-keyfile=/etc/srv/sshproxy/.sshkeyfile"
fi fi
elif [ -n "${MASTER_ADVERTISE_ADDRESS:-}" ]; then
params="${params} --advertise-address=${MASTER_ADVERTISE_ADDRESS}"
fi fi
local webhook_authn_config_mount="" local webhook_authn_config_mount=""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment