Skip to content

Commit

Permalink
Enable Envoy healthchecks
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Sloka <[email protected]>
  • Loading branch information
stevesloka committed Oct 18, 2018
1 parent 040fa01 commit 193a4ce
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 83 deletions.
15 changes: 6 additions & 9 deletions cmd/contour/contour.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,20 @@ import (
"strings"

clientset "github.com/heptio/contour/apis/generated/clientset/versioned"
"github.com/heptio/contour/internal/contour"
"github.com/heptio/contour/internal/debug"
"github.com/heptio/contour/internal/envoy"
"github.com/heptio/contour/internal/grpc"
"github.com/heptio/contour/internal/httpsvc"
"github.com/heptio/contour/internal/k8s"
"github.com/heptio/contour/internal/metrics"
"github.com/heptio/workgroup"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
kingpin "gopkg.in/alecthomas/kingpin.v2"

"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

"github.com/heptio/contour/internal/contour"
"github.com/heptio/contour/internal/envoy"
"github.com/heptio/contour/internal/grpc"
"github.com/heptio/contour/internal/k8s"
"github.com/heptio/contour/internal/metrics"

"github.com/sirupsen/logrus"
)

var ingressrouteRootNamespaceFlag string
Expand Down
8 changes: 7 additions & 1 deletion deployment/deployment-grpc-v2/02-contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ spec:
- --service-node node0
- --log-level info
- --v2-config-only
readinessProbe:
httpGet:
path: /healthz
port: 8002
initialDelaySeconds: 3
periodSeconds: 3
volumeMounts:
- name: contour-config
mountPath: /config
Expand All @@ -50,7 +56,7 @@ spec:
command: ["contour"]
args:
- bootstrap
# Uncomment the statsd-enable to enable prometheus metrics
# Uncomment the statsd-enable to enable statsd metrics
#- --statsd-enable
# Uncomment to set a custom stats emission address and port
#- --stats-address=0.0.0.0
Expand Down
6 changes: 6 additions & 0 deletions deployment/ds-grpc-v2/02-contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ spec:
- --service-node node0
- --log-level info
- --v2-config-only
readinessProbe:
httpGet:
path: /healthz
port: 8002
initialDelaySeconds: 3
periodSeconds: 3
volumeMounts:
- name: contour-config
mountPath: /config
Expand Down
7 changes: 6 additions & 1 deletion deployment/ds-hostnet-split/03-envoy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ spec:
hostPort: 443
name: https
protocol: TCP
readinessProbe:
httpGet:
path: /healthz
port: 8002
initialDelaySeconds: 3
periodSeconds: 3
volumeMounts:
- name: contour-config
mountPath: /config
Expand All @@ -58,7 +64,6 @@ spec:
- $(CONTOUR_SERVICE_HOST)
- --xds-port
- $(CONTOUR_SERVICE_PORT)
- --statsd-enabled
command:
- contour
image: gcr.io/heptio-images/contour:v0.6.0-beta.3
Expand Down
6 changes: 6 additions & 0 deletions deployment/ds-hostnet/02-contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ spec:
- --service-node node0
- --log-level info
- --v2-config-only
readinessProbe:
httpGet:
path: /healthz
port: 8002
initialDelaySeconds: 3
periodSeconds: 3
volumeMounts:
- name: contour-config
mountPath: /config
Expand Down
6 changes: 6 additions & 0 deletions deployment/render/daemonset-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ spec:
- --service-node node0
- --log-level info
- --v2-config-only
readinessProbe:
httpGet:
path: /healthz
port: 8002
initialDelaySeconds: 3
periodSeconds: 3
volumeMounts:
- name: contour-config
mountPath: /config
Expand Down
8 changes: 7 additions & 1 deletion deployment/render/deployment-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ spec:
- --service-node node0
- --log-level info
- --v2-config-only
readinessProbe:
httpGet:
path: /healthz
port: 8002
initialDelaySeconds: 3
periodSeconds: 3
volumeMounts:
- name: contour-config
mountPath: /config
Expand All @@ -205,7 +211,7 @@ spec:
command: ["contour"]
args:
- bootstrap
# Uncomment the statsd-enable to enable prometheus metrics
# Uncomment the statsd-enable to enable statsd metrics
#- --statsd-enable
# Uncomment to set a custom stats emission address and port
#- --stats-address=0.0.0.0
Expand Down
3 changes: 3 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ Contour is a client of the Kubernetes API. Contour watches Ingress, Service, and
The transfer of information from Kubernetes to Contour is by watching the API with the SharedInformer framework.
The transfer of information from Contour to Envoy is by polling from the Envoy side.

Kubernetes Readiness Probes are configured to check the status of Envoy.
These are enabled over the metrics port and are served over http via `/healthz`.

[0]: https://github.com/envoyproxy/data-plane-api#terminology
4 changes: 2 additions & 2 deletions docs/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ avoid exposing the entire admin interface to Prometheus (and other workloads in
the cluster), Contour configures a static listener that sends traffic to the
stats endpoint and nowhere else.

To enable the static listener, set the `--statsd-enabled` flag on the Contour
`bootstrap` command that runs as an init container.
To enable the static listener, set the `--statsd-enabled` flag.
By default, Envoy's stats will be exposed over `0.0.0.0:8002` but can be overridden setting the `--stats-address` and `--stats-port` flags in Contour.

### Configuration Prometheus

Expand Down
11 changes: 7 additions & 4 deletions internal/envoy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static_resources:
protocol: TCP
address: 127.0.0.1
port_value: {{ if .AdminPort }}{{ .AdminPort }}{{ else }}9001{{ end }}
{{ if .StatsdEnabled }} listeners:
listeners:
- address:
socket_address:
protocol: TCP
Expand All @@ -140,18 +140,21 @@ static_resources:
route:
cluster: service_stats
http_filters:
- name: envoy.health_check
config:
endpoint: "/healthz"
pass_through_mode: false
- name: envoy.router
config:
stats_sinks:
{{ if .StatsdEnabled }}stats_sinks:
- name: envoy.statsd
config:
address:
socket_address:
protocol: UDP
address: {{ if .StatsdAddress }}{{ .StatsdAddress }}{{ else }}127.0.0.1{{ end }}
port_value: {{ if .StatsdPort }}{{ .StatsdPort }}{{ else }}9125{{ end }}
{{ end -}}
admin:
{{ end -}}admin:
access_log_path: {{ if .AdminAccessLogPath }}{{ .AdminAccessLogPath }}{{ else }}/dev/null{{ end }}
address:
socket_address:
Expand Down
73 changes: 8 additions & 65 deletions internal/envoy/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,63 +38,6 @@ func TestConfigWriter_WriteYAML(t *testing.T) {
grpc_services:
- envoy_grpc:
cluster_name: contour
static_resources:
clusters:
- name: contour
connect_timeout: { seconds: 5 }
type: STRICT_DNS
hosts:
- socket_address:
address: 127.0.0.1
port_value: 8001
lb_policy: ROUND_ROBIN
http2_protocol_options: {}
circuit_breakers:
thresholds:
- priority: high
max_connections: 100000
max_pending_requests: 100000
max_requests: 60000000
max_retries: 50
- priority: default
max_connections: 100000
max_pending_requests: 100000
max_requests: 60000000
max_retries: 50
- name: service_stats
connect_timeout: 0.250s
type: LOGICAL_DNS
lb_policy: ROUND_ROBIN
hosts:
- socket_address:
protocol: TCP
address: 127.0.0.1
port_value: 9001
admin:
access_log_path: /dev/null
address:
socket_address:
address: 127.0.0.1
port_value: 9001
`,
},
"statsd enabled": {
ConfigWriter: ConfigWriter{
StatsdEnabled: true,
},
want: `dynamic_resources:
lds_config:
api_config_source:
api_type: GRPC
grpc_services:
- envoy_grpc:
cluster_name: contour
cds_config:
api_config_source:
api_type: GRPC
grpc_services:
- envoy_grpc:
cluster_name: contour
static_resources:
clusters:
- name: contour
Expand Down Expand Up @@ -150,16 +93,12 @@ static_resources:
route:
cluster: service_stats
http_filters:
- name: envoy.health_check
config:
endpoint: "/healthz"
pass_through_mode: false
- name: envoy.router
config:
stats_sinks:
- name: envoy.statsd
config:
address:
socket_address:
protocol: UDP
address: 127.0.0.1
port_value: 9125
admin:
access_log_path: /dev/null
address:
Expand Down Expand Up @@ -242,6 +181,10 @@ static_resources:
route:
cluster: service_stats
http_filters:
- name: envoy.health_check
config:
endpoint: "/healthz"
pass_through_mode: false
- name: envoy.router
config:
stats_sinks:
Expand Down

0 comments on commit 193a4ce

Please sign in to comment.