Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pires/consul-lb-gce
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: dffrntmedia/consul-lb-gce
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Jun 18, 2019

  1. update wait package

    mbarouski committed Jun 18, 2019
    Copy the full SHA
    d763da7 View commit details
  2. connected glide

    mbarouski committed Jun 18, 2019
    Copy the full SHA
    d6ed474 View commit details
  3. correct glide.yaml

    mbarouski committed Jun 18, 2019
    Copy the full SHA
    e96e292 View commit details
  4. Copy the full SHA
    5d43188 View commit details

Commits on Jun 19, 2019

  1. added tag parser

    mbarouski committed Jun 19, 2019
    Copy the full SHA
    347e0ac View commit details
  2. Copy the full SHA
    3bc434f View commit details
  3. Copy the full SHA
    70f8a89 View commit details
  4. ignore .DS_Store

    mbarouski committed Jun 19, 2019
    Copy the full SHA
    1643e3b View commit details

Commits on Jun 20, 2019

  1. Correct health check

    mbarouski committed Jun 20, 2019
    Copy the full SHA
    466df89 View commit details
  2. updating of existing url map with host_rule and path_matcher; work wi…

    …th existing instance group;
    mbarouski committed Jun 20, 2019
    Copy the full SHA
    bf46180 View commit details
  3. firewall rule is back

    mbarouski committed Jun 20, 2019
    Copy the full SHA
    3ba7d0d View commit details
  4. adding of dns record set

    mbarouski committed Jun 20, 2019
    Copy the full SHA
    4d60899 View commit details
  5. Copy the full SHA
    f4146b4 View commit details

Commits on Jun 21, 2019

  1. Copy the full SHA
    061291e View commit details
  2. Copy the full SHA
    662ba2e View commit details
  3. Copy the full SHA
    5bc085d View commit details
  4. added affinity and cdn

    mbarouski committed Jun 21, 2019
    Copy the full SHA
    f1c7f9e View commit details
  5. Copy the full SHA
    0d4cd05 View commit details
  6. Copy the full SHA
    0954997 View commit details
  7. rm excess options

    mbarouski committed Jun 21, 2019
    Copy the full SHA
    46f6817 View commit details
  8. correct endpoint

    mbarouski committed Jun 21, 2019
    Copy the full SHA
    bf2820c View commit details
  9. refactoring (in progress)

    mbarouski committed Jun 21, 2019
    Copy the full SHA
    c972a8d View commit details

Commits on Jun 24, 2019

  1. refactoring p.1

    mbarouski committed Jun 24, 2019
    Copy the full SHA
    735533e View commit details
  2. Copy the full SHA
    b1199ca View commit details
  3. documentation

    mbarouski committed Jun 24, 2019
    Copy the full SHA
    d07dd3f View commit details
  4. tip fix

    mbarouski committed Jun 24, 2019
    Copy the full SHA
    c3713c8 View commit details
  5. changes for prod usage

    mbarouski committed Jun 24, 2019
    Copy the full SHA
    84e031a View commit details
  6. Copy the full SHA
    0da75e9 View commit details
  7. Copy the full SHA
    0e57841 View commit details
  8. fixed instance name

    mbarouski committed Jun 24, 2019
    Copy the full SHA
    4bb5901 View commit details
  9. Copy the full SHA
    79a09b8 View commit details

Commits on Jun 25, 2019

  1. Merge pull request #1 from dffrntmedia/mb/setup

    Load Balancing with Network Endpoint Groups
    mbarouski authored Jun 25, 2019
    Copy the full SHA
    c2d284f View commit details
  2. BEIN-307

    Changes:
    - Added mutex on url map updating.
    mbarouski committed Jun 25, 2019
    Copy the full SHA
    4c8031d View commit details
  3. BEIN-307

    Changes:
    - Correct filtering out host rules.
    mbarouski committed Jun 25, 2019
    Copy the full SHA
    12982fe View commit details
  4. BEIN-307

    Changes:
    - Add apth matcher only if host rule is added.
    mbarouski committed Jun 25, 2019
    Copy the full SHA
    6b2c48e View commit details

Commits on Jun 26, 2019

  1. Merge pull request #2 from dffrntmedia/BEIN-307

    BEIN-307
    mbarouski authored Jun 26, 2019
    Copy the full SHA
    80cd38b View commit details

Commits on Oct 21, 2019

  1. Update README.adoc

    mbarouski authored Oct 21, 2019
    Copy the full SHA
    ca07a71 View commit details
  2. Update README.adoc

    mbarouski authored Oct 21, 2019
    Copy the full SHA
    212a9fa View commit details
  3. Update README.adoc

    mbarouski authored Oct 21, 2019
    Copy the full SHA
    4c9a180 View commit details
  4. Update README.adoc

    mbarouski authored Oct 21, 2019
    Copy the full SHA
    3a35a12 View commit details

Commits on Mar 10, 2020

  1. Copy the full SHA
    ac0a72e View commit details
  2. make help

    mbarouski committed Mar 10, 2020
    Copy the full SHA
    a387e79 View commit details
  3. temp-1

    mbarouski committed Mar 10, 2020
    Copy the full SHA
    45236fd View commit details
  4. Work only with one zone

    mbarouski committed Mar 10, 2020
    Copy the full SHA
    40f1c21 View commit details

Commits on Mar 11, 2020

  1. Copy the full SHA
    de7bd30 View commit details

Commits on Mar 12, 2020

  1. Copy the full SHA
    ebe6eb0 View commit details
  2. Config docs

    mbarouski committed Mar 12, 2020
    Copy the full SHA
    7d98a5c View commit details
  3. Copy the full SHA
    ff37d74 View commit details
  4. Copy the full SHA
    115cbe9 View commit details
  5. Logging

    mbarouski committed Mar 12, 2020
    Copy the full SHA
    3546ce2 View commit details
Showing with 2,345 additions and 76,666 deletions.
  1. +31 −0 .circleci/config.yml
  2. +12 −1 .gitignore
  3. +15 −0 .sonarcloud.properties
  4. +29 −21 Makefile
  5. +0 −116 README.adoc
  6. +133 −0 README.md
  7. +62 −0 cloud/cloud.go
  8. +85 −0 cloud/gce/backend-service.go
  9. +68 −0 cloud/gce/gce.go
  10. +34 −0 cloud/gce/gce_test.go
  11. +50 −0 cloud/gce/health-check.go
  12. +86 −0 cloud/gce/network-endpoint-group.go
  13. +92 −0 cloud/gce/operaton.go
  14. +109 −0 cloud/gce/url-map.go
  15. +84 −0 cloud/stub/stub.go
  16. +211 −0 config.go
  17. +0 −7 config.toml.sample
  18. +259 −0 config_test.go
  19. +20 −0 go.mod
  20. +78 −0 go.sum
  21. +308 −0 main.go
  22. +387 −0 main_test.go
  23. +14 −5 {src/github.com/pires/consul-lb-google → }/registry/consul/consul.go
  24. +5 −2 {src/github.com/pires/consul-lb-google → }/registry/registry.go
  25. +44 −0 sample.config.json
  26. +0 −290 src/github.com/pires/consul-lb-google/cloud/cloud.go
  27. +0 −757 src/github.com/pires/consul-lb-google/cloud/gce/gce.go
  28. +0 −261 src/github.com/pires/consul-lb-google/main.go
  29. +50 −0 tagparser.go
  30. +37 −0 tagparser_test.go
  31. +42 −0 util/util.go
  32. +0 −106 vendor/manifest
  33. +0 −3 vendor/src/github.com/BurntSushi/toml/COMPATIBLE
  34. +0 −14 vendor/src/github.com/BurntSushi/toml/COPYING
  35. +0 −19 vendor/src/github.com/BurntSushi/toml/Makefile
  36. +0 −220 vendor/src/github.com/BurntSushi/toml/README.md
  37. +0 −61 vendor/src/github.com/BurntSushi/toml/_examples/example.go
  38. +0 −35 vendor/src/github.com/BurntSushi/toml/_examples/example.toml
  39. +0 −22 vendor/src/github.com/BurntSushi/toml/_examples/hard.toml
  40. +0 −4 vendor/src/github.com/BurntSushi/toml/_examples/implicit.toml
  41. +0 −6 vendor/src/github.com/BurntSushi/toml/_examples/invalid-apples.toml
  42. +0 −35 vendor/src/github.com/BurntSushi/toml/_examples/invalid.toml
  43. +0 −5 vendor/src/github.com/BurntSushi/toml/_examples/readme1.toml
  44. +0 −1 vendor/src/github.com/BurntSushi/toml/_examples/readme2.toml
  45. +0 −14 vendor/src/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING
  46. +0 −14 vendor/src/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md
  47. +0 −90 vendor/src/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go
  48. +0 −14 vendor/src/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING
  49. +0 −14 vendor/src/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md
  50. +0 −131 vendor/src/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go
  51. +0 −14 vendor/src/github.com/BurntSushi/toml/cmd/tomlv/COPYING
  52. +0 −22 vendor/src/github.com/BurntSushi/toml/cmd/tomlv/README.md
  53. +0 −61 vendor/src/github.com/BurntSushi/toml/cmd/tomlv/main.go
  54. +0 −492 vendor/src/github.com/BurntSushi/toml/decode.go
  55. +0 −122 vendor/src/github.com/BurntSushi/toml/decode_meta.go
  56. +0 −950 vendor/src/github.com/BurntSushi/toml/decode_test.go
  57. +0 −27 vendor/src/github.com/BurntSushi/toml/doc.go
  58. +0 −551 vendor/src/github.com/BurntSushi/toml/encode.go
  59. +0 −542 vendor/src/github.com/BurntSushi/toml/encode_test.go
  60. +0 −19 vendor/src/github.com/BurntSushi/toml/encoding_types.go
  61. +0 −18 vendor/src/github.com/BurntSushi/toml/encoding_types_1.1.go
  62. +0 −874 vendor/src/github.com/BurntSushi/toml/lex.go
  63. +0 −498 vendor/src/github.com/BurntSushi/toml/parse.go
  64. +0 −1 vendor/src/github.com/BurntSushi/toml/session.vim
  65. +0 −91 vendor/src/github.com/BurntSushi/toml/type_check.go
  66. +0 −241 vendor/src/github.com/BurntSushi/toml/type_fields.go
  67. +0 −191 vendor/src/github.com/golang/glog/LICENSE
  68. +0 −44 vendor/src/github.com/golang/glog/README
  69. +0 −1,180 vendor/src/github.com/golang/glog/glog.go
  70. +0 −124 vendor/src/github.com/golang/glog/glog_file.go
  71. +0 −415 vendor/src/github.com/golang/glog/glog_test.go
  72. +0 −44 vendor/src/github.com/hashicorp/consul/api/README.md
  73. +0 −140 vendor/src/github.com/hashicorp/consul/api/acl.go
  74. +0 −128 vendor/src/github.com/hashicorp/consul/api/acl_test.go
  75. +0 −337 vendor/src/github.com/hashicorp/consul/api/agent.go
  76. +0 −568 vendor/src/github.com/hashicorp/consul/api/agent_test.go
  77. +0 −453 vendor/src/github.com/hashicorp/consul/api/api.go
  78. +0 −256 vendor/src/github.com/hashicorp/consul/api/api_test.go
  79. +0 −182 vendor/src/github.com/hashicorp/consul/api/catalog.go
  80. +0 −279 vendor/src/github.com/hashicorp/consul/api/catalog_test.go
  81. +0 −66 vendor/src/github.com/hashicorp/consul/api/coordinate.go
  82. +0 −54 vendor/src/github.com/hashicorp/consul/api/coordinate_test.go
  83. +0 −104 vendor/src/github.com/hashicorp/consul/api/event.go
  84. +0 −49 vendor/src/github.com/hashicorp/consul/api/event_test.go
  85. +0 −136 vendor/src/github.com/hashicorp/consul/api/health.go
  86. +0 −125 vendor/src/github.com/hashicorp/consul/api/health_test.go
  87. +0 −240 vendor/src/github.com/hashicorp/consul/api/kv.go
  88. +0 −447 vendor/src/github.com/hashicorp/consul/api/kv_test.go
  89. +0 −366 vendor/src/github.com/hashicorp/consul/api/lock.go
  90. +0 −490 vendor/src/github.com/hashicorp/consul/api/lock_test.go
  91. +0 −173 vendor/src/github.com/hashicorp/consul/api/prepared_query.go
  92. +0 −123 vendor/src/github.com/hashicorp/consul/api/prepared_query_test.go
  93. +0 −24 vendor/src/github.com/hashicorp/consul/api/raw.go
  94. +0 −477 vendor/src/github.com/hashicorp/consul/api/semaphore.go
  95. +0 −313 vendor/src/github.com/hashicorp/consul/api/semaphore_test.go
  96. +0 −217 vendor/src/github.com/hashicorp/consul/api/session.go
  97. +0 −314 vendor/src/github.com/hashicorp/consul/api/session_test.go
  98. +0 −43 vendor/src/github.com/hashicorp/consul/api/status.go
  99. +0 −37 vendor/src/github.com/hashicorp/consul/api/status_test.go
  100. +0 −194 vendor/src/github.com/hashicorp/consul/watch/funcs.go
  101. +0 −434 vendor/src/github.com/hashicorp/consul/watch/funcs_test.go
  102. +0 −116 vendor/src/github.com/hashicorp/consul/watch/plan.go
  103. +0 −54 vendor/src/github.com/hashicorp/consul/watch/plan_test.go
  104. +0 −129 vendor/src/github.com/hashicorp/consul/watch/watch.go
  105. +0 −48 vendor/src/github.com/hashicorp/consul/watch/watch_test.go
  106. +0 −363 vendor/src/github.com/hashicorp/go-cleanhttp/LICENSE
  107. +0 −30 vendor/src/github.com/hashicorp/go-cleanhttp/README.md
  108. +0 −28 vendor/src/github.com/hashicorp/go-cleanhttp/cleanhttp.go
  109. +0 −1 vendor/src/github.com/hashicorp/serf/coordinate/README.md
  110. +0 −180 vendor/src/github.com/hashicorp/serf/coordinate/client.go
  111. +0 −109 vendor/src/github.com/hashicorp/serf/coordinate/client_test.go
  112. +0 −70 vendor/src/github.com/hashicorp/serf/coordinate/config.go
  113. +0 −183 vendor/src/github.com/hashicorp/serf/coordinate/coordinate.go
  114. +0 −260 vendor/src/github.com/hashicorp/serf/coordinate/coordinate_test.go
  115. +0 −182 vendor/src/github.com/hashicorp/serf/coordinate/performance_test.go
  116. +0 −187 vendor/src/github.com/hashicorp/serf/coordinate/phantom.go
  117. +0 −27 vendor/src/github.com/hashicorp/serf/coordinate/test_util.go
  118. +0 −447 vendor/src/golang.org/x/net/context/context.go
  119. +0 −575 vendor/src/golang.org/x/net/context/context_test.go
  120. +0 −18 vendor/src/golang.org/x/net/context/ctxhttp/cancelreq.go
  121. +0 −23 vendor/src/golang.org/x/net/context/ctxhttp/cancelreq_go14.go
  122. +0 −79 vendor/src/golang.org/x/net/context/ctxhttp/ctxhttp.go
  123. +0 −72 vendor/src/golang.org/x/net/context/ctxhttp/ctxhttp_test.go
  124. +0 −26 vendor/src/golang.org/x/net/context/withtimeout_test.go
  125. +0 −3 vendor/src/golang.org/x/oauth2/AUTHORS
  126. +0 −31 vendor/src/golang.org/x/oauth2/CONTRIBUTING.md
  127. +0 −3 vendor/src/golang.org/x/oauth2/CONTRIBUTORS
  128. +0 −27 vendor/src/golang.org/x/oauth2/LICENSE
  129. +0 −64 vendor/src/golang.org/x/oauth2/README.md
  130. +0 −16 vendor/src/golang.org/x/oauth2/bitbucket/bitbucket.go
  131. +0 −25 vendor/src/golang.org/x/oauth2/client_appengine.go
  132. +0 −112 vendor/src/golang.org/x/oauth2/clientcredentials/clientcredentials.go
  133. +0 −96 vendor/src/golang.org/x/oauth2/clientcredentials/clientcredentials_test.go
  134. +0 −45 vendor/src/golang.org/x/oauth2/example_test.go
  135. +0 −16 vendor/src/golang.org/x/oauth2/facebook/facebook.go
  136. +0 −16 vendor/src/golang.org/x/oauth2/github/github.go
  137. +0 −86 vendor/src/golang.org/x/oauth2/google/appengine.go
  138. +0 −13 vendor/src/golang.org/x/oauth2/google/appengine_hook.go
  139. +0 −14 vendor/src/golang.org/x/oauth2/google/appenginevm_hook.go
  140. +0 −155 vendor/src/golang.org/x/oauth2/google/default.go
  141. +0 −150 vendor/src/golang.org/x/oauth2/google/example_test.go
  142. +0 −145 vendor/src/golang.org/x/oauth2/google/google.go
  143. +0 −67 vendor/src/golang.org/x/oauth2/google/google_test.go
  144. +0 −71 vendor/src/golang.org/x/oauth2/google/jwt.go
  145. +0 −168 vendor/src/golang.org/x/oauth2/google/sdk.go
  146. +0 −46 vendor/src/golang.org/x/oauth2/google/sdk_test.go
  147. +0 −122 vendor/src/golang.org/x/oauth2/google/testdata/gcloud/credentials
  148. +0 −2 vendor/src/golang.org/x/oauth2/google/testdata/gcloud/properties
  149. +0 −76 vendor/src/golang.org/x/oauth2/internal/oauth2.go
  150. +0 −62 vendor/src/golang.org/x/oauth2/internal/oauth2_test.go
  151. +0 −221 vendor/src/golang.org/x/oauth2/internal/token.go
  152. +0 −36 vendor/src/golang.org/x/oauth2/internal/token_test.go
  153. +0 −69 vendor/src/golang.org/x/oauth2/internal/transport.go
  154. +0 −38 vendor/src/golang.org/x/oauth2/internal/transport_test.go
  155. +0 −172 vendor/src/golang.org/x/oauth2/jws/jws.go
  156. +0 −31 vendor/src/golang.org/x/oauth2/jwt/example_test.go
  157. +0 −153 vendor/src/golang.org/x/oauth2/jwt/jwt.go
  158. +0 −134 vendor/src/golang.org/x/oauth2/jwt/jwt_test.go
  159. +0 −16 vendor/src/golang.org/x/oauth2/linkedin/linkedin.go
  160. +0 −337 vendor/src/golang.org/x/oauth2/oauth2.go
  161. +0 −471 vendor/src/golang.org/x/oauth2/oauth2_test.go
  162. +0 −16 vendor/src/golang.org/x/oauth2/odnoklassniki/odnoklassniki.go
  163. +0 −22 vendor/src/golang.org/x/oauth2/paypal/paypal.go
  164. +0 −158 vendor/src/golang.org/x/oauth2/token.go
  165. +0 −72 vendor/src/golang.org/x/oauth2/token_test.go
  166. +0 −132 vendor/src/golang.org/x/oauth2/transport.go
  167. +0 −86 vendor/src/golang.org/x/oauth2/transport_test.go
  168. +0 −16 vendor/src/golang.org/x/oauth2/vk/vk.go
  169. +0 −13,960 vendor/src/google.golang.org/api/compute/v1/compute-api.json
  170. +0 −36,286 vendor/src/google.golang.org/api/compute/v1/compute-gen.go
  171. +0 −177 vendor/src/google.golang.org/api/gensupport/json.go
  172. +0 −367 vendor/src/google.golang.org/api/gensupport/json_test.go
  173. +0 −31 vendor/src/google.golang.org/api/gensupport/params.go
  174. +0 −588 vendor/src/google.golang.org/api/googleapi/googleapi.go
  175. +0 −599 vendor/src/google.golang.org/api/googleapi/googleapi_test.go
  176. +0 −18 vendor/src/google.golang.org/api/googleapi/internal/uritemplates/LICENSE
  177. +0 −359 vendor/src/google.golang.org/api/googleapi/internal/uritemplates/uritemplates.go
  178. +0 −13 vendor/src/google.golang.org/api/googleapi/internal/uritemplates/utils.go
  179. +0 −38 vendor/src/google.golang.org/api/googleapi/transport/apikey.go
  180. +0 −182 vendor/src/google.golang.org/api/googleapi/types.go
  181. +0 −44 vendor/src/google.golang.org/api/googleapi/types_test.go
  182. +0 −327 vendor/src/google.golang.org/cloud/compute/metadata/metadata.go
  183. +0 −128 vendor/src/google.golang.org/cloud/internal/cloud.go
  184. +0 −606 vendor/src/google.golang.org/cloud/internal/datastore/datastore_v1.proto
  185. +0 −24 vendor/src/google.golang.org/cloud/internal/opts/option.go
  186. +0 −69 vendor/src/google.golang.org/cloud/internal/testutil/context.go
  187. +0 −29 vendor/src/google.golang.org/cloud/internal/transport/cancelreq.go
  188. +0 −31 vendor/src/google.golang.org/cloud/internal/transport/cancelreq_legacy.go
  189. +0 −134 vendor/src/google.golang.org/cloud/internal/transport/dial.go
  190. +0 −80 vendor/src/google.golang.org/cloud/internal/transport/proto.go
31 changes: 31 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: 2.1

jobs:
test:
working_directory: ~/repo
docker:
- image: circleci/golang:1.15
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go mod download
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: |
mkdir -p /tmp/test-reports
gotestsum --format testname --junitfile /tmp/test-reports/unit-tests.xml
- store_test_results:
path: /tmp/test-reports

workflows:
base:
jobs:
- test
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -16,5 +16,16 @@ pkg
*.pb.go

## user configuration
*.toml
*.json
!sample.config.json

## binaries
consul-lb-gce
consul-lb-gce-linux-amd64
consul-lb-gce-linux-amd64.sha256

## MacOS
**/.DS_Store

todo

15 changes: 15 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Path to sources
sonar.sources=.
sonar.exclusions=
#sonar.inclusions=

# Path to tests
#sonar.tests=
#sonar.test.exclusions=
#sonar.test.inclusions=

# Source encoding
#sonar.sourceEncoding=UTF-8

# Exclusions for copy-paste detection
sonar.cpd.exclusions=**/*_test.go
50 changes: 29 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
GOPATH=$(shell pwd):$(shell pwd)/vendor
.PHONY: up
## up: runs application
up:
@go run $$(ls | grep -v _test.go | grep .go) --stderrthreshold INFO

all: clean build
.PHONY: build-linux-amd64
## build-linux-amd64: builds executable file for linux-amd64 platform and checksum file
build-linux-amd64:
@GOOS=linux GOARCH=amd64 go build -o consul-lb-gce-linux-amd64
@echo $$(sha256sum consul-lb-gce-linux-amd64) > consul-lb-gce-linux-amd64.sha256

build:
GOARCH=amd64 gb build all
.PHONY: test-linux-amd64-checksum
## test-linux-amd64-checksum: tests if checksum of executable file for linux-amd64 platform is correct
test-linux-amd64-checksum:
@cat consul-lb-gce-linux-amd64.sha256 | sha256sum -c

.PHONY: clean
clean:
@rm -rf ./{bin,pkg}
@gofmt -s -w src

.PHONY: release
release: clean
GOOS=linux GOARCH=amd64 gb build -ldflags '-w -extldflags=-static'
.PHONY: fmt
## fmt: formats source code
fmt:
@gofmt -s -w .

.PHONY: test
## test: runs tests
test:
@gb test -v
@go test -timeout 10s -v ./...

.PHONY: help
## help: prints help message
help:
@echo "Consul LB GCE"
@echo
@echo "Usage:"
@echo
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
@echo

#
# Use COVPKG env var to set which package to run coverage
#
.PHONY: coverage
coverage:
go test -v -coverprofile cover.out github.com/pires/consul-lb-google/${COVPKG}
@go tool cover -html=cover.out -o coverage.html
@rm cover.out
116 changes: 0 additions & 116 deletions README.adoc

This file was deleted.

133 changes: 133 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Consul LB GCE

[![Consul-LB-GCE CI](https://circleci.com/gh/dffrntmedia/consul-lb-gce.svg?style=svg)](https://circleci.com/gh/dffrntmedia/consul-lb-gce)
[![Consul-LB-GCE Sonarcloud](https://sonarcloud.io/api/project_badges/measure?project=dffrntmedia_consul-lb-gce&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dffrntmedia_consul-lb-gce)

GCE load balancing based on [Consul](https://www.consul.io/). It is a fork of [@pires's project](https://github.com/pires/consul-lb-gce) that works with network endpoint groups instead of instance groups.

## Setup

### Production

- Prepare VM instances to run Consul, your services and `consul-lb-gce`;
- Prepare URL map;
- Setup [Consul](https://www.consul.io/);
- Run your services and register them in Consul via its API, [Nomad](https://nomadproject.io/) or something else;
- Add firewall rule as described [here](https://cloud.google.com/load-balancing/docs/health-checks#fw-rule) to allow health checks requests;
- If you plan to use `REUSE` mode then create necessary network endpoint groups, health checks, backend services and configure URL map so that it uses created backend services;
- ~~We use HTTP API to manage NEGs so no need for support of [network endpoint groups](https://cloud.google.com/load-balancing/docs/negs) by `gcloud` CLI~~;
- Build `consul-lb-gce` linux binary executable via `make build-linux-amd64` (it also generates SHA256 checksum file);
- Create `config.json` file near the binary by copying `sample.config.json` and putting your values in;
- Run `consul-lb-gce`, if you want to have logging then use `--stderrthreshold INFO` option.

### Development

`make up` runs application. Although it's difficult to test the app locally, some things can be tested: tracking Consul services, sending requests to GCE, GCE will not be able to work with your network endpoints coz it isn't aware of them.

`make test` runs tests.

Other commands are available via `make help`.

## How it works

The application tracks services registered in Consul and manages corresponding network endpoint groups accordingly. Services registered under one tag in Consul have single network endpoint group. `consul-lb-gce` can work with tags in 3 modes: `REUSE`, `TAG`, `DEFAULT`. In `REUSE` mode, the application re-uses cloud resources managed externally (network endpoint groups, health checks, backend services are managed externally as well as URL map is configured externally). When services with tag are found for the first time, the application in modes `TAG` or `DEFAULT` tries to create and configure listed above resources itself if needed. The difference between `TAG` and `DEFAULT` modes is in a way resources properties are specified: 1) encoded into tag string; 2) listed as fields of JSON object. If list of registered with tag services is updated in Consul then `consul-lb-gce` updates list of endpoints in corresponding network endpoint group (attaches new ones and detaches old ones).

Example:

1. Watched tag is single, it is in `TAG` mode and it is `consullbgce-cdn-ipaffinity-subdomain.domain.com/`;
2. The app creates network endpoint group `neg-consullbgce-cdn-ipaffinity-subdomain-domain-com` if it doesn't exist;
3. The app creates health check `hc-consullbgce-cdn-ipaffinity-subdomain-domain-com` if it doesn't exist;
4. The app creates backend service `bs-consullbgce-cdn-ipaffinity-subdomain-domain-com` based on NEG and HC created above if doesn't exist with enabled CDN and IP affinity;
5. The app configures host rule for `subdomain.domain.com` with path matcher for `/*` which is targeted to created backend service. If path from tag has not only `/` (e.g.: `/path`) then it creates `/path`, `/path/*` path matcher and maps it to created backend service, but `/*` is targeted to default backend service of provided URL map.

## Global/Zonal

- `NEG` - zonal;
- `BS` - global;
- `HC` - global.

> In future we should support both global and zonal resources.
## Configuration

You can see configuration example [here](./sample.config.json). It has 3 main sections `tags`, `consul`, `cloud`.

### Tags

It is a map where key is a tag, value is an object with tag related properties:

```json
"api": {
"mode": "REUSE",
"networkEndpointGroup": {
"name": "api-neg"
}
},
"consullbgce-nocdn:noaffinity:subdomain.domain.com/": {
"mode": "TAG",
"healthCheck": {
"type": "http",
"path": "/health"
}
},
"consullbgce-nocdn:noaffinity:test.domain.com/v1": {
"mode": "DEFAULT",
"networkEndpointGroup": {
"name": "neg-name"
},
"backendService": {
"name": "bs-name",
"cdn": false,
"affinity": "ipaffinity",
"host": "test.domain.com",
"path": "/v1"
},
"healthCheck": {
"name": "hc-name",
"type": "http",
"path": "/healthcheck"
}
}
```

In `REUSE` mode, we have to specify only name of network endpoint group.

In `TAG` and `DEFAULT` modes, health checks are specified explicitly since Consul doesn't provide information about them.

In `DEFAULT` mode, all properties are specified explicitly (tag will not be parsed to get them).

**Tag format in `TAG` mode**

`consullbgce-<cdn|nocdn>:<ipaffinity|noaffinity>:<APPLICATION_ADDRESS>/<PATH>`

Let's take the following initial values:

- We don't need CDN;
- We want to use IP affinity;
- `APPLICATION_ADDRESS` is `api.application.com`;
- `Path` is empty.

So we have the following tag: `consullbgce-nocdn:ipaffinity:api.application.com/`.

### Consul

It is an object with URL to Consul agent or server:

```json
{
"url": "localhost:8500"
}
```

### Cloud

It is an object with GCE properties:

```json
{
"project": "project-id",
"network": "network-name", // e.g. "default"
"zone": "region-and-zone", // e.g. "europe-west4-b"
"urlMap": "url-map-name"
}
```
Loading