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

Add abilitiy to specify health check path #136

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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Please note:
| `LEGO_SERVICE_NAME_NGINX` | n | `kube-lego-nginx` | Service name for NGINX ingress |
| `LEGO_SERVICE_NAME_GCE` | n | `kube-lego-gce` | Service name for GCE ingress |
| `LEGO_SUPPORTED_INGRESS_CLASS` | n | `nginx,gce` | Specify the supported ingress class |
| `LEGO_HEALTH_CHECK_PATH` | n | `/healthz` | Specify the health check path |
| `LEGO_INGRESS_NAME_NGINX` | n | `kube-lego-nginx` | Ingress name which contains the routing for HTTP verification for nginx ingress |
| `LEGO_PORT` | n | `8080` | Port where this daemon is listening for verifcation calls (HTTP method)|
| `LEGO_CHECK_INTERVAL` | n | `8h` | Interval for periodically certificate checks (to find expired certs)|
Expand Down
2 changes: 1 addition & 1 deletion pkg/acme/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (a *Acme) Mux() *http.ServeMux {
}
})

mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc(a.kubelego.LegoHealthCheckPath(), func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, "ok")
Expand Down
10 changes: 10 additions & 0 deletions pkg/kubelego/kubelego.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func (kl *KubeLego) LegoEmail() string {
return kl.legoEmail
}

func (kl *KubeLego) LegoHealthCheckPath() string {
return kl.legoHealthCheckPath
}
func (kl *KubeLego) LegoNamespace() string {
return kl.legoNamespace
}
Expand Down Expand Up @@ -340,5 +343,12 @@ func (kl *KubeLego) paramsLego() error {
} else {
kl.legoWatchNamespace = watchNamespace
}

kl.legoHealthCheckPath = os.Getenv("LEGO_HEALTH_CHECK_PATH")
if len(kl.legoHealthCheckPath) == 0 {
kl.legoHealthCheckPath = kubelego.LegoHealthCheckPath
}


return nil
}
1 change: 1 addition & 0 deletions pkg/kubelego/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type KubeLego struct {
legoServiceNameGce string
legoSupportedIngressClass []string
legoHTTPPort intstr.IntOrString
legoHealthCheckPath string
legoCheckInterval time.Duration
legoMinimumValidity time.Duration
legoDefaultIngressClass string
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelego_const/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const AcmeRegistrationUrl = "acme-registration-url"
const AcmePrivateKey = k8sApi.TLSPrivateKeyKey
const AcmeHttpChallengePath = "/.well-known/acme-challenge"
const AcmeHttpSelfTest = "/.well-known/acme-challenge/_selftest"

const LegoHealthCheckPath = "/healthz"
const TLSCertKey = k8sApi.TLSCertKey
const TLSPrivateKeyKey = k8sApi.TLSPrivateKeyKey
const TLSCaKey = "ca.crt"
Expand Down
1 change: 1 addition & 0 deletions pkg/kubelego_const/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type KubeLego interface {
LegoCheckInterval() time.Duration
LegoMinimumValidity() time.Duration
LegoPodIP() net.IP
LegoHealthCheckPath() string
IngressProvider(string) (IngressProvider, error)
Version() string
AcmeUser() (map[string][]byte, error)
Expand Down
10 changes: 10 additions & 0 deletions pkg/mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ func (_mr *_MockKubeLegoRecorder) LegoHTTPPort() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "LegoHTTPPort")
}

func (_m *MockKubeLego) LegoHealthCheckPath() string {
ret := _m.ctrl.Call(_m, "LegoHealthCheckPath")
ret0, _ := ret[0].(string)
return ret0
}

func (_mr *_MockKubeLegoRecorder) LegoHealthCheckPath() *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "LegoHealthCheckPath")
}

func (_m *MockKubeLego) LegoEmail() string {
ret := _m.ctrl.Call(_m, "LegoEmail")
ret0, _ := ret[0].(string)
Expand Down