mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #81073 from mborsz/cnat
Few improvements to Cloud NAT
This commit is contained in:
commit
b084336460
@ -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}"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
@ -3851,13 +3856,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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user