hds.proto 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. syntax = "proto3";
  2. package envoy.service.discovery.v2;
  3. import "envoy/api/v2/core/base.proto";
  4. import "envoy/api/v2/core/health_check.proto";
  5. import "envoy/api/v2/endpoint/endpoint_components.proto";
  6. import "google/api/annotations.proto";
  7. import "google/protobuf/duration.proto";
  8. import "udpa/annotations/migrate.proto";
  9. import "udpa/annotations/status.proto";
  10. option java_package = "io.envoyproxy.envoy.service.discovery.v2";
  11. option java_outer_classname = "HdsProto";
  12. option java_multiple_files = true;
  13. option go_package = "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v2;discoveryv2";
  14. option java_generic_services = true;
  15. option (udpa.annotations.file_migrate).move_to_package = "envoy.service.health.v3";
  16. option (udpa.annotations.file_status).package_version_status = FROZEN;
  17. // [#protodoc-title: Health Discovery Service (HDS)]
  18. // HDS is Health Discovery Service. It compliments Envoy’s health checking
  19. // service by designating this Envoy to be a healthchecker for a subset of hosts
  20. // in the cluster. The status of these health checks will be reported to the
  21. // management server, where it can be aggregated etc and redistributed back to
  22. // Envoy through EDS.
  23. service HealthDiscoveryService {
  24. // 1. Envoy starts up and if its can_healthcheck option in the static
  25. // bootstrap config is enabled, sends HealthCheckRequest to the management
  26. // server. It supplies its capabilities (which protocol it can health check
  27. // with, what zone it resides in, etc.).
  28. // 2. In response to (1), the management server designates this Envoy as a
  29. // healthchecker to health check a subset of all upstream hosts for a given
  30. // cluster (for example upstream Host 1 and Host 2). It streams
  31. // HealthCheckSpecifier messages with cluster related configuration for all
  32. // clusters this Envoy is designated to health check. Subsequent
  33. // HealthCheckSpecifier message will be sent on changes to:
  34. // a. Endpoints to health checks
  35. // b. Per cluster configuration change
  36. // 3. Envoy creates a health probe based on the HealthCheck config and sends
  37. // it to endpoint(ip:port) of Host 1 and 2. Based on the HealthCheck
  38. // configuration Envoy waits upon the arrival of the probe response and
  39. // looks at the content of the response to decide whether the endpoint is
  40. // healthy or not. If a response hasn't been received within the timeout
  41. // interval, the endpoint health status is considered TIMEOUT.
  42. // 4. Envoy reports results back in an EndpointHealthResponse message.
  43. // Envoy streams responses as often as the interval configured by the
  44. // management server in HealthCheckSpecifier.
  45. // 5. The management Server collects health statuses for all endpoints in the
  46. // cluster (for all clusters) and uses this information to construct
  47. // EndpointDiscoveryResponse messages.
  48. // 6. Once Envoy has a list of upstream endpoints to send traffic to, it load
  49. // balances traffic to them without additional health checking. It may
  50. // use inline healthcheck (i.e. consider endpoint UNHEALTHY if connection
  51. // failed to a particular endpoint to account for health status propagation
  52. // delay between HDS and EDS).
  53. // By default, can_healthcheck is true. If can_healthcheck is false, Cluster
  54. // configuration may not contain HealthCheck message.
  55. // TODO(htuch): How is can_healthcheck communicated to CDS to ensure the above
  56. // invariant?
  57. // TODO(htuch): Add @amb67's diagram.
  58. rpc StreamHealthCheck(stream HealthCheckRequestOrEndpointHealthResponse)
  59. returns (stream HealthCheckSpecifier) {
  60. }
  61. // TODO(htuch): Unlike the gRPC version, there is no stream-based binding of
  62. // request/response. Should we add an identifier to the HealthCheckSpecifier
  63. // to bind with the response?
  64. rpc FetchHealthCheck(HealthCheckRequestOrEndpointHealthResponse) returns (HealthCheckSpecifier) {
  65. option (google.api.http).post = "/v2/discovery:health_check";
  66. option (google.api.http).body = "*";
  67. }
  68. }
  69. // Defines supported protocols etc, so the management server can assign proper
  70. // endpoints to healthcheck.
  71. message Capability {
  72. // Different Envoy instances may have different capabilities (e.g. Redis)
  73. // and/or have ports enabled for different protocols.
  74. enum Protocol {
  75. HTTP = 0;
  76. TCP = 1;
  77. REDIS = 2;
  78. }
  79. repeated Protocol health_check_protocols = 1;
  80. }
  81. message HealthCheckRequest {
  82. api.v2.core.Node node = 1;
  83. Capability capability = 2;
  84. }
  85. message EndpointHealth {
  86. api.v2.endpoint.Endpoint endpoint = 1;
  87. api.v2.core.HealthStatus health_status = 2;
  88. }
  89. message EndpointHealthResponse {
  90. repeated EndpointHealth endpoints_health = 1;
  91. }
  92. message HealthCheckRequestOrEndpointHealthResponse {
  93. oneof request_type {
  94. HealthCheckRequest health_check_request = 1;
  95. EndpointHealthResponse endpoint_health_response = 2;
  96. }
  97. }
  98. message LocalityEndpoints {
  99. api.v2.core.Locality locality = 1;
  100. repeated api.v2.endpoint.Endpoint endpoints = 2;
  101. }
  102. // The cluster name and locality is provided to Envoy for the endpoints that it
  103. // health checks to support statistics reporting, logging and debugging by the
  104. // Envoy instance (outside of HDS). For maximum usefulness, it should match the
  105. // same cluster structure as that provided by EDS.
  106. message ClusterHealthCheck {
  107. string cluster_name = 1;
  108. repeated api.v2.core.HealthCheck health_checks = 2;
  109. repeated LocalityEndpoints locality_endpoints = 3;
  110. }
  111. message HealthCheckSpecifier {
  112. repeated ClusterHealthCheck cluster_health_checks = 1;
  113. // The default is 1 second.
  114. google.protobuf.Duration interval = 2;
  115. }