Skip to content
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

Implement ClientSettingsPolicy #1940

Merged
merged 38 commits into from
May 20, 2024

Conversation

kate-osborn
Copy link
Contributor

Proposed changes

Write a clear and concise description that helps reviewers understand the purpose and impact of your changes. Use the
following format:

Problems:

  • As a Cluster Operator, I want to set defaults for client settings that will work for most applications so that most Application Developers will not have to tweak these settings.
  • As an Application Developer, I want to be able to configure client settings for my application based on its behavior or requirements.
  • As an Application Developer, I want to override the defaults for client settings set by the Cluster Operator because the defaults do not satisfy my application's requirements or behavior.

Solution: Implement ClientSettingsPolicy API.

  • Cluster operators can create a ClientSettingsPolicy for a Gateway to set defaults for client settings that apply to all routes attached to that Gateway.
  • App devs can create ClientSettingsPolicies for their routes and specify client settings that override the defaults set by the cluster operator.

Testing: Manually tested the following cases:

  • attaching to Gateway
  • attaching to HTTPRoute
  • attaching to GRPCRoute
  • merging and inheritance behavior
  • conflict handling

Closes #1792 #1760

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.

Introduces ClientSettingsPolicy CRD. This CRD allows users to configure the behavior of the connection between the client and NGINX.

@kate-osborn kate-osborn requested review from a team as code owners May 7, 2024 02:46
@github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request helm-chart Relates to helm chart labels May 7, 2024
Copy link

codecov bot commented May 7, 2024

Codecov Report

Attention: Patch coverage is 95.46248% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 87.66%. Comparing base (9212c4b) to head (2842083).

Files Patch % Lines
internal/mode/static/manager.go 4.76% 20 Missing ⚠️
internal/framework/helpers/helpers.go 85.71% 1 Missing and 1 partial ⚠️
internal/mode/static/state/change_processor.go 92.30% 1 Missing and 1 partial ⚠️
internal/mode/static/state/store.go 92.30% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1940      +/-   ##
==========================================
+ Coverage   87.04%   87.66%   +0.62%     
==========================================
  Files          89       93       +4     
  Lines        6096     6557     +461     
  Branches       50       50              
==========================================
+ Hits         5306     5748     +442     
- Misses        737      753      +16     
- Partials       53       56       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sjberman sjberman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this!

internal/mode/static/nginx/config/servers_template.go Outdated Show resolved Hide resolved
internal/mode/static/nginx/config/servers.go Outdated Show resolved Hide resolved
internal/mode/static/policies/clientsettings/validator.go Outdated Show resolved Hide resolved
internal/mode/static/policies/clientsettings/validator.go Outdated Show resolved Hide resolved
internal/mode/static/state/graph/policies_test.go Outdated Show resolved Hide resolved
internal/mode/static/state/graph/policies_test.go Outdated Show resolved Hide resolved
internal/mode/static/state/graph/policy_ancestor.go Outdated Show resolved Hide resolved
internal/mode/static/state/store.go Show resolved Hide resolved
charts/nginx-gateway-fabric/templates/rbac.yaml Outdated Show resolved Hide resolved
@sjberman
Copy link
Contributor

sjberman commented May 7, 2024

I wonder if we want a tech-debt issue to rework BackendTLSPolicy at some point to use this new framework.

@sjberman
Copy link
Contributor

sjberman commented May 8, 2024

Is the PolicyAncestorStatus supposed to apply to Inherited policies? I thought I read that it only applies to direct policies.

@kate-osborn
Copy link
Contributor Author

Is the PolicyAncestorStatus supposed to apply to Inherited policies? I thought I read that it only applies to direct policies.

Yeah, currently, it is only required for direct policies, but there's been some discussion to include it on inherited policies. Plus, the spec is moving towards collapsing direct and inherited policies into one policy type with a strategy field.

@pleshakov talked me into including PolicyAncestorStatus on the ClientSettingsPolicy here: #1793 (comment)

@kate-osborn
Copy link
Contributor Author

I wonder if we want a tech-debt issue to rework BackendTLSPolicy at some point to use this new framework.

This might be tricky. We'd have to create a wrapper class to pass it around like an NGF Policy. Then, we'd have to figure out how to genericize the ConfigMap resolving part. I'm sure it can be done, but it's not an easy lift.

internal/framework/helpers/helpers_test.go Show resolved Hide resolved
internal/mode/static/manager.go Outdated Show resolved Hide resolved
internal/mode/static/policies/clientsettings/validator.go Outdated Show resolved Hide resolved
internal/mode/static/sort/sort.go Outdated Show resolved Hide resolved
internal/mode/static/state/change_processor_test.go Outdated Show resolved Hide resolved
Copy link
Member

@ciarams87 ciarams87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @kate-osborn! 🚀

internal/mode/static/handler.go Show resolved Hide resolved
internal/mode/static/state/graph/policies.go Show resolved Hide resolved
internal/mode/static/state/graph/policies.go Show resolved Hide resolved
internal/mode/static/manager.go Outdated Show resolved Hide resolved
internal/mode/static/nginx/config/http/config.go Outdated Show resolved Hide resolved
internal/mode/static/nginx/config/servers.go Show resolved Hide resolved
internal/mode/static/nginx/config/servers_test.go Outdated Show resolved Hide resolved
internal/mode/static/nginx/config/servers_test.go Outdated Show resolved Hide resolved
internal/mode/static/policies/clientsettings/validator.go Outdated Show resolved Hide resolved
Copy link
Member

@ciarams87 ciarams87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 🚀 🚀

@kate-osborn kate-osborn force-pushed the enh/client-settings-policy branch from 916f58e to 2842083 Compare May 20, 2024 20:52
@kate-osborn kate-osborn merged commit 10bae0b into nginxinc:main May 20, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request helm-chart Relates to helm chart release-notes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

ClientSettingsPolicy for Routes
5 participants