mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
Fix subnet cleanup logic when using IP-aliases with custom subnets
This commit is contained in:
parent
99e77a76be
commit
be2e5e65d3
@ -1817,8 +1817,7 @@ function delete-network() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function delete-subnetworks() {
|
function delete-subnetworks() {
|
||||||
if [[ ${ENABLE_IP_ALIASES:-} != "true" ]]; then
|
# If running in custom mode network we need to delete subnets manually.
|
||||||
# If running in custom mode network we need to delete subnets
|
|
||||||
mode="$(check-network-mode)"
|
mode="$(check-network-mode)"
|
||||||
if [[ "${mode}" == "CUSTOM" ]]; then
|
if [[ "${mode}" == "CUSTOM" ]]; then
|
||||||
if [[ "${ENABLE_BIG_CLUSTER_SUBNETS}" = "true" ]]; then
|
if [[ "${ENABLE_BIG_CLUSTER_SUBNETS}" = "true" ]]; then
|
||||||
@ -1831,12 +1830,15 @@ function delete-subnetworks() {
|
|||||||
echo "Deleting custom subnet..."
|
echo "Deleting custom subnet..."
|
||||||
gcloud --quiet compute networks subnets delete "${SUBNETWORK}" --project "${NETWORK_PROJECT}" --region="${REGION}" || true
|
gcloud --quiet compute networks subnets delete "${SUBNETWORK}" --project "${NETWORK_PROJECT}" --region="${REGION}" || true
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Only delete automatically created subnets.
|
# If we reached here, it means we're not using custom network.
|
||||||
if [[ ${IP_ALIAS_SUBNETWORK} == ${INSTANCE_PREFIX}-subnet-default ]]; then
|
# So the only thing we need to check is if IP-aliases was turned
|
||||||
|
# on and we created a subnet for it. If so, we should delete it.
|
||||||
|
if [[ ${ENABLE_IP_ALIASES:-} == "true" ]]; then
|
||||||
|
# Only delete the subnet if we created it (i.e it's not pre-existing).
|
||||||
|
if [[ -z "${KUBE_GCE_IP_ALIAS_SUBNETWORK:-}" ]]; then
|
||||||
echo "Removing auto-created subnet ${NETWORK}:${IP_ALIAS_SUBNETWORK}"
|
echo "Removing auto-created subnet ${NETWORK}:${IP_ALIAS_SUBNETWORK}"
|
||||||
if [[ -n $(gcloud beta compute networks subnets describe \
|
if [[ -n $(gcloud beta compute networks subnets describe \
|
||||||
--project "${NETWORK_PROJECT}" \
|
--project "${NETWORK_PROJECT}" \
|
||||||
@ -1848,6 +1850,7 @@ function delete-subnetworks() {
|
|||||||
${IP_ALIAS_SUBNETWORK}
|
${IP_ALIAS_SUBNETWORK}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generates SSL certificates for etcd cluster. Uses cfssl program.
|
# Generates SSL certificates for etcd cluster. Uses cfssl program.
|
||||||
|
Loading…
Reference in New Issue
Block a user