Skip to content

Commit 14772b4

Browse files
hdurand0710oktalz
authored andcommitted
MINOR: add --disable-writing-only-if-reload Ingress Controller start argument
This new argument allows to disable the default behavior to write the maps/certificates only if haproxy reloads. If this option is set, files are written to disk even if there is no haproxy reload
1 parent 509a160 commit 14772b4

File tree

5 files changed

+87
-51
lines changed

5 files changed

+87
-51
lines changed

documentation/controller.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Image can be run with arguments:
4646
| [`--disable-quic`](#--disable-quic) | `false` |
4747
| [`--quic-announce-port`](#--quic-announce-port) | |
4848
| [`--quic-bind-port`](#--quic-bind-port) | |
49+
| [`--disable-writing-only-if-reload`](#--disable-writing-only-if-reload) :construction:(dev) | `false` |
4950

5051

5152
### `--configmap`
@@ -817,3 +818,24 @@ args:
817818

818819
***
819820

821+
### `--disable-writing-only-if-reload`
822+
823+
824+
> :construction: this is only available from next version, currently available in dev build
825+
826+
Disable the delayed writing of files to disk ONLY in case of haproxy reload (= write files to disk even if no reload)
827+
828+
Possible values:
829+
830+
- Boolean value, just need to declare the flag to disable
831+
832+
Example:
833+
834+
```yaml
835+
--disable-writing-only-if-reload
836+
```
837+
838+
<p align='right'><a href='#haproxy-kubernetes-ingress-controller'>:arrow_up_small: back to top</a></p>
839+
840+
***
841+

documentation/doc.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,13 @@ image_arguments:
397397
example: |-
398398
args:
399399
- --quic-bind-port=4443
400+
- argument: --disable-writing-only-if-reload
401+
description: Disable the delayed writing of files to disk ONLY in case of haproxy reload (= write files to disk even if no reload)
402+
values:
403+
- Boolean value, just need to declare the flag to disable
404+
default: false
405+
version_min: "3.1"
406+
example: --disable-writing-only-if-reload
400407
groups:
401408
config-snippet:
402409
header: |-

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ func logInfo(logger utils.Logger, osArgs utils.OSArgs) bool {
228228
if osArgs.DisableConfigSnippets != "" {
229229
logger.Printf("Disabling config snippets for [%s]", osArgs.DisableConfigSnippets)
230230
}
231+
if osArgs.DisableDelayedWritingOnlyIfReload {
232+
logger.Printf("Disabling the delayed writing of files to disk only in case of haproxy reload (write to disk even if no reload)")
233+
}
231234
logger.Debugf("Kubernetes Informers resync period: %s", osArgs.CacheResyncPeriod.String())
232235
logger.Printf("Controller sync period: %s\n", osArgs.SyncPeriod.String())
233236

pkg/controller/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ func (c *HAProxyController) updateHAProxy() {
207207
logger.Info("HAProxy reloaded")
208208
}
209209
c.prometheusMetricsManager.UpdateReloadMetrics(err)
210+
} else if c.osArgs.DisableDelayedWritingOnlyIfReload {
211+
// If the osArgs flag is set, then write the files to disk even if there is no reload of haproxy
212+
fs.RunDelayedFuncs()
210213
}
211214

212215
c.clean(false)

pkg/utils/flags.go

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -66,55 +66,56 @@ func (n *LogLevelValue) UnmarshalFlag(value string) error {
6666

6767
// OSArgs contains arguments that can be sent to controller
6868
type OSArgs struct {
69-
ConfigMapPatternFiles NamespaceValue `long:"configmap-patternfiles" description:"configmap used to provide a list of pattern files to use in haproxy configuration " default:""`
70-
ConfigMapTCPServices NamespaceValue `long:"configmap-tcp-services" description:"configmap used to define tcp services" default:""`
71-
DefaultBackendService NamespaceValue `long:"default-backend-service" default:"" description:"default service to serve 404 page. If not specified HAProxy serves http 400"`
72-
ConfigMapErrorFiles NamespaceValue `long:"configmap-errorfiles" description:"configmap used to define custom error pages associated to HTTP error codes" default:""`
73-
DefaultCertificate NamespaceValue `long:"default-ssl-certificate" default:"" description:"secret name of the certificate"`
74-
ConfigMap NamespaceValue `long:"configmap" description:"configmap designated for HAProxy" default:""`
75-
IPV6BindAddr string `long:"ipv6-bind-address" default:"::" description:"IPv6 address the Ingress Controller listens on (if enabled)"`
76-
GatewayControllerName string `long:"gateway-controller-name" description:"sets the controller name of gatewayclass managed by the controller"`
77-
IPV4BindAddr string `long:"ipv4-bind-address" default:"0.0.0.0" description:"IPv4 address the Ingress Controller listens on (if enabled)"`
78-
RuntimeDir string `long:"runtime-dir" description:"path to HAProxy runtime directory. NOTE: works only in External mode"`
79-
IngressClass string `long:"ingress.class" default:"" description:"ingress.class to monitor in multiple controllers environment"`
80-
PublishService string `long:"publish-service" default:"" description:"Takes the form namespace/name. The controller mirrors the address of this service's endpoints to the load-balancer status of all Ingress objects it satisfies"`
81-
CfgDir string `long:"config-dir" description:"path to HAProxy configuration directory. NOTE: works only in External mode"`
82-
Program string `long:"program" description:"path to HAProxy program. NOTE: works only with External mode"`
83-
KubeConfig string `long:"kubeconfig" default:"" description:"combined with -e. location of kube config file"`
84-
HTTPBindThread string `long:"http-bind-thread" description:"default http service bind thread params eg: 1-1" default:""`
85-
HTTPSBindThread string `long:"https-bind-thread" description:"default https service bind thread params eg: 1-1" default:""`
86-
HealthzBindThread string `long:"healthz-bind-thread" description:"default healthz service bind thread params eg: 1-1" default:""`
87-
DisableConfigSnippets string `long:"disable-config-snippets" description:"Allow to disable config snippets. List of comma separated values (possible values: all/global/backend/frontend)"`
88-
Version []bool `short:"v" long:"version" description:"version"`
89-
NamespaceWhitelist []string `long:"namespace-whitelist" description:"whitelisted namespaces"`
90-
NamespaceBlacklist []string `long:"namespace-blacklist" description:"blacklisted namespaces"`
91-
Help []bool `short:"h" long:"help" description:"show this help message"`
92-
LocalPeerPort int64 `long:"localpeer-port" default:"10000" description:"port to listen on for local peer"`
93-
StatsBindPort int64 `long:"stats-bind-port" default:"1024" description:"port to listen on for stats page"`
94-
StatsBindThread string `long:"stats-bind-thread" description:"default stats service bind thread params eg: 1-1" default:""`
95-
DefaultBackendPort int `long:"default-backend-port" description:"port to use for default service" default:"6061"`
96-
ChannelSize int64 `long:"channel-size" description:"sets the size of controller buffers used to receive and send k8s events.NOTE: increase the value to accommodate large number of resources "`
97-
ControllerPort int `long:"controller-port" description:"port to listen on for controller data: prometheus, pprof" default:"6060"`
98-
HTTPBindPort int64 `long:"http-bind-port" default:"8080" description:"port to listen on for HTTP traffic"`
99-
HTTPSBindPort int64 `long:"https-bind-port" default:"8443" description:"port to listen on for HTTPS traffic"`
100-
SyncPeriod time.Duration `long:"sync-period" default:"5s" description:"Sets the period at which the controller syncs HAProxy configuration file"`
101-
CacheResyncPeriod time.Duration `long:"cache-resync-period" default:"10m" description:"Sets the underlying Shared Informer resync period: resyncing controller with informers cache"`
102-
HealthzBindPort int64 `long:"healthz-bind-port" default:"1042" description:"port to listen on for probes"`
103-
QuicAnnouncePort int64 `long:"quic-announce-port" description:"sets the port in the alt-svc header"`
104-
QuicBindPort int64 `long:"quic-bind-port" description:"sets the binding port for quic in HTTPS frontend"`
105-
LogLevel LogLevelValue `long:"log" default:"info" description:"level of log messages you can see"`
106-
DisableIPV4 bool `long:"disable-ipv4" description:"toggle to disable the IPv4 protocol from all frontends"`
107-
External bool `short:"e" long:"external" description:"use as external Ingress Controller (out of k8s cluster)"`
108-
Test bool `short:"t" description:"simulate running HAProxy"`
109-
EmptyIngressClass bool `long:"empty-ingress-class" description:"empty-ingress-class manages the behavior in case an ingress has no explicit ingress class annotation. true: to process, false: to skip"`
110-
DisableServiceExternalName bool `long:"disable-service-external-name" description:"disable forwarding to ExternalName Services due to CVE-2021-25740"`
111-
UseWiths6Overlay bool `long:"with-s6-overlay" description:"use s6 overlay to start/stpop/reload HAProxy"`
112-
DisableHTTPS bool `long:"disable-https" description:"toggle to disable the HTTPs frontend"`
113-
PprofEnabled bool `long:"pprof" short:"p" description:"enable pprof"`
114-
PrometheusEnabled bool `long:"prometheus" description:"enable prometheus of IC data"`
115-
DisableHTTP bool `long:"disable-http" description:"toggle to disable the HTTP frontend"`
116-
DisableIPV6 bool `long:"disable-ipv6" description:"toggle to disable the IPv6 protocol from all frontends"`
117-
UseWithPebble bool `long:"with-pebble" description:"use pebble to start/stop/reload HAProxy"`
118-
JobCheckCRD bool `long:"job-check-crd" description:"does not execute IC, but adds/updates CRDs"`
119-
DisableQuic bool `long:"disable-quic" description:"disable quic protocol in http frontend bindings"`
69+
ConfigMapPatternFiles NamespaceValue `long:"configmap-patternfiles" description:"configmap used to provide a list of pattern files to use in haproxy configuration " default:""`
70+
ConfigMapTCPServices NamespaceValue `long:"configmap-tcp-services" description:"configmap used to define tcp services" default:""`
71+
DefaultBackendService NamespaceValue `long:"default-backend-service" default:"" description:"default service to serve 404 page. If not specified HAProxy serves http 400"`
72+
ConfigMapErrorFiles NamespaceValue `long:"configmap-errorfiles" description:"configmap used to define custom error pages associated to HTTP error codes" default:""`
73+
DefaultCertificate NamespaceValue `long:"default-ssl-certificate" default:"" description:"secret name of the certificate"`
74+
ConfigMap NamespaceValue `long:"configmap" description:"configmap designated for HAProxy" default:""`
75+
IPV6BindAddr string `long:"ipv6-bind-address" default:"::" description:"IPv6 address the Ingress Controller listens on (if enabled)"`
76+
GatewayControllerName string `long:"gateway-controller-name" description:"sets the controller name of gatewayclass managed by the controller"`
77+
IPV4BindAddr string `long:"ipv4-bind-address" default:"0.0.0.0" description:"IPv4 address the Ingress Controller listens on (if enabled)"`
78+
RuntimeDir string `long:"runtime-dir" description:"path to HAProxy runtime directory. NOTE: works only in External mode"`
79+
IngressClass string `long:"ingress.class" default:"" description:"ingress.class to monitor in multiple controllers environment"`
80+
PublishService string `long:"publish-service" default:"" description:"Takes the form namespace/name. The controller mirrors the address of this service's endpoints to the load-balancer status of all Ingress objects it satisfies"`
81+
CfgDir string `long:"config-dir" description:"path to HAProxy configuration directory. NOTE: works only in External mode"`
82+
Program string `long:"program" description:"path to HAProxy program. NOTE: works only with External mode"`
83+
KubeConfig string `long:"kubeconfig" default:"" description:"combined with -e. location of kube config file"`
84+
HTTPBindThread string `long:"http-bind-thread" description:"default http service bind thread params eg: 1-1" default:""`
85+
HTTPSBindThread string `long:"https-bind-thread" description:"default https service bind thread params eg: 1-1" default:""`
86+
HealthzBindThread string `long:"healthz-bind-thread" description:"default healthz service bind thread params eg: 1-1" default:""`
87+
DisableConfigSnippets string `long:"disable-config-snippets" description:"Allow to disable config snippets. List of comma separated values (possible values: all/global/backend/frontend)"`
88+
Version []bool `short:"v" long:"version" description:"version"`
89+
NamespaceWhitelist []string `long:"namespace-whitelist" description:"whitelisted namespaces"`
90+
NamespaceBlacklist []string `long:"namespace-blacklist" description:"blacklisted namespaces"`
91+
Help []bool `short:"h" long:"help" description:"show this help message"`
92+
LocalPeerPort int64 `long:"localpeer-port" default:"10000" description:"port to listen on for local peer"`
93+
StatsBindPort int64 `long:"stats-bind-port" default:"1024" description:"port to listen on for stats page"`
94+
StatsBindThread string `long:"stats-bind-thread" description:"default stats service bind thread params eg: 1-1" default:""`
95+
DefaultBackendPort int `long:"default-backend-port" description:"port to use for default service" default:"6061"`
96+
ChannelSize int64 `long:"channel-size" description:"sets the size of controller buffers used to receive and send k8s events.NOTE: increase the value to accommodate large number of resources "`
97+
ControllerPort int `long:"controller-port" description:"port to listen on for controller data: prometheus, pprof" default:"6060"`
98+
HTTPBindPort int64 `long:"http-bind-port" default:"8080" description:"port to listen on for HTTP traffic"`
99+
HTTPSBindPort int64 `long:"https-bind-port" default:"8443" description:"port to listen on for HTTPS traffic"`
100+
SyncPeriod time.Duration `long:"sync-period" default:"5s" description:"Sets the period at which the controller syncs HAProxy configuration file"`
101+
CacheResyncPeriod time.Duration `long:"cache-resync-period" default:"10m" description:"Sets the underlying Shared Informer resync period: resyncing controller with informers cache"`
102+
HealthzBindPort int64 `long:"healthz-bind-port" default:"1042" description:"port to listen on for probes"`
103+
QuicAnnouncePort int64 `long:"quic-announce-port" description:"sets the port in the alt-svc header"`
104+
QuicBindPort int64 `long:"quic-bind-port" description:"sets the binding port for quic in HTTPS frontend"`
105+
LogLevel LogLevelValue `long:"log" default:"info" description:"level of log messages you can see"`
106+
DisableIPV4 bool `long:"disable-ipv4" description:"toggle to disable the IPv4 protocol from all frontends"`
107+
External bool `short:"e" long:"external" description:"use as external Ingress Controller (out of k8s cluster)"`
108+
Test bool `short:"t" description:"simulate running HAProxy"`
109+
EmptyIngressClass bool `long:"empty-ingress-class" description:"empty-ingress-class manages the behavior in case an ingress has no explicit ingress class annotation. true: to process, false: to skip"`
110+
DisableServiceExternalName bool `long:"disable-service-external-name" description:"disable forwarding to ExternalName Services due to CVE-2021-25740"`
111+
UseWiths6Overlay bool `long:"with-s6-overlay" description:"use s6 overlay to start/stpop/reload HAProxy"`
112+
DisableHTTPS bool `long:"disable-https" description:"toggle to disable the HTTPs frontend"`
113+
PprofEnabled bool `long:"pprof" short:"p" description:"enable pprof"`
114+
PrometheusEnabled bool `long:"prometheus" description:"enable prometheus of IC data"`
115+
DisableHTTP bool `long:"disable-http" description:"toggle to disable the HTTP frontend"`
116+
DisableIPV6 bool `long:"disable-ipv6" description:"toggle to disable the IPv6 protocol from all frontends"`
117+
UseWithPebble bool `long:"with-pebble" description:"use pebble to start/stop/reload HAProxy"`
118+
JobCheckCRD bool `long:"job-check-crd" description:"does not execute IC, but adds/updates CRDs"`
119+
DisableQuic bool `long:"disable-quic" description:"disable quic protocol in http frontend bindings"`
120+
DisableDelayedWritingOnlyIfReload bool `long:"disable-writing-only-if-reload" description:"disable the delayed writing of files to disk only in case of haproxy reload (=write files to disk even if no reload)"`
120121
}

0 commit comments

Comments
 (0)