Few improvements to cloud nat

This commit is contained in:
Maciej Borsz 2019-08-07 13:36:58 +02:00
parent ea4570a412
commit afbe1898e7
3 changed files with 9 additions and 9 deletions

View File

@ -496,6 +496,7 @@ WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSche
# Whether to set up a private GCE cluster, i.e. a cluster where nodes have only private IPs.
GCE_PRIVATE_CLUSTER="${KUBE_GCE_PRIVATE_CLUSTER:-false}"
GCE_PRIVATE_CLUSTER_PORTS_PER_VM="${KUBE_GCE_PRIVATE_CLUSTER_PORTS_PER_VM:-}"
# Optional: Create apiserver konnectivity server and agent.
ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE="${KUBE_ENABLE_EGRESS_VIA_KONNECTIVITY_SERVICE:-false}"

View File

@ -537,6 +537,7 @@ WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSche
# Whether to set up a private GCE cluster, i.e. a cluster where nodes have only private IPs.
GCE_PRIVATE_CLUSTER="${KUBE_GCE_PRIVATE_CLUSTER:-false}"
GCE_PRIVATE_CLUSTER_PORTS_PER_VM="${KUBE_GCE_PRIVATE_CLUSTER_PORTS_PER_VM:-}"
ETCD_LISTEN_CLIENT_IP=0.0.0.0

View File

@ -2495,6 +2495,10 @@ function detect-subnetworks() {
# NETWORK
function create-cloud-nat-router() {
if [[ ${GCE_PRIVATE_CLUSTER:-} == "true" ]]; then
if gcloud compute routers describe "$NETWORK-nat-router" --project $NETWORK_PROJECT --region $REGION &>/dev/null; then
echo "Cloud nat already exists"
return 0
fi
gcloud compute routers create "$NETWORK-nat-router" \
--project $NETWORK_PROJECT \
--region $REGION \
@ -2503,8 +2507,9 @@ function create-cloud-nat-router() {
--project $NETWORK_PROJECT \
--router-region $REGION \
--router "$NETWORK-nat-router" \
--nat-all-subnet-ip-ranges \
--auto-allocate-nat-external-ips
--nat-primary-subnet-ip-ranges \
--auto-allocate-nat-external-ips \
${GCE_PRIVATE_CLUSTER_PORTS_PER_VM:+--min-ports-per-vm ${GCE_PRIVATE_CLUSTER_PORTS_PER_VM}}
fi
}
@ -3843,13 +3848,6 @@ function check-resources() {
return 1
fi
if [[ ${GCE_PRIVATE_CLUSTER:-} == "true" ]]; then
if gcloud compute routers describe --project "${NETWORK_PROJECT}" --region "${REGION}" "${NETWORK}-nat-router" &>/dev/null; then
KUBE_RESOURCE_FOUND="Cloud NAT router"
return 1
fi
fi
# No resources found.
return 0
}