Skip to content

Commit 9b5e541

Browse files
committed
Add custom subnet to cluster creation
1 parent 91f8e47 commit 9b5e541

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tests/scripts/create-gke-cluster.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ if [ "${IPV6_ENABLE}" = "true" ]; then
3030
--region=${GKE_CLUSTER_REGION}
3131

3232
gcloud compute firewall-rules create ${GKE_CLUSTER_NAME}-firewall --network ${GKE_CLUSTER_NAME}-network --allow tcp:22,tcp:3389,icmp
33-
34-
echo "Deleting subnet ${GKE_CLUSTER_NAME}-subnet (if exists)..."
35-
gcloud compute networks subnets delete ${GKE_CLUSTER_NAME}-subnet --region=${GKE_CLUSTER_REGION} --quiet || true
36-
echo "Deleting network ${GKE_CLUSTER_NAME}-network (if exists)..."
37-
gcloud compute networks delete ${GKE_CLUSTER_NAME}-network --quiet || true
38-
echo "Deleting firewall rule ${GKE_CLUSTER_NAME}-firewall (if exists)..."
39-
gcloud compute firewall-rules delete ${GKE_CLUSTER_NAME}-firewall --quiet || true
4033
fi
4134

4235
gcloud container clusters create "${GKE_CLUSTER_NAME}" \
@@ -52,7 +45,8 @@ gcloud container clusters create "${GKE_CLUSTER_NAME}" \
5245
--logging=SYSTEM,WORKLOAD \
5346
--machine-type "${GKE_MACHINE_TYPE}" \
5447
--num-nodes "${GKE_NUM_NODES}" \
55-
--no-enable-insecure-kubelet-readonly-port
48+
--no-enable-insecure-kubelet-readonly-port \
49+
--subnetwork=${GKE_CLUSTER_NAME}-subnet
5650

5751
# Add current IP to GKE master control node access, if this script is not invoked during a CI run.
5852
if [ "${IS_CI}" = "false" ]; then

tests/scripts/delete-gke-cluster.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@ set -eo pipefail
55
source scripts/vars.env
66

77
gcloud container clusters delete "${GKE_CLUSTER_NAME}" --zone "${GKE_CLUSTER_ZONE}" --project "${GKE_PROJECT}" --quiet
8+
9+
echo "Deleting firewall rule ${GKE_CLUSTER_NAME}-firewall (if exists)..."
10+
gcloud compute firewall-rules delete ${GKE_CLUSTER_NAME}-firewall --quiet || true
11+
echo "Deleting subnet ${GKE_CLUSTER_NAME}-subnet (if exists)..."
12+
gcloud compute networks subnets delete ${GKE_CLUSTER_NAME}-subnet --region=${GKE_CLUSTER_REGION} --quiet || true
13+
echo "Deleting network ${GKE_CLUSTER_NAME}-network (if exists)..."
14+
gcloud compute networks delete ${GKE_CLUSTER_NAME}-network --quiet || true

0 commit comments

Comments
 (0)