diff --git a/documentation/controller.md b/documentation/controller.md index 3bf1075c..1d745b59 100644 --- a/documentation/controller.md +++ b/documentation/controller.md @@ -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` @@ -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 +``` + +

:arrow_up_small: back to top

+ +*** + diff --git a/documentation/doc.yaml b/documentation/doc.yaml index 1f401147..d50d8cea 100644 --- a/documentation/doc.yaml +++ b/documentation/doc.yaml @@ -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: |- diff --git a/pkg/controller/builder.go b/pkg/controller/builder.go index 47812225..4c382de1 100644 --- a/pkg/controller/builder.go +++ b/pkg/controller/builder.go @@ -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() diff --git a/pkg/ingress/status.go b/pkg/ingress/status.go index f219ff14..d3f23383 100644 --- a/pkg/ingress/status.go +++ b/pkg/ingress/status.go @@ -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 { diff --git a/pkg/status/updatestatus.go b/pkg/status/updatestatus.go index 8b724032..4103d284 100644 --- a/pkg/status/updatestatus.go +++ b/pkg/status/updatestatus.go @@ -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, } } @@ -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)) } } }() diff --git a/pkg/utils/flags.go b/pkg/utils/flags.go index c92271e5..322a31da 100644 --- a/pkg/utils/flags.go +++ b/pkg/utils/flags.go @@ -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"` }