Skip to content

feat: add LB session persistence and listener idle timeout features #130

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 1 commit into
base: main
Choose a base branch
from

Conversation

mnogueiraops
Copy link

PS: Still waiting for my OCA agreement to be accepted.

Subject: feat: Add LB Cookie Session Persistence and Listener Idle Timeout

Related Issue: Fixes #106 + Add LB side Cookie Session Persistence

Description:

This pull request introduces two significant enhancements to the OCI Native Ingress Controller, allowing finer-grained control over OCI Load Balancer configurations through IngressClassParameters:

  1. Load Balancer (LB) Cookie-Based Session Persistence:
    • A new lbCookieSessionPersistenceConfiguration field can now be defined within IngressClassParameters. This allows users to enable and configure LB cookie stickiness (e.g., cookie name, max-age/timeout, path, domain, security attributes) for backend sets.
    • The ingress controller now applies this configuration to backend sets created based on Ingress rules.
    • The ingressclass controller also applies this configuration to the default backend set of the Load Balancer.
  2. Default Listener Idle Timeout:
    • A new defaultListenerIdleTimeoutInSeconds field can be specified in IngressClassParameters.
    • The ingress controller uses this value to configure the idle timeout on listeners (e.g., HTTP, HTTPS) it provisions for Ingress resources.

Summary of Changes:

  • API Updated (api/v1beta1/ingressclassparameters_types.go):
    • Added lbCookieSessionPersistenceConfiguration (and its LbCookieSessionPersistenceConfigurationDetails struct) to IngressClassParametersSpec.
    • Added defaultListenerIdleTimeoutInSeconds to IngressClassParametersSpec.
  • Controller Logic Modified:
    • pkg/controllers/ingressclass/ingressclass.go: Updated to handle lbCookieSessionPersistenceConfiguration for the default backend set.
    • pkg/controllers/ingress/ingress.go:
      • Enhanced to apply defaultListenerIdleTimeoutInSeconds during listener creation and updates.
      • Refactored syncBackendSet to apply lbCookieSessionPersistenceConfiguration to Ingress-derived backend sets during creation and updates, ensuring a consolidated update approach.
  • OCI Client & LoadBalancer Helpers Updated:
    • Modified methods in pkg/loadbalancer/loadbalancer.go (CreateListenerUpdateListenerCreateBackendSetUpdateBackendSet) to support the new parameters.
    • Extended LoadBalancerInterface in pkg/oci/client/loadbalancer.go (e.g., added GetBackendSet) and its implementation.
  • Build Error Corrections: Addressed various compilation issues identified during development, including CRD generation marker fixes, OCI SDK type mismatches, and incorrect function signatures/calls.
  • Examples Updated: The example IngressClassParameters YAML (deploy/example/customresource/ingressclassparameter.yaml) has been updated with commented-out sections for the new configurations.

Documentation Impact:

  • The primary README.md or other documentation detailing IngressClassParameters fields will need to be updated to describe lbCookieSessionPersistenceConfiguration and defaultListenerIdleTimeoutInSeconds.

Validation Steps:

Prerequisites:

  1. Ensure the controller is built with these changes.
  2. Regenerate the IngressClassParameters CRD manifest (e.g., using controller-gen crd paths=./api/v1beta1/... output:crd:dir=./deploy/manifests/oci-native-ingress-controller/crds) and apply the updated CRD to your Kubernetes cluster (kubectl apply -f ...). (Already commited with this done)
  3. Deploy the new controller image.

1. Validate LB Cookie Session Persistence:
a. Define an IngressClassParameters resource with the lbCookieSessionPersistenceConfiguration section (e.g., set cookieName, timeoutInSeconds).
b. Create an IngressClass referencing these parameters.
c. Deploy an application with an Ingress using this IngressClass.
d. Verify in OCI Console: Check the OCI Load Balancer. The backend set corresponding to your Ingress rule should have the specified cookie session persistence settings.
e. Test Stickiness: Make multiple requests from a single client to your application's endpoint. Verify requests are routed to the same backend pod and check for the presence of the configured cookie in HTTP responses.

2. Validate Default Listener Idle Timeout:
a. Define an IngressClassParameters resource setting defaultListenerIdleTimeoutInSeconds (e.g., to 120).
b. Ensure your IngressClass uses these parameters.
c. Deploy an Ingress that creates listeners.
d. Verify in OCI Console: Check the listeners on the OCI Load Balancer. Their "Idle Timeout" should match the value from defaultListenerIdleTimeoutInSeconds.

- Correct controller-gen marker parsing.
- Fix type mismatches with OCI SDK structs.
- Update OCI client interface and helper method signatures/calls.
- Resolve undefined variable and import errors in controllers.

API (api/v1beta1/ingressclassparameters_types.go):
- Add lbCookieSessionPersistenceConfiguration and its struct.
- Add defaultListenerIdleTimeoutInSeconds.

Controllers:
- ingressclass.go: handle lbCookieSessionPersistenceConfiguration for default backend set.
- ingress.go: apply defaultListenerIdleTimeoutInSeconds to listeners; refactor syncBackendSet for consolidated updates.

OCI Client & Helpers:
- Update methods in loadbalancer.go to support new parameters.
- Extend LoadBalancerInterface and its implementation.

Signed-off-by: Marcos Nogueira <[email protected]>
Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label May 24, 2025
Copy link

Thank you for signing the OCA.

@oracle-contributor-agreement oracle-contributor-agreement bot added OCA Verified All contributors have signed the Oracle Contributor Agreement. and removed OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. labels May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to configure timeout values for listener
1 participant