Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 # Run this script from its directory, to correctly pick up nat_startup.sh: | |
|
ghost stip (do not use)
2015/04/14 00:36:43
this is intended for humans, not some automated th
Sergey Berezin (google)
2015/04/16 04:39:07
Yes. This is how I'd fix a fried NAT box when I ge
| |
| 3 # cd scripts | |
| 4 # ./nat_setup.sh | |
| 5 | |
| 6 PROJECT="chrome-infra-mon-proxy" | |
| 7 REGION="us-central1" | |
| 8 INSTANCE_TYPE="n1-standard-2" | |
| 9 GAE_VM1_TAG="managed-gae-vm1" | |
| 10 GAE_VM2_TAG="managed-gae-vm2" | |
| 11 GAE_VM3_TAG="managed-gae-vm3" | |
| 12 | |
| 13 function delete_instance { | |
| 14 # delete_instance instance-name zone-name | |
| 15 gcloud compute -q --project "$PROJECT" instances delete "$1" --zone "$2" | |
| 16 } | |
| 17 function create_instance { | |
| 18 # create_instance instance-name zone-name ip-name | |
| 19 gcloud compute -q --project "$PROJECT" instances create $1 --project "$PROJE CT" --machine-type $INSTANCE_TYPE --zone $2 --image ubuntu-14-04 --network defau lt --can-ip-forward --tags nat --address $3 --metadata-from-file startup-script= nat_startup.sh | |
| 20 } | |
| 21 | |
| 22 function create_nat_route { | |
| 23 # create_nat_route route-name tag instance-name instance-zone | |
| 24 echo "Creating new route to hijack traffic from VM tag $2" | |
| 25 gcloud compute --project "$PROJECT" routes create "$1" --network default --d estination-range 0.0.0.0/0 --next-hop-instance "$3" --next-hop-instance-zone "$4 " --tags "$2" --priority 800 | |
| 26 } | |
| 27 | |
| 28 function delete_nat_backend { | |
| 29 # Deletes NAT routes. | |
| 30 gcloud compute --project "$PROJECT" routes delete managed-vm1-nat-route | |
| 31 gcloud compute --project "$PROJECT" routes delete managed-vm2-nat-route | |
| 32 gcloud compute --project "$PROJECT" routes delete managed-vm3-nat-route | |
| 33 } | |
| 34 | |
| 35 function create_nat_backend { | |
| 36 create_nat_route managed-vm1-nat-route "$GAE_VM1_TAG" nat-box1 "$REGION-a" | |
| 37 create_nat_route managed-vm2-nat-route "$GAE_VM2_TAG" nat-box2 "$REGION-b" | |
| 38 create_nat_route managed-vm3-nat-route "$GAE_VM3_TAG" nat-box3 "$REGION-f" | |
| 39 } | |
| 40 | |
| 41 # Respin the NAT box VMs. Controlled individually, in case only some | |
| 42 # of them have problems. | |
| 43 if false; then | |
| 44 delete_instance nat-box1 "$REGION-a" | |
| 45 create_instance nat-box1 "$REGION-a" proxy1 | |
| 46 fi | |
| 47 | |
| 48 if false; then | |
| 49 delete_instance nat-box2 "$REGION-b" | |
| 50 create_instance nat-box2 "$REGION-b" proxy2 | |
| 51 fi | |
| 52 | |
| 53 if false; then | |
| 54 delete_instance nat-box3 "$REGION-f" | |
| 55 create_instance nat-box3 "$REGION-f" proxy3 | |
| 56 fi | |
| OLD | NEW |