mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-01-03 13:30:08 +07:00
Added http health check endpoint. (#137)
* Added http health check endpoint. * Fixed performing POST on GET endpoint. * Explicitly return http status 200 in health check endpoint. * Updated changelog.
This commit is contained in:
parent
7fbb5261c8
commit
aff13a02fb
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ acme-dns.db
|
|||||||
acme-dns.log
|
acme-dns.log
|
||||||
.vagrant
|
.vagrant
|
||||||
coverage.out
|
coverage.out
|
||||||
|
.idea/
|
||||||
|
24
README.md
24
README.md
@ -102,6 +102,28 @@ The method allows you to update the TXT answer contents of your unique subdomain
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Health check endpoint
|
||||||
|
|
||||||
|
The method can be used to check readiness and/or liveness of the server. It will return status code 200 on success or won't be reachable.
|
||||||
|
|
||||||
|
```GET /health```
|
||||||
|
|
||||||
|
#### Example using a Kubernetes deployment
|
||||||
|
|
||||||
|
```
|
||||||
|
# ...
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /health
|
||||||
|
port: 80
|
||||||
|
periodSeconds: 2
|
||||||
|
initialDelaySeconds: 2
|
||||||
|
failureThreshold: 3
|
||||||
|
successThreshold: 1
|
||||||
|
livenessProbe:
|
||||||
|
# same as for readinessProbe...
|
||||||
|
```
|
||||||
|
|
||||||
## Self-hosted
|
## Self-hosted
|
||||||
|
|
||||||
You are encouraged to run your own acme-dns instance, because you are effectively authorizing the acme-dns server to act on your behalf in providing the answer to the challenging CA, making the instance able to request (and get issued) a TLS certificate for the domain that has CNAME pointing to it.
|
You are encouraged to run your own acme-dns instance, because you are effectively authorizing the acme-dns server to act on your behalf in providing the answer to the challenging CA, making the instance able to request (and get issued) a TLS certificate for the domain that has CNAME pointing to it.
|
||||||
@ -304,6 +326,8 @@ logformat = "text"
|
|||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
- master
|
- master
|
||||||
|
- Unreleased
|
||||||
|
- Added new endpoint to perform health checks
|
||||||
- Changed
|
- Changed
|
||||||
- A new protocol selection for DNS server "both", that binds both - UDP and TCP ports.
|
- A new protocol selection for DNS server "both", that binds both - UDP and TCP ports.
|
||||||
- v0.6
|
- v0.6
|
||||||
|
5
api.go
5
api.go
@ -93,3 +93,8 @@ func webUpdatePost(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
|
|||||||
w.WriteHeader(updStatus)
|
w.WriteHeader(updStatus)
|
||||||
w.Write(upd)
|
w.Write(upd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Endpoint used to check the readiness and/or liveness (health) of the server.
|
||||||
|
func healthCheck(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
|
@ -71,6 +71,7 @@ func setupRouter(debug bool, noauth bool) http.Handler {
|
|||||||
Debug: Config.General.Debug,
|
Debug: Config.General.Debug,
|
||||||
})
|
})
|
||||||
api.POST("/register", webRegisterPost)
|
api.POST("/register", webRegisterPost)
|
||||||
|
api.GET("/health", healthCheck)
|
||||||
if noauth {
|
if noauth {
|
||||||
api.POST("/update", noAuth(webUpdatePost))
|
api.POST("/update", noAuth(webUpdatePost))
|
||||||
} else {
|
} else {
|
||||||
@ -406,3 +407,11 @@ func TestApiManyUpdateWithIpCheckHeaders(t *testing.T) {
|
|||||||
}
|
}
|
||||||
Config.API.UseHeader = false
|
Config.API.UseHeader = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApiHealthCheck(t *testing.T) {
|
||||||
|
router := setupRouter(false, false)
|
||||||
|
server := httptest.NewServer(router)
|
||||||
|
defer server.Close()
|
||||||
|
e := getExpect(t, server)
|
||||||
|
e.GET("/health").Expect().Status(http.StatusOK)
|
||||||
|
}
|
||||||
|
1
main.go
1
main.go
@ -128,6 +128,7 @@ func startHTTPAPI(errChan chan error) {
|
|||||||
api.POST("/register", webRegisterPost)
|
api.POST("/register", webRegisterPost)
|
||||||
}
|
}
|
||||||
api.POST("/update", Auth(webUpdatePost))
|
api.POST("/update", Auth(webUpdatePost))
|
||||||
|
api.GET("/health", healthCheck)
|
||||||
|
|
||||||
host := Config.API.IP + ":" + Config.API.Port
|
host := Config.API.IP + ":" + Config.API.Port
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user