Skip to content

MEDIUM: config: add disable-ingress-status-update configuration flag #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions documentation/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Image can be run with arguments:
| [`--disable-writing-only-if-reload`](#--disable-writing-only-if-reload) :construction:(dev) | `false` |
| [`--input-file`](#--input-file) :construction:(dev) | |
| [`--output-file`](#--output-file) :construction:(dev) | |
| [`--disable-ingress-status-update`](#--disable-ingress-status-update) | `false` |


### `--configmap`
Expand Down Expand Up @@ -885,3 +886,23 @@ Example:

***

### `--disable-ingress-status-update`

If set, disables updating the status field of Ingress resources by the controller.
By default, the controller will update the status field with the LoadBalancer address.
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.

Possible values:

- Boolean flag; just declare the flag to disable status updates.

Example:

```yaml
--disable-ingress-status-update
```

<p align='right'><a href='#haproxy-kubernetes-ingress-controller'>:arrow_up_small: back to top</a></p>

***

10 changes: 10 additions & 0 deletions documentation/doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,16 @@ image_arguments:
- Path a to a CRD manifest where the converted v3 CRDs will be written
example: --output-file=/home/xxx/convert/v3/global-full.yaml
version_min: "3.2"
- argument: --disable-ingress-status-update
description: |-
If set, disables updating the status field of Ingress resources by the controller.
By default, the controller will update the status field with the LoadBalancer address.
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.
values:
- Boolean flag; just declare the flag to disable status updates.
default: false
version_min: "3.0"
example: --disable-ingress-status-update
groups:
config-snippet:
header: |-
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (builder *Builder) Build() *HAProxyController {
}
updateStatusManager := builder.updateStatusManager
if updateStatusManager == nil {
updateStatusManager = status.New(builder.clientSet, builder.osArgs.IngressClass, builder.osArgs.EmptyIngressClass)
updateStatusManager = status.New(builder.clientSet, builder.osArgs.IngressClass, builder.osArgs.EmptyIngressClass, builder.osArgs.DisableIngressStatusUpdate)
}
hostname, _ := os.Hostname()
podIP := utils.GetIP()
Expand Down
7 changes: 6 additions & 1 deletion pkg/ingress/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import (
"k8s.io/client-go/kubernetes"
)

func (i *Ingress) UpdateStatus(client *kubernetes.Clientset) (err error) {
func (i *Ingress) UpdateStatus(client *kubernetes.Clientset, disableStatusUpdate bool) (err error) {
if disableStatusUpdate {
logger.Tracef("Skipping update of LoadBalancer status in ingress %s/%s due to configuration", i.resource.Namespace, i.resource.Name)
return nil
}

var lbi []networkingv1.IngressLoadBalancerIngress

for _, addr := range i.resource.Addresses {
Expand Down
20 changes: 11 additions & 9 deletions pkg/status/updatestatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ type UpdateStatusManager interface {
}

type UpdateStatusManagerImpl struct {
client *kubernetes.Clientset
ingressClass string
updateIngresses []*ingress.Ingress
emptyIngressClass bool
client *kubernetes.Clientset
ingressClass string
updateIngresses []*ingress.Ingress
emptyIngressClass bool
disableIngressStatusUpdate bool
}

func New(client *kubernetes.Clientset, ingressClass string, emptyIngressClass bool) UpdateStatusManager {
func New(client *kubernetes.Clientset, ingressClass string, emptyIngressClass bool, disableIngressStatusUpdate bool) UpdateStatusManager {
return &UpdateStatusManagerImpl{
client: client,
ingressClass: ingressClass,
emptyIngressClass: emptyIngressClass,
client: client,
ingressClass: ingressClass,
emptyIngressClass: emptyIngressClass,
disableIngressStatusUpdate: disableIngressStatusUpdate,
}
}

Expand Down Expand Up @@ -75,7 +77,7 @@ func (m *UpdateStatusManagerImpl) Update(k store.K8s, h haproxy.HAProxy, a annot
go func() {
for _, ing := range ingresses {
if ing != nil {
errs.Add(ing.UpdateStatus(m.client))
errs.Add(ing.UpdateStatus(m.client, m.disableIngressStatusUpdate))
}
}
}()
Expand Down
1 change: 1 addition & 0 deletions pkg/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@ type OSArgs struct {
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)"`
CRDInputFile string `long:"input-file" description:"The file path of a CRD manifest to convert"`
CRDOutputFile string `long:"output-file" description:"The file path of the converted (to the most recent version) CRD manifest"`
DisableIngressStatusUpdate bool `long:"disable-ingress-status-update" description:"If true, disables updating the status field of Ingress resources"`
}