Skip to content
This repository was archived by the owner on Aug 26, 2021. It is now read-only.

Commit 1272fb7

Browse files
committed
Add abilitiy to specify health check path
1 parent aa96e54 commit 1272fb7

File tree

7 files changed

+21
-2
lines changed

7 files changed

+21
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Please note:
105105
| `LEGO_SERVICE_NAME_NGINX` | n | `kube-lego-nginx` | Service name for NGINX ingress |
106106
| `LEGO_SERVICE_NAME_GCE` | n | `kube-lego-gce` | Service name for GCE ingress |
107107
| `LEGO_SUPPORTED_INGRESS_CLASS` | n | `nginx,gce` | Specify the supported ingress class |
108+
| `LEGO_HEALTH_CHECK_PATH` | n | `/healthz` | Specify the health check path |
108109
| `LEGO_INGRESS_NAME_NGINX` | n | `kube-lego-nginx` | Ingress name which contains the routing for HTTP verification for nginx ingress |
109110
| `LEGO_PORT` | n | `8080` | Port where this daemon is listening for verifcation calls (HTTP method)|
110111
| `LEGO_CHECK_INTERVAL` | n | `8h` | Interval for periodically certificate checks (to find expired certs)|

pkg/acme/acme.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (a *Acme) Mux() *http.ServeMux {
4848
}
4949
})
5050

51-
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
51+
mux.HandleFunc(a.kubelego.LegoHealthCheckPath(), func(w http.ResponseWriter, r *http.Request) {
5252
w.Header().Set("Content-Type", "text/plain")
5353
w.WriteHeader(http.StatusOK)
5454
fmt.Fprint(w, "ok")

pkg/kubelego/kubelego.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ func (kl *KubeLego) LegoEmail() string {
157157
return kl.legoEmail
158158
}
159159

160+
func (kl *KubeLego) LegoHealthCheckPath() string {
161+
return kl.legoHealthCheckPath
162+
}
160163
func (kl *KubeLego) LegoNamespace() string {
161164
return kl.legoNamespace
162165
}
@@ -340,5 +343,12 @@ func (kl *KubeLego) paramsLego() error {
340343
} else {
341344
kl.legoWatchNamespace = watchNamespace
342345
}
346+
347+
kl.legoHealthCheckPath = os.Getenv("LEGO_HEALTH_CHECK_PATH")
348+
if len(kl.legoHealthCheckPath) == 0 {
349+
kl.legoHealthCheckPath = kubelego.LegoHealthCheckPath
350+
}
351+
352+
343353
return nil
344354
}

pkg/kubelego/type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type KubeLego struct {
2525
legoServiceNameGce string
2626
legoSupportedIngressClass []string
2727
legoHTTPPort intstr.IntOrString
28+
legoHealthCheckPath string
2829
legoCheckInterval time.Duration
2930
legoMinimumValidity time.Duration
3031
legoDefaultIngressClass string

pkg/kubelego_const/consts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const AcmeRegistrationUrl = "acme-registration-url"
1010
const AcmePrivateKey = k8sApi.TLSPrivateKeyKey
1111
const AcmeHttpChallengePath = "/.well-known/acme-challenge"
1212
const AcmeHttpSelfTest = "/.well-known/acme-challenge/_selftest"
13-
13+
const LegoHealthCheckPath = "/healthz"
1414
const TLSCertKey = k8sApi.TLSCertKey
1515
const TLSPrivateKeyKey = k8sApi.TLSPrivateKeyKey
1616
const TLSCaKey = "ca.crt"

pkg/kubelego_const/interfaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type KubeLego interface {
2828
LegoCheckInterval() time.Duration
2929
LegoMinimumValidity() time.Duration
3030
LegoPodIP() net.IP
31+
LegoHealthCheckPath() string
3132
IngressProvider(string) (IngressProvider, error)
3233
Version() string
3334
AcmeUser() (map[string][]byte, error)

pkg/mocks/mocks.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ func (_m *MockKubeLego) LegoEmail() string {
8282
return ret0
8383
}
8484

85+
func (_m *MockKubeLego) LegoHealthCheckPath() string {
86+
ret := _m.ctrl.Call(_m, "LegoHealthCheckPath")
87+
ret0, _ := ret[0].(string)
88+
return ret0
89+
}
90+
8591
func (_mr *_MockKubeLegoRecorder) LegoEmail() *gomock.Call {
8692
return _mr.mock.ctrl.RecordCall(_mr.mock, "LegoEmail")
8793
}

0 commit comments

Comments
 (0)