@@ -53,9 +53,28 @@ __create_gke() {
5353 --max-unavailable-upgrade 0 \
5454 --enable-autorepair
5555
56+ __init_internal_loadbalancer
5657 __init $@
5758}
5859
60+ __init_internal_loadbalancer () {
61+ # GCE internal load balancer requires a
62+ # proxy-only subnet in the same region and VPC
63+
64+ # IMPORTANT: this IPv4 is ONLY for GCP default us-central1, you need to update the range
65+ # to match your desired subnet settings
66+ # Check if proxy-only subnet already exists, L7 LB only
67+ if ! gcloud compute networks subnets describe proxy-only-subnet \
68+ --region=$region --network=default > /dev/null 2>&1 ; then
69+ echo " Creating proxy-only subnet for internal load balancer..."
70+ gcloud compute networks subnets create proxy-only-subnet \
71+ --purpose=REGIONAL_MANAGED_PROXY --role=ACTIVE --region=$region \
72+ --network=default --range=10.120.0.0/23
73+ else
74+ echo " proxy-only-subnet already exists, skipping creation."
75+ fi
76+ }
77+
5978# setup the deployment enviroment for Elastic Stack
6079__init () {
6180 # Set kubectl to target the created cluster
@@ -144,6 +163,7 @@ __password_reset() {
144163__status () {
145164 passwd=$( __password)
146165 lb_ip=` kubectl get services ${es_cluster_name} -es-http -o jsonpath=' {.status.loadBalancer.ingress[0].ip}' `
166+ ilb_ip=` kubectl get ingress ${es_cluster_name} -es-ingress -o jsonpath=' {.status.loadBalancer.ingress[0].ip}' `
147167
148168 kbn_ip=` kubectl get service dingo-demo-kbn-kb-http -o jsonpath=' {.status.loadBalancer.ingress[0].ip}' `
149169 kbn_port=5601
@@ -152,11 +172,13 @@ __status() {
152172 echo ; echo " =================================" ; echo
153173 echo " Elasticsearch status: "
154174 curl -u " elastic:$passwd " -k " https://$lb_ip :9200"
175+ curl -u " elastic:$passwd " " http://$ilb_ip "
155176
156177 echo ; echo " ---------------------------------" ; echo
157178
158- echo " Kibana: " ${kbn_url}
159- echo " Elasticsearch: " " https://$lb_ip :9200"
179+ echo " Kibana public address: " ${kbn_url}
180+ echo " Elasticsearch public address: " " https://$lb_ip :9200"
181+ echo " Elasticsearch internal address: " " http://$ilb_ip "
160182 echo " Username: " elastic
161183 echo " Password: " ${passwd}
162184 echo " =================================" ; echo
0 commit comments