Skip to content

Commit

Permalink
cmd/contour: add readinessProbe support to contour container
Browse files Browse the repository at this point in the history
Fixes projectcontour#86
Updates projectcontour#10

This PR adds healthz support to contour using the heptiolabs/healthcheck library.
The envoy container's heathcheck is not done, yet.

Signed-off-by: Dave Cheney <dave@cheney.net>
  • Loading branch information
davecheney committed Jan 29, 2018
1 parent 783aeb2 commit 17dd27d
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 1 deletion.
53 changes: 52 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions cmd/contour/contour.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
package main

import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
"path/filepath"
"time"

kingpin "gopkg.in/alecthomas/kingpin.v2"

Expand All @@ -33,6 +36,7 @@ import (
"github.com/heptio/contour/internal/k8s"
"github.com/heptio/contour/internal/log/stdlog"
"github.com/heptio/contour/internal/workgroup"
"github.com/heptiolabs/healthcheck"
)

const (
Expand Down Expand Up @@ -92,6 +96,21 @@ func main() {
k8s.WatchIngress(&g, client, logger, buf)
k8s.WatchSecrets(&g, client, logger, buf)

g.Add(func(stop <-chan struct{}) {
logger := logger.WithPrefix("healthcheck")
srv := &http.Server{
Handler: healthcheck.NewHandler(),
Addr: "0.0.0.0:8086",
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
go srv.ListenAndServe() // run server in another goroutine
logger.Infof("started, listening on %v", srv.Addr)
defer logger.Infof("stopped")
<-stop // wait for stop signal
srv.Shutdown(context.Background()) // shutdown and wait for server to exit
})

g.Add(func(stop <-chan struct{}) {
logger := logger.WithPrefix("gRPCAPI")
l, err := net.Listen("tcp", V2_API_ADDRESS)
Expand Down
5 changes: 5 additions & 0 deletions deployment/deployment-grpc-v2/02-contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ spec:
volumeMounts:
- name: contour-config
mountPath: /config
readinessProbe:
httpGet:
path: /ready
port: 8086
periodSeconds: 5
initContainers:
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
Expand Down
5 changes: 5 additions & 0 deletions deployment/ds-grpc-v2/02-contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ spec:
volumeMounts:
- name: contour-config
mountPath: /config
readinessProbe:
httpGet:
path: /ready
port: 8086
periodSeconds: 5
initContainers:
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
Expand Down
5 changes: 5 additions & 0 deletions deployment/ds-hostnet/02-contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ spec:
name: contour
command: ["contour"]
args: ["serve", "--incluster"]
readinessProbe:
httpGet:
path: /ready
port: 8086
periodSeconds: 5
initContainers:
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
Expand Down
5 changes: 5 additions & 0 deletions deployment/render/daemonset-norbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ spec:
volumeMounts:
- name: contour-config
mountPath: /config
readinessProbe:
httpGet:
path: /ready
port: 8086
periodSeconds: 5
initContainers:
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
Expand Down
5 changes: 5 additions & 0 deletions deployment/render/daemonset-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ spec:
volumeMounts:
- name: contour-config
mountPath: /config
readinessProbe:
httpGet:
path: /ready
port: 8086
periodSeconds: 5
initContainers:
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
Expand Down
5 changes: 5 additions & 0 deletions deployment/render/deployment-norbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ spec:
volumeMounts:
- name: contour-config
mountPath: /config
readinessProbe:
httpGet:
path: /ready
port: 8086
periodSeconds: 5
initContainers:
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
Expand Down
5 changes: 5 additions & 0 deletions deployment/render/deployment-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ spec:
volumeMounts:
- name: contour-config
mountPath: /config
readinessProbe:
httpGet:
path: /ready
port: 8086
periodSeconds: 5
initContainers:
- image: gcr.io/heptio-images/contour:master
imagePullPolicy: Always
Expand Down

0 comments on commit 17dd27d

Please sign in to comment.