{"id":17968719,"url":"https://github.com/pires/consul-lb-gce","last_synced_at":"2025-03-25T10:32:34.774Z","repository":{"id":45890056,"uuid":"48076945","full_name":"pires/consul-lb-gce","owner":"pires","description":"A smart Google Cloud Engine load-balancer manager for Consul backed services.","archived":false,"fork":false,"pushed_at":"2021-11-29T14:27:09.000Z","size":369,"stargazers_count":10,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T01:11:13.487Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pires.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-16T00:27:59.000Z","updated_at":"2023-03-10T11:55:23.000Z","dependencies_parsed_at":"2022-07-25T02:18:01.965Z","dependency_job_id":null,"html_url":"https://github.com/pires/consul-lb-gce","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pires%2Fconsul-lb-gce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pires%2Fconsul-lb-gce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pires%2Fconsul-lb-gce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pires%2Fconsul-lb-gce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pires","download_url":"https://codeload.github.com/pires/consul-lb-gce/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245444410,"owners_count":20616370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T14:41:20.764Z","updated_at":"2025-03-25T10:32:33.916Z","avatar_url":"https://github.com/pires.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":":sectnums:\n:numbered:\n:toc: macro\n:toc-title:\n:toclevels: 99\n\n# consul-lb-gce\n\nA smart Google Cloud Engine load-balancer manager for https://www.consul.io/[Consul] backed services.\n\ntoc::[]\n\n## Pre-requisites\n\n* Go 1.5.x\n* `make`\n* Some Go tools\n** http://getgb.io[`gb`] - `go get -u github.com/constabulary/gb/...`\n* A running Nomad cluster with Consul integration on Google Compute Engine\n\n## Development\n\n### Build\n\nThe following will take care of generating code, build and run tests.\n```\nmake all\n```\n\n### Test\n\n**Attention:** Testing locally is not supported, but if you're feeling adventurous, take a look at https://github.com/pires/nomad-vagrant-coreos-cluster[this Nomad cluster with Consul integration].\n\nNow, before deploying the `nginx` service example, let's compile and run the load-balancer manager. On another terminal window, execute:\n\n```\ngb build all\ncat config.toml.sample \u003e config.toml\n\n(..edit config.toml accordingly..)\n\nGOOGLE_APPLICATION_CREDENTIALS=~/Work/gce/my-project-1234567890.json bin/consul-lb-google -config config.toml -alsologtostderr\n```\n\nYou should see something like:\n```\nI1218 16:20:36.877575       1 main.go:45] Starting..\nI1218 16:20:36.877909       1 main.go:54] Initializing cloud client [Project ID: my-project, Network: my-network, Allowed Zones: []string{\"us-east1-d\", \"europe-west1-d\", \"asia-east1-c\"}]..\nI1218 16:20:36.878178       1 main.go:61] Connecting to Consul at consul.service.consul:8500..\nI1218 16:20:36.878198       1 main.go:69] Initiating registry..\nI1218 16:20:36.878214       1 main.go:76] Waiting for service updates..\n```\n\nDeploy the `nginx` example:\n\n```\nnomad run web.hcl\n```\n\nLooking at the load-balancer manager terminal window, one should see something like:\n```\nI1218 16:21:07.931230       1 main.go:129] Initializing service [web]..\nI1218 16:21:07.931263       1 cloud.go:78] Creating instance groups for [web]..\nI1218 16:21:07.931269       1 cloud.go:81] Creating instance group [us-east1-d-web] in zone [us-east1-d].\nI1218 16:21:11.751202       1 cloud.go:81] Creating instance group [europe-west1-d-web] in zone [europe-west1-d].\nI1218 16:21:15.747546       1 cloud.go:81] Creating instance group [asia-east1-c-web] in zone [asia-east1-c].\nI1218 16:21:19.653728       1 cloud.go:101] Created instance groups for [web] successfully\nI1218 16:21:19.653771       1 main.go:135] Watching service [web].\nW1218 16:21:19.653780       1 main.go:195] Adding instance [client-us-01.c.my-project.internal].\nI1218 16:21:19.654187       1 main.go:203] Service has new port [11080]\nI1218 16:21:19.654217       1 cloud.go:133] Adding 1 instances into instance group [web]\nI1218 16:21:19.963843       1 cloud.go:182] There are 1 instances to add to instance group [web] on zone [us-east1-d]. Adding..\nI1218 16:21:20.764763       1 cloud.go:187] There are no instances to add to instance group [web] on zone [europe-west1-d].\nI1218 16:21:21.049794       1 cloud.go:187] There are no instances to add to instance group [web] on zone [asia-east1-c].\nI1218 16:21:21.049813       1 cloud.go:191] Added 1 instances into instance group [web]\nI1218 16:21:21.049820       1 cloud.go:244] Setting instance group [web] port [11080]..\nI1218 16:21:22.229671       1 cloud.go:266] Creating/updating load-balancer for [web:11080].\nI1218 16:21:53.131003       1 gce.go:546] Created/updated firewall rule with success.\nI1218 16:21:56.995704       1 gce.go:557] Created/updated HTTP health-check with success.\nI1218 16:22:02.429513       1 gce.go:568] Created/updated backend service with success.\nI1218 16:22:06.350711       1 gce.go:574] Created URL map with success.\nI1218 16:22:10.381194       1 gce.go:580] Created target HTTP proxy with success.\nI1218 16:22:17.401182       1 gce.go:587] Created global forwarding rule with success.\nI1218 16:22:17.401215       1 cloud.go:268] Load-balancer [web] created successfully.\n```\n\nValidate that load-balancing is working alright.\n\nNow, stop it:\n\n```\nnomad stop web\n```\n\nLooking again at the load-balancer manager terminal window, one should see something like:\n\n```\nI1218 16:26:17.601174       1 cloud.go:273] Removing load-balancer for [web].\nI1218 16:26:24.390783       1 gce.go:598] Removed global forwarding rule with success.\nI1218 16:26:28.139698       1 gce.go:604] Removed target HTTP proxy with success.\nI1218 16:26:32.001725       1 gce.go:610] Removed URL map with success.\nI1218 16:26:35.774544       1 gce.go:616] Removed backend service with success.\nI1218 16:26:39.477543       1 gce.go:622] Removed HTTP health-check with success.\nI1218 16:27:07.202854       1 gce.go:628] Removed firewall rule with success.\nI1218 16:27:07.202878       1 cloud.go:275] Load-balancer [web] removed successfully.\nI1218 16:27:07.202886       1 cloud.go:109] Removing instance groups for [web]..\nW1218 16:27:10.853607       1 cloud.go:115] Removed instance group [us-east1-d-web] from zone [us-east1-d].\nW1218 16:27:14.319410       1 cloud.go:115] Removed instance group [europe-west1-d-web] from zone [europe-west1-d].\nW1218 16:27:18.036865       1 cloud.go:115] Removed instance group [asia-east1-c-web] from zone [asia-east1-c].\nI1218 16:27:18.036888       1 cloud.go:127] Removing instance groups for [web] completed successfully\nI1218 16:27:18.036896       1 main.go:149] Stopped watching service [web].\n```\n\n### Scaling\n\nThe manager supports scaling the number of instances of a service as well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpires%2Fconsul-lb-gce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpires%2Fconsul-lb-gce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpires%2Fconsul-lb-gce/lists"}