Add flag to allow custom ingress status update intervals (#5050)
This commit is contained in:
parent
5e54f66ab2
commit
2c5819e1b3
3 changed files with 15 additions and 4 deletions
|
@ -31,6 +31,7 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
"k8s.io/ingress-nginx/internal/ingress/controller"
|
||||
ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config"
|
||||
"k8s.io/ingress-nginx/internal/ingress/status"
|
||||
ing_net "k8s.io/ingress-nginx/internal/net"
|
||||
"k8s.io/ingress-nginx/internal/nginx"
|
||||
)
|
||||
|
@ -175,6 +176,8 @@ Takes the form "<host>:port". If not provided, no admission controller is starte
|
|||
streamPort = flags.Int("stream-port", 10247, "Port to use for the lua TCP/UDP endpoint configuration.")
|
||||
|
||||
profilerPort = flags.Int("profiler-port", 10245, "Port to use for expose the ingress controller Go profiler when it is enabled.")
|
||||
|
||||
statusUpdateInterval = flags.Int("status-update-interval", status.UpdateInterval, "Time interval in seconds in which the status should check if an update is required. Default is 60 seconds")
|
||||
)
|
||||
|
||||
flags.MarkDeprecated("force-namespace-isolation", `This flag doesn't do anything.`)
|
||||
|
@ -201,6 +204,13 @@ https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-g
|
|||
return true, nil, nil
|
||||
}
|
||||
|
||||
if *statusUpdateInterval < 5 {
|
||||
klog.Warningf("The defined time to update the Ingress status too low (%v seconds). Adjusting to 5 seconds", *statusUpdateInterval)
|
||||
status.UpdateInterval = 5
|
||||
} else {
|
||||
status.UpdateInterval = *statusUpdateInterval
|
||||
}
|
||||
|
||||
if *ingressClass != "" {
|
||||
klog.Infof("Watching for Ingress class: %s", *ingressClass)
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ They are set in the container spec of the `nginx-ingress-controller` Deployment
|
|||
| `--udp-services-configmap string` | Name of the ConfigMap containing the definition of the UDP services to expose. The key in the map indicates the external port to be used. The value is a reference to a Service in the form "namespace/name:port", where "port" can either be a port name or number. |
|
||||
| `--update-status` | Update the load-balancer status of Ingress objects this controller satisfies. Requires setting the publish-service parameter to a valid Service reference. (default true) |
|
||||
| `--update-status-on-shutdown` | Update the load-balancer status of Ingress objects when the controller shuts down. Requires the update-status parameter. (default true) |
|
||||
| `--status-update-interval` | Time interval in seconds in which the status should check if an update is required. (default 60 seconds) |
|
||||
| `-v`, `--v Level` | log level for V logs |
|
||||
| `--version` | Show release information about the NGINX Ingress controller and exit. |
|
||||
| `--vmodule moduleSpec` | comma-separated list of pattern=N settings for file-filtered logging |
|
||||
|
|
|
@ -40,9 +40,9 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/task"
|
||||
)
|
||||
|
||||
const (
|
||||
updateInterval = 60 * time.Second
|
||||
)
|
||||
// UpdateInterval defines the time interval, in seconds, in
|
||||
// which the status should check if an update is required.
|
||||
var UpdateInterval = 60
|
||||
|
||||
// Syncer ...
|
||||
type Syncer interface {
|
||||
|
@ -98,7 +98,7 @@ func (s statusSync) Run(stopCh chan struct{}) {
|
|||
|
||||
// when this instance is the leader we need to enqueue
|
||||
// an item to trigger the update of the Ingress status.
|
||||
wait.PollUntil(updateInterval, func() (bool, error) {
|
||||
wait.PollUntil(time.Duration(UpdateInterval)*time.Second, func() (bool, error) {
|
||||
s.syncQueue.EnqueueTask(task.GetDummyObject("sync status"))
|
||||
return false, nil
|
||||
}, stopCh)
|
||||
|
|
Loading…
Reference in a new issue