Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Consul gRPC check #639

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,21 @@ func (r *ConsulAdapter) buildCheck(service *bridge.Service) *consulapi.AgentServ
if timeout := service.Attrs["check_timeout"]; timeout != "" {
check.Timeout = timeout
}
} else if grpc := service.Attrs["check_grpc"]; grpc != "" {
check.GRPC = fmt.Sprintf("%s:%d", service.IP, service.Port)
if timeout := service.Attrs["check_timeout"]; timeout != "" {
check.Timeout = timeout
}
if useTLS := service.Attrs["check_grpc_use_tls"]; useTLS != "" {
check.GRPCUseTLS = true
if tlsSkipVerify := service.Attrs["check_tls_skip_verify"]; tlsSkipVerify != "" {
check.TLSSkipVerify = true
}
}
} else {
return nil
}
if check.Script != "" || check.HTTP != "" || check.TCP != "" {
if check.Script != "" || check.HTTP != "" || check.TCP != "" || check.GRPC != "" {
if interval := service.Attrs["check_interval"]; interval != "" {
check.Interval = interval
} else {
Expand Down
14 changes: 14 additions & 0 deletions docs/user/backends.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ healthy.
SERVICE_CHECK_TTL=30s
```

### Consul gRPC Check

This feature is only available when using Consul 1.0.5 or newer. Containers
specifying these extra metadata in labels or environment will be used to
register an gRPC health check with the service.

```bash
SERVICE_CHECK_GRPC=true
SERVICE_CHECK_INTERVAL=5s
SERVICE_CHECK_TIMEOUT=3s # optional, Consul default uses 10s
SERVICE_CHECK_GRPC_USE_TLS=true # optional, Consul default uses false
SERVICE_CHECK_TLS_SKIP_VERIFY=true # optional, Consul default uses false
```

### Consul Initial Health Check Status

By default when a service is registered against Consul, the state is set to "critical". You can specify the initial health check status.
Expand Down