项目作者: nathanejohnson

项目描述 :
consul inception
高级语言: Go
项目地址: git://github.com/nathanejohnson/conseption.git
创建时间: 2017-08-19T13:53:43Z
项目社区:https://github.com/nathanejohnson/conseption

开源协议:MIT License

下载


conseption

consul inception

This is used to watch a prefix in a consul KV store where the values of keys represent consul api AgentServiceRegistration data. This is useful for services that are not consul-aware but need to be registered as services within consul. The way it works currently, a consul agent as well as this program would be deployed on each machine where registrations need to occur, and it would only register services to the local agent that match the hostname of where we live. This can be overridden by changing the HOSTNAME environment variable. CONSUL_HTTP_ADDR must be set to point to a consul agent, or there must be an agent at localhost, or the config must be specified in a configuration toml file. If it notices health checks registered to another agent, it will deregister first.

Multiple registrations can exist in the same Value block in the consul KV, with the following formats accepted:

Serial representations of AgentServiceRegistration

  1. {
  2. "id": "cb01.labs.widget.co",
  3. "name": "couchbase",
  4. "tags": [
  5. "cache",
  6. "cloudstack",
  7. "rancid",
  8. "cloudythings"
  9. ],
  10. "address": "cb01.labs.widget.co",
  11. "port": 8091,
  12. "checks": [
  13. {
  14. "http": "http://cb01.labs.widget.co:8091/pools/",
  15. "interval": "30s"
  16. }
  17. ]
  18. }
  19. {
  20. "id": "cb02.labs.widget.co",
  21. "name": "couchbase",
  22. "tags": [
  23. "cache",
  24. "cloudstack",
  25. "rancid",
  26. "cloudythings"
  27. ],
  28. "address": "cb02.labs.widget.co",
  29. "port": 8091,
  30. "checks": [
  31. {
  32. "http": "http://cb02.labs.widget.co:8091/pools/",
  33. "interval": "30s"
  34. }
  35. ]
  36. }

Comma separated representations of AgentServiceRegistration

  1. {
  2. "id": "cb01.labs.widget.co",
  3. "name": "couchbase",
  4. "tags": [
  5. "cache",
  6. "cloudstack",
  7. "rancid",
  8. "cloudythings"
  9. ],
  10. "address": "cb01.labs.widget.co",
  11. "port": 8091,
  12. "checks": [
  13. {
  14. "http": "http://cb01.labs.widget.co:8091/pools/",
  15. "interval": "30s"
  16. }
  17. ]
  18. },
  19. {
  20. "id": "cb02.labs.widget.co",
  21. "name": "couchbase",
  22. "tags": [
  23. "cache",
  24. "cloudstack",
  25. "rancid",
  26. "cloudythings"
  27. ],
  28. "address": "cb02.labs.widget.co",
  29. "port": 8091,
  30. "checks": [
  31. {
  32. "http": "http://cb02.labs.widget.co:8091/pools/",
  33. "interval": "30s"
  34. }
  35. ]
  36. }

A list of AgentServiceRegistrations

  1. [
  2. {
  3. "id": "cb01.labs.widget.co",
  4. "name": "couchbase",
  5. "tags": [
  6. "cache",
  7. "cloudstack",
  8. "rancid",
  9. "cloudythings"
  10. ],
  11. "address": "cb01.labs.widget.co",
  12. "port": 8091,
  13. "checks": [
  14. {
  15. "http": "http://cb01.labs.widget.co:8091/pools/",
  16. "interval": "30s"
  17. }
  18. ]
  19. },
  20. {
  21. "id": "cb02.labs.widget.co",
  22. "name": "couchbase",
  23. "tags": [
  24. "cache",
  25. "cloudstack",
  26. "rancid",
  27. "cloudythings"
  28. ],
  29. "address": "cb02.labs.widget.co",
  30. "port": 8091,
  31. "checks": [
  32. {
  33. "http": "http://cb02.labs.widget.co:8091/pools/",
  34. "interval": "30s"
  35. }
  36. ]
  37. }
  38. ]

Or a json object that has a top level Services field

  1. { "Services":
  2. [
  3. {
  4. "id": "cb01.labs.widget.co",
  5. "name": "couchbase",
  6. "tags": [
  7. "cache",
  8. "cloudstack",
  9. "rancid",
  10. "cloudythings"
  11. ],
  12. "address": "cb01.labs.widget.co",
  13. "port": 8091,
  14. "checks": [
  15. {
  16. "http": "http://cb01.labs.widget.co:8091/pools/",
  17. "interval": "30s"
  18. }
  19. ]
  20. },
  21. {
  22. "id": "cb02.labs.widget.co",
  23. "name": "couchbase",
  24. "tags": [
  25. "cache",
  26. "cloudstack",
  27. "rancid",
  28. "cloudythings"
  29. ],
  30. "address": "cb02.labs.widget.co",
  31. "port": 8091,
  32. "checks": [
  33. {
  34. "http": "http://cb02.labs.widget.co:8091/pools/",
  35. "interval": "30s"
  36. }
  37. ]
  38. }
  39. ]
  40. }