Skip to content

Commit d520183

Browse files
Vladyslav Riabykoktalz
authored andcommitted
MEDIUM: config: add disable-ingress-status-update configuration flag
1 parent d8adc57 commit d520183

File tree

6 files changed

+50
-11
lines changed

6 files changed

+50
-11
lines changed

documentation/controller.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Image can be run with arguments:
4949
| [`--disable-writing-only-if-reload`](#--disable-writing-only-if-reload) :construction:(dev) | `false` |
5050
| [`--input-file`](#--input-file) :construction:(dev) | |
5151
| [`--output-file`](#--output-file) :construction:(dev) | |
52+
| [`--disable-ingress-status-update`](#--disable-ingress-status-update) | `false` |
5253

5354

5455
### `--configmap`
@@ -885,3 +886,23 @@ Example:
885886

886887
***
887888

889+
### `--disable-ingress-status-update`
890+
891+
If set, disables updating the status field of Ingress resources by the controller.
892+
By default, the controller will update the status field with the LoadBalancer address.
893+
This flag is useful if you want to prevent the controller from modifying Ingress status, for example when using another controller or external process to manage status updates.
894+
895+
Possible values:
896+
897+
- Boolean flag; just declare the flag to disable status updates.
898+
899+
Example:
900+
901+
```yaml
902+
--disable-ingress-status-update
903+
```
904+
905+
<p align='right'><a href='#haproxy-kubernetes-ingress-controller'>:arrow_up_small: back to top</a></p>
906+
907+
***
908+

documentation/doc.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,16 @@ image_arguments:
420420
- Path a to a CRD manifest where the converted v3 CRDs will be written
421421
example: --output-file=/home/xxx/convert/v3/global-full.yaml
422422
version_min: "3.2"
423+
- argument: --disable-ingress-status-update
424+
description: |-
425+
If set, disables updating the status field of Ingress resources by the controller.
426+
By default, the controller will update the status field with the LoadBalancer address.
427+
This flag is useful if you want to prevent the controller from modifying Ingress status, for example when using another controller or external process to manage status updates.
428+
values:
429+
- Boolean flag; just declare the flag to disable status updates.
430+
default: false
431+
version_min: "3.0"
432+
example: --disable-ingress-status-update
423433
groups:
424434
config-snippet:
425435
header: |-

pkg/controller/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (builder *Builder) Build() *HAProxyController {
181181
}
182182
updateStatusManager := builder.updateStatusManager
183183
if updateStatusManager == nil {
184-
updateStatusManager = status.New(builder.clientSet, builder.osArgs.IngressClass, builder.osArgs.EmptyIngressClass)
184+
updateStatusManager = status.New(builder.clientSet, builder.osArgs.IngressClass, builder.osArgs.EmptyIngressClass, builder.osArgs.DisableIngressStatusUpdate)
185185
}
186186
hostname, _ := os.Hostname()
187187
podIP := utils.GetIP()

pkg/ingress/status.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import (
1111
"k8s.io/client-go/kubernetes"
1212
)
1313

14-
func (i *Ingress) UpdateStatus(client *kubernetes.Clientset) (err error) {
14+
func (i *Ingress) UpdateStatus(client *kubernetes.Clientset, disableStatusUpdate bool) (err error) {
15+
if disableStatusUpdate {
16+
logger.Tracef("Skipping update of LoadBalancer status in ingress %s/%s due to configuration", i.resource.Namespace, i.resource.Name)
17+
return nil
18+
}
19+
1520
var lbi []networkingv1.IngressLoadBalancerIngress
1621

1722
for _, addr := range i.resource.Addresses {

pkg/status/updatestatus.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ type UpdateStatusManager interface {
1717
}
1818

1919
type UpdateStatusManagerImpl struct {
20-
client *kubernetes.Clientset
21-
ingressClass string
22-
updateIngresses []*ingress.Ingress
23-
emptyIngressClass bool
20+
client *kubernetes.Clientset
21+
ingressClass string
22+
updateIngresses []*ingress.Ingress
23+
emptyIngressClass bool
24+
disableIngressStatusUpdate bool
2425
}
2526

26-
func New(client *kubernetes.Clientset, ingressClass string, emptyIngressClass bool) UpdateStatusManager {
27+
func New(client *kubernetes.Clientset, ingressClass string, emptyIngressClass bool, disableIngressStatusUpdate bool) UpdateStatusManager {
2728
return &UpdateStatusManagerImpl{
28-
client: client,
29-
ingressClass: ingressClass,
30-
emptyIngressClass: emptyIngressClass,
29+
client: client,
30+
ingressClass: ingressClass,
31+
emptyIngressClass: emptyIngressClass,
32+
disableIngressStatusUpdate: disableIngressStatusUpdate,
3133
}
3234
}
3335

@@ -75,7 +77,7 @@ func (m *UpdateStatusManagerImpl) Update(k store.K8s, h haproxy.HAProxy, a annot
7577
go func() {
7678
for _, ing := range ingresses {
7779
if ing != nil {
78-
errs.Add(ing.UpdateStatus(m.client))
80+
errs.Add(ing.UpdateStatus(m.client, m.disableIngressStatusUpdate))
7981
}
8082
}
8183
}()

pkg/utils/flags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,5 @@ type OSArgs struct {
122122
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)"`
123123
CRDInputFile string `long:"input-file" description:"The file path of a CRD manifest to convert"`
124124
CRDOutputFile string `long:"output-file" description:"The file path of the converted (to the most recent version) CRD manifest"`
125+
DisableIngressStatusUpdate bool `long:"disable-ingress-status-update" description:"If true, disables updating the status field of Ingress resources"`
125126
}

0 commit comments

Comments
 (0)