Merge pull request #51725 from nicksardo/gce-plumb-netvars

Automatic merge from submit-queue (batch tested with PRs 51805, 51725, 50925, 51474, 51638)

GCE: Plumb network & subnetwork to master

**Which issue this PR fixes** *
Fixes #51714

/assign @bowei 

**Release note**:
```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-09-03 11:10:00 -07:00 committed by GitHub
commit 9637f46122
4 changed files with 65 additions and 19 deletions

View File

@ -610,6 +610,8 @@ ENV_TIMESTAMP: $(yaml-quote $(date -u +%Y-%m-%dT%T%z))
INSTANCE_PREFIX: $(yaml-quote ${INSTANCE_PREFIX}) INSTANCE_PREFIX: $(yaml-quote ${INSTANCE_PREFIX})
NODE_INSTANCE_PREFIX: $(yaml-quote ${NODE_INSTANCE_PREFIX}) NODE_INSTANCE_PREFIX: $(yaml-quote ${NODE_INSTANCE_PREFIX})
NODE_TAGS: $(yaml-quote ${NODE_TAGS:-}) NODE_TAGS: $(yaml-quote ${NODE_TAGS:-})
NODE_NETWORK: $(yaml-quote ${NODE_NETWORK:-})
NODE_SUBNETWORK: $(yaml-quote ${NODE_SUBNETWORK:-})
CLUSTER_IP_RANGE: $(yaml-quote ${CLUSTER_IP_RANGE:-10.244.0.0/16}) CLUSTER_IP_RANGE: $(yaml-quote ${CLUSTER_IP_RANGE:-10.244.0.0/16})
SERVER_BINARY_TAR_URL: $(yaml-quote ${server_binary_tar_url}) SERVER_BINARY_TAR_URL: $(yaml-quote ${server_binary_tar_url})
SERVER_BINARY_TAR_HASH: $(yaml-quote ${SERVER_BINARY_TAR_HASH}) SERVER_BINARY_TAR_HASH: $(yaml-quote ${SERVER_BINARY_TAR_HASH})

View File

@ -229,24 +229,36 @@ EOF
api-endpoint = ${GCE_API_ENDPOINT} api-endpoint = ${GCE_API_ENDPOINT}
EOF EOF
fi fi
if [[ -n "${PROJECT_ID:-}" && -n "${TOKEN_URL:-}" && -n "${TOKEN_BODY:-}" && -n "${NODE_NETWORK:-}" ]]; then if [[ -n "${TOKEN_URL:-}" && -n "${TOKEN_BODY:-}" ]]; then
use_cloud_config="true" use_cloud_config="true"
cat <<EOF >>/etc/gce.conf cat <<EOF >>/etc/gce.conf
token-url = ${TOKEN_URL} token-url = ${TOKEN_URL}
token-body = ${TOKEN_BODY} token-body = ${TOKEN_BODY}
project-id = ${PROJECT_ID}
network-name = ${NODE_NETWORK}
EOF EOF
if [[ -n "${NETWORK_PROJECT_ID:-}" ]]; then fi
cat <<EOF >>/etc/gce.conf if [[ -n "${PROJECT_ID:-}" ]]; then
use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
project-id = ${PROJECT_ID}
EOF
fi
if [[ -n "${NETWORK_PROJECT_ID:-}" ]]; then
use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
network-project-id = ${NETWORK_PROJECT_ID} network-project-id = ${NETWORK_PROJECT_ID}
EOF EOF
fi fi
if [[ -n "${NODE_SUBNETWORK:-}" ]]; then if [[ -n "${NODE_NETWORK:-}" ]]; then
cat <<EOF >>/etc/gce.conf use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
network-name = ${NODE_NETWORK}
EOF
fi
if [[ -n "${NODE_SUBNETWORK:-}" ]]; then
use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
subnetwork-name = ${NODE_SUBNETWORK} subnetwork-name = ${NODE_SUBNETWORK}
EOF EOF
fi
fi fi
if [[ -n "${NODE_INSTANCE_PREFIX:-}" ]]; then if [[ -n "${NODE_INSTANCE_PREFIX:-}" ]]; then
use_cloud_config="true" use_cloud_config="true"

View File

@ -389,24 +389,36 @@ EOF
api-endpoint = ${GCE_API_ENDPOINT} api-endpoint = ${GCE_API_ENDPOINT}
EOF EOF
fi fi
if [[ -n "${PROJECT_ID:-}" && -n "${TOKEN_URL:-}" && -n "${TOKEN_BODY:-}" && -n "${NODE_NETWORK:-}" ]]; then if [[ -n "${TOKEN_URL:-}" && -n "${TOKEN_BODY:-}" ]]; then
use_cloud_config="true" use_cloud_config="true"
cat <<EOF >>/etc/gce.conf cat <<EOF >>/etc/gce.conf
token-url = ${TOKEN_URL} token-url = ${TOKEN_URL}
token-body = ${TOKEN_BODY} token-body = ${TOKEN_BODY}
project-id = ${PROJECT_ID}
network-name = ${NODE_NETWORK}
EOF EOF
if [[ -n "${NETWORK_PROJECT_ID:-}" ]]; then fi
cat <<EOF >>/etc/gce.conf if [[ -n "${PROJECT_ID:-}" ]]; then
use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
project-id = ${PROJECT_ID}
EOF
fi
if [[ -n "${NETWORK_PROJECT_ID:-}" ]]; then
use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
network-project-id = ${NETWORK_PROJECT_ID} network-project-id = ${NETWORK_PROJECT_ID}
EOF EOF
fi fi
if [[ -n "${NODE_SUBNETWORK:-}" ]]; then if [[ -n "${NODE_NETWORK:-}" ]]; then
cat <<EOF >>/etc/gce.conf use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
network-name = ${NODE_NETWORK}
EOF
fi
if [[ -n "${NODE_SUBNETWORK:-}" ]]; then
use_cloud_config="true"
cat <<EOF >>/etc/gce.conf
subnetwork-name = ${NODE_SUBNETWORK} subnetwork-name = ${NODE_SUBNETWORK}
EOF EOF
fi
fi fi
if [[ -n "${NODE_INSTANCE_PREFIX:-}" ]]; then if [[ -n "${NODE_INSTANCE_PREFIX:-}" ]]; then
use_cloud_config="true" use_cloud_config="true"

View File

@ -86,6 +86,7 @@ fi
NODE_INSTANCE_PREFIX="${INSTANCE_PREFIX}-minion" NODE_INSTANCE_PREFIX="${INSTANCE_PREFIX}-minion"
NODE_TAGS="${NODE_TAG}" NODE_TAGS="${NODE_TAG}"
NODE_NETWORK="${NETWORK}"
ALLOCATE_NODE_CIDRS=true ALLOCATE_NODE_CIDRS=true
PREEXISTING_NETWORK=false PREEXISTING_NETWORK=false
@ -806,12 +807,28 @@ function expand-default-subnetwork() {
--quiet --quiet
} }
# Vars set:
# NODE_SUBNETWORK
function create-subnetworks() { function create-subnetworks() {
NODE_SUBNETWORK=$(gcloud beta compute networks subnets list \
--network=${NETWORK} \
--regions=${REGION} \
--project=${PROJECT} \
--limit=1 \
--format='value(name)' 2>/dev/null)
if [[ -z ${NODE_SUBNETWORK:-} ]]; then
echo "${color_red}Could not find subnetwork with region ${REGION}, network ${NETWORK}, and project ${PROJECT}"
exit 1
fi
echo "Found subnet for region ${REGION} in network ${NETWORK}: ${NODE_SUBNETWORK}"
case ${ENABLE_IP_ALIASES} in case ${ENABLE_IP_ALIASES} in
true) echo "IP aliases are enabled. Creating subnetworks.";; true) echo "IP aliases are enabled. Creating subnetworks.";;
false) false)
echo "IP aliases are disabled." echo "IP aliases are disabled."
if [[ "${ENABLE_BIG_CLUSTER_SUBNETS}" = "true" ]]; then if [[ "${ENABLE_BIG_CLUSTER_SUBNETS}" = "true" ]]; then
if [[ "${PREEXISTING_NETWORK}" != "true" ]]; then if [[ "${PREEXISTING_NETWORK}" != "true" ]]; then
expand-default-subnetwork expand-default-subnetwork
else else
@ -823,6 +840,9 @@ function create-subnetworks() {
exit 1;; exit 1;;
esac esac
NODE_SUBNETWORK=${IP_ALIAS_SUBNETWORK}
echo "Using IP Aliases subnet ${NODE_SUBNETWORK}"
# Look for the alias subnet, it must exist and have a secondary # Look for the alias subnet, it must exist and have a secondary
# range configured. # range configured.
local subnet=$(gcloud beta compute networks subnets describe \ local subnet=$(gcloud beta compute networks subnets describe \