diff --git a/charts/proxy/templates/deployment.yaml b/charts/proxy/templates/deployment.yaml index 1e6d5b3e..53e1d082 100644 --- a/charts/proxy/templates/deployment.yaml +++ b/charts/proxy/templates/deployment.yaml @@ -21,6 +21,14 @@ spec: - name: {{ template "fullname" . }} image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy | quote }} + livenessProbe: + httpGet: + path: /healthz + port: 3000 + readinessProbe: + httpGet: + path: /readyz + port: 3000 env: - name: ATHENS_STORAGE_TYPE value: {{ .Values.storage.type | quote }} diff --git a/cmd/proxy/actions/app_proxy.go b/cmd/proxy/actions/app_proxy.go index 057dab04..8fb60fee 100644 --- a/cmd/proxy/actions/app_proxy.go +++ b/cmd/proxy/actions/app_proxy.go @@ -21,6 +21,7 @@ func addProxyRoutes( ) error { app.GET("/", proxyHomeHandler) app.GET("/healthz", healthHandler) + app.GET("/readyz", getReadinessHandler(s)) app.GET("/version", versionHandler) // Download Protocol diff --git a/cmd/proxy/actions/readiness.go b/cmd/proxy/actions/readiness.go new file mode 100644 index 00000000..52d8fcf5 --- /dev/null +++ b/cmd/proxy/actions/readiness.go @@ -0,0 +1,16 @@ +package actions + +import ( + "github.com/gobuffalo/buffalo" + "github.com/gomods/athens/pkg/storage" +) + +func getReadinessHandler(s storage.Backend) buffalo.Handler { + return func(c buffalo.Context) error { + if _, err := s.List(c, "github.com/gomods/athens"); err != nil { + return c.Render(500, nil) + } + + return c.Render(200, nil) + } +}