Skip to content

Instantly share code, notes, and snippets.

@bprashanth
Last active July 11, 2016 03:19
Show Gist options
  • Save bprashanth/950889ec9e12e5d740706c042445deed to your computer and use it in GitHub Desktop.
Save bprashanth/950889ec9e12e5d740706c042445deed to your computer and use it in GitHub Desktop.

First make your service type=NodePort

Then create an instance group in UI (console.cloud.google.com), with some pool of instances from one of your zones:

gcloud compute --project $PROJECT instance-groups create unmanaged $K8S_IG
gcloud compute --project $PROJECTinstance-groups unmanaged add-instances $K8S_IG --instances $NODE,$NODE_1...

Add the Service NodePort to the InstanceGroup:

gcloud compute --project $PROJECT instance-groups set-named-ports $K8S_G --named-ports svc1:$SVC1_NODE_PORT

Create a health check:

gcloud compute --project $PROJECT http-health-checks create "svc1-health-check" --port $SVC1_NODE_PORT

Create a backend service:

gcloud compute --project $PROJECT backend-services create "svc1-backends" --port $SVC1_NODE_PORT --protocol "HTTP" --http-health-check "svc1-health-check"

Add the backend to the IG:

gcloud compute --project $PROJECT backend-services add-backend "svc1-backends" --balancing-mode "UTILIZATION" --instance-group $K8S_IG

Create a firewall rule:

gcloud compute firewall-rules create allow-130-211-0-0-22  --source-ranges 130.211.0.0/22  --allow tcp:30000-32767

Where 30000-32767 is the nodeport range (you can replace it with just your nodeport) and that /22 is the range of ips for lb health checks (it's always that).

There are actually a bunch of other resources you need, but for the rest, using the ui is better. Now you should be able to navigate to the gce console and click on networking > http loadbalancing, and do what seems natural (url map, plug your backend in there etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment