Updates for k8s updates to forwarding-rule/target-pool naming

This commit is contained in:
Joshua Thompson 2015-05-08 13:09:36 -07:00
Родитель 889bf99e1e
Коммит f36f80c376
4 изменённых файлов: 40 добавлений и 15 удалений

Просмотреть файл

@ -109,8 +109,18 @@ $ gcloud compute firewall-rules create vtctld --allow tcp:15000
# get the address of the load balancer for vtctld
$ gcloud compute forwarding-rules list
NAME REGION IP_ADDRESS IP_PROTOCOL TARGET
vtctld us-central1 12.34.56.78 TCP us-central1/targetPools/vtctld
NAME REGION IP_ADDRESS IP_PROTOCOL TARGET
aa6f47950f5a011e4b8f242010af0fe1 us-central1 12.34.56.78 TCP us-central1/targetPools/aa6f47950f5a011e4b8f242010af0fe1
```
Note that Kubernetes will generate the name of the forwarding-rule and
target-pool based on a hash of source/target IP addresses. If there are
multiple rules (perhaps due to running other services on GKE), use the following
to determine the correct target pool:
```
$ util/get_forwarded_pool.sh example us-central1 15000
aa6f47950f5a011e4b8f242010af0fe1
```
In the example above, you would then access vtctld at

Просмотреть файл

@ -16,8 +16,8 @@ for i in `seq 1 $num_ssds`; do
gcloud compute disks delete $base_ssd_name$i --zone $GKE_ZONE -q
done
vtctld="k8s-${GKE_CLUSTER_NAME}-default-vtctld"
vtgate="k8s-${GKE_CLUSTER_NAME}-default-vtgate"
vtctld=`util/get_forwarded_pool.sh $GKE_CLUSTER_NAME $gke_region 15000`
vtgate=`util/get_forwarded_pool.sh $GKE_CLUSTER_NAME $gke_region 15001`
gcloud compute forwarding-rules delete $vtctld -q --region=$gke_region
gcloud compute forwarding-rules delete $vtgate -q --region=$gke_region

Просмотреть файл

@ -24,6 +24,8 @@ MAX_VTTABLET_TOPO_WAIT_RETRIES=${MAX_VTTABLET_TOPO_WAIT_RETRIES:-180}
BENCHMARK_CLUSTER=${BENCHMARK_CLUSTER:-true}
VTGATE_COUNT=${VTGATE_COUNT:-0}
# Get region from zone (everything to last dash)
gke_region=`echo $GKE_ZONE | sed "s/-[^-]*$//"`
vttablet_template='vttablet-pod-template.yaml'
vtgate_script='vtgate-up.sh'
if $BENCHMARK_CLUSTER; then
@ -152,10 +154,11 @@ wait_for_running_tasks vttablet $total_tablet_count
wait_for_running_tasks vtgate $vtgate_count
echo Creating firewall rule for vtctld...
vtctl_port=15000
gcloud compute firewall-rules create ${GKE_CLUSTER_NAME}-vtctld --allow tcp:$vtctl_port
vtctl_ip=`gcloud compute forwarding-rules list | grep $GKE_CLUSTER_NAME | grep vtctld | awk '{print $3}'`
vtctl_server="$vtctl_ip:$vtctl_port"
vtctld_port=15000
gcloud compute firewall-rules create ${GKE_CLUSTER_NAME}-vtctld --allow tcp:$vtctld_port
vtctld_pool=`util/get_forwarded_pool.sh $GKE_CLUSTER_NAME $gke_region $vtctld_port`
vtctld_ip=`gcloud compute forwarding-rules list | grep $vtctld_pool | awk '{print $3}'`
vtctl_server="$vtctld_ip:$vtctld_port"
kvtctl="$GOPATH/bin/vtctlclient -server $vtctl_server"
echo Waiting for tablets to be visible in the topology
@ -204,13 +207,9 @@ echo Done
echo Creating firewall rule for vtgate
vtgate_port=15001
gcloud compute firewall-rules create ${GKE_CLUSTER_NAME}-vtgate --allow tcp:$vtgate_port
vtgate_ip=`gcloud compute forwarding-rules list | grep $GKE_CLUSTER_NAME | grep vtgate | awk '{print $3}'`
if [ -z "$vtgate_ip" ]
then
vtgate_server="No firewall rules created for vtgate. Add createExternalLoadBalancer: true if access to vtgate is desired"
else
vtgate_server="$vtgate_ip:$vtgate_port"
fi
vtgate_pool=`util/get_forwarded_pool.sh $GKE_CLUSTER_NAME $gke_region $vtgate_port`
vtgate_ip=`gcloud compute forwarding-rules list | grep $vtgate_pool | awk '{print $3}'`
vtgate_server="$vtgate_ip:$vtgate_port"
if [ -n "$NEWRELIC_LICENSE_KEY" -a $GKE_SSD_SIZE_GB -gt 0 ]; then
for i in `seq 1 $num_nodes`; do

Просмотреть файл

@ -0,0 +1,16 @@
#!/bin/bash
cluster_name=$1
region=$2
port=$3
target_pools=`gcloud compute target-pools list | awk 'NR>1 {print $1}'`
for pool in $target_pools; do
if [ -n "`gcloud compute target-pools describe $pool --region $region | grep k8s-$cluster_name-node`" ]; then
if [ -n "`gcloud compute forwarding-rules describe $pool --region $region | grep "portRange: $port"`" ]; then
echo $pool
exit 0
fi
fi
done
exit -1