Add a flag to specify address to bind the healthz server (#7541)
* Add a flag to specify address to bind the healthz server Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Add healthz host to the helm chart Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> * Apply suggestions from code review Co-authored-by: Ricardo Katz <rikatz@users.noreply.github.com> Co-authored-by: Ricardo Katz <rikatz@users.noreply.github.com>
This commit is contained in:
parent
66c2a716da
commit
4c4013904a
7 changed files with 19 additions and 4 deletions
|
@ -111,6 +111,9 @@ spec:
|
||||||
{{- if not (eq .Values.controller.healthCheckPath "/healthz") }}
|
{{- if not (eq .Values.controller.healthCheckPath "/healthz") }}
|
||||||
- --health-check-path={{ .Values.controller.healthCheckPath }}
|
- --health-check-path={{ .Values.controller.healthCheckPath }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if .Values.controller.healthCheckHost }}
|
||||||
|
- --healthz-host={{ .Values.controller.healthCheckHost }}
|
||||||
|
{{- end }}
|
||||||
{{- if .Values.controller.watchIngressWithoutClass }}
|
{{- if .Values.controller.watchIngressWithoutClass }}
|
||||||
- --watch-ingress-without-class=true
|
- --watch-ingress-without-class=true
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -109,6 +109,9 @@ spec:
|
||||||
{{- if .Values.controller.maxmindLicenseKey }}
|
{{- if .Values.controller.maxmindLicenseKey }}
|
||||||
- --maxmind-license-key={{ .Values.controller.maxmindLicenseKey }}
|
- --maxmind-license-key={{ .Values.controller.maxmindLicenseKey }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if .Values.controller.healthCheckHost }}
|
||||||
|
- --healthz-host={{ .Values.controller.healthCheckHost }}
|
||||||
|
{{- end }}
|
||||||
{{- if not (eq .Values.controller.healthCheckPath "/healthz") }}
|
{{- if not (eq .Values.controller.healthCheckPath "/healthz") }}
|
||||||
- --health-check-path={{ .Values.controller.healthCheckPath }}
|
- --health-check-path={{ .Values.controller.healthCheckPath }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -311,6 +311,11 @@ controller:
|
||||||
# the healthz-port parameter are forwarded internally to this path.
|
# the healthz-port parameter are forwarded internally to this path.
|
||||||
healthCheckPath: "/healthz"
|
healthCheckPath: "/healthz"
|
||||||
|
|
||||||
|
# Address to bind the health check endpoint.
|
||||||
|
# It is better to set this option to the internal node address
|
||||||
|
# if the ingress nginx controller is running in the hostNetwork: true mode.
|
||||||
|
healthCheckHost: ""
|
||||||
|
|
||||||
## Annotations to be added to controller pods
|
## Annotations to be added to controller pods
|
||||||
##
|
##
|
||||||
podAnnotations: {}
|
podAnnotations: {}
|
||||||
|
|
|
@ -162,6 +162,7 @@ Requires the update-status parameter.`)
|
||||||
sslProxyPort = flags.Int("ssl-passthrough-proxy-port", 442, `Port to use internally for SSL Passthrough.`)
|
sslProxyPort = flags.Int("ssl-passthrough-proxy-port", 442, `Port to use internally for SSL Passthrough.`)
|
||||||
defServerPort = flags.Int("default-server-port", 8181, `Port to use for exposing the default server (catch-all).`)
|
defServerPort = flags.Int("default-server-port", 8181, `Port to use for exposing the default server (catch-all).`)
|
||||||
healthzPort = flags.Int("healthz-port", 10254, "Port to use for the healthz endpoint.")
|
healthzPort = flags.Int("healthz-port", 10254, "Port to use for the healthz endpoint.")
|
||||||
|
healthzHost = flags.String("healthz-host", "", "Address to bind the healthz endpoint.")
|
||||||
|
|
||||||
disableCatchAll = flags.Bool("disable-catch-all", false,
|
disableCatchAll = flags.Bool("disable-catch-all", false,
|
||||||
`Disable support for catch-all Ingresses`)
|
`Disable support for catch-all Ingresses`)
|
||||||
|
@ -286,6 +287,7 @@ https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-g
|
||||||
ShutdownGracePeriod: *shutdownGracePeriod,
|
ShutdownGracePeriod: *shutdownGracePeriod,
|
||||||
UseNodeInternalIP: *useNodeInternalIP,
|
UseNodeInternalIP: *useNodeInternalIP,
|
||||||
SyncRateLimit: *syncRateLimit,
|
SyncRateLimit: *syncRateLimit,
|
||||||
|
HealthCheckHost: *healthzHost,
|
||||||
ListenPorts: &ngx_config.ListenPorts{
|
ListenPorts: &ngx_config.ListenPorts{
|
||||||
Default: *defServerPort,
|
Default: *defServerPort,
|
||||||
Health: *healthzPort,
|
Health: *healthzPort,
|
||||||
|
|
|
@ -150,7 +150,7 @@ func main() {
|
||||||
registerHealthz(nginx.HealthPath, ngx, mux)
|
registerHealthz(nginx.HealthPath, ngx, mux)
|
||||||
registerMetrics(reg, mux)
|
registerMetrics(reg, mux)
|
||||||
|
|
||||||
go startHTTPServer(conf.ListenPorts.Health, mux)
|
go startHTTPServer(conf.HealthCheckHost, conf.ListenPorts.Health, mux)
|
||||||
go ngx.Start()
|
go ngx.Start()
|
||||||
|
|
||||||
handleSigterm(ngx, func(code int) {
|
handleSigterm(ngx, func(code int) {
|
||||||
|
@ -324,9 +324,9 @@ func registerProfiler() {
|
||||||
klog.Fatal(server.ListenAndServe())
|
klog.Fatal(server.ListenAndServe())
|
||||||
}
|
}
|
||||||
|
|
||||||
func startHTTPServer(port int, mux *http.ServeMux) {
|
func startHTTPServer(host string, port int, mux *http.ServeMux) {
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: fmt.Sprintf(":%v", port),
|
Addr: fmt.Sprintf("%s:%v", host, port),
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
ReadTimeout: 10 * time.Second,
|
ReadTimeout: 10 * time.Second,
|
||||||
ReadHeaderTimeout: 10 * time.Second,
|
ReadHeaderTimeout: 10 * time.Second,
|
||||||
|
|
|
@ -23,6 +23,7 @@ They are set in the container spec of the `nginx-ingress-controller` Deployment
|
||||||
| `--health-check-path` | URL path of the health check endpoint. Configured inside the NGINX status server. All requests received on the port defined by the healthz-port parameter are forwarded internally to this path. (default "/healthz") |
|
| `--health-check-path` | URL path of the health check endpoint. Configured inside the NGINX status server. All requests received on the port defined by the healthz-port parameter are forwarded internally to this path. (default "/healthz") |
|
||||||
| `--health-check-timeout` | Time limit, in seconds, for a probe to health-check-path to succeed. (default 10) |
|
| `--health-check-timeout` | Time limit, in seconds, for a probe to health-check-path to succeed. (default 10) |
|
||||||
| `--healthz-port` | Port to use for the healthz endpoint. (default 10254) |
|
| `--healthz-port` | Port to use for the healthz endpoint. (default 10254) |
|
||||||
|
| `--healthz-host` | Address to bind the healthz endpoint. |
|
||||||
| `--http-port` | Port to use for servicing HTTP traffic. (default 80) |
|
| `--http-port` | Port to use for servicing HTTP traffic. (default 80) |
|
||||||
| `--https-port` | Port to use for servicing HTTPS traffic. (default 443) |
|
| `--https-port` | Port to use for servicing HTTPS traffic. (default 443) |
|
||||||
| `--ingress-class` | Name of the ingress class this controller satisfies. The class of an Ingress object is set using the field IngressClassName in Kubernetes clusters version v1.18.0 or higher or the annotation "kubernetes.io/ingress.class" (deprecated). If this parameter is not set, or set to the default value of "nginx", it will handle ingresses with either an empty or "nginx" class name. |
|
| `--ingress-class` | Name of the ingress class this controller satisfies. The class of an Ingress object is set using the field IngressClassName in Kubernetes clusters version v1.18.0 or higher or the annotation "kubernetes.io/ingress.class" (deprecated). If this parameter is not set, or set to the default value of "nginx", it will handle ingresses with either an empty or "nginx" class name. |
|
||||||
|
|
|
@ -83,7 +83,8 @@ type Configuration struct {
|
||||||
ElectionID string
|
ElectionID string
|
||||||
UpdateStatusOnShutdown bool
|
UpdateStatusOnShutdown bool
|
||||||
|
|
||||||
ListenPorts *ngx_config.ListenPorts
|
HealthCheckHost string
|
||||||
|
ListenPorts *ngx_config.ListenPorts
|
||||||
|
|
||||||
DisableServiceExternalName bool
|
DisableServiceExternalName bool
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue