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

Add SnippetsFilter guide #2721

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Add SnippetsFilter guide #2721

wants to merge 18 commits into from

Conversation

bjee19
Copy link
Contributor

@bjee19 bjee19 commented Oct 23, 2024

Add SnippetsFilters guide.

Problem: We want a guide for using SnippetsFilters.

Solution: Add a SnippetsFilters guide.

Testing: Verified using make watch Hugo command.

Closes #2377

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.


@bjee19 bjee19 requested review from a team as code owners October 23, 2024 21:17
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 23, 2024
Copy link
Contributor

@ADubhlaoich ADubhlaoich left a comment

Choose a reason for hiding this comment

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

LGTM generally: I'd consider using the ghcode shortcode to explicitly show the YAML contents of files, but it might lead to reading fatigue.

Using it for the code that includes the actual snippets could show the reader what to expect if they decide to configure NGF with them, at least.

site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
examples/snippets-filter/README.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets-filters.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@77f3e97). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2721   +/-   ##
=======================================
  Coverage        ?   89.38%           
=======================================
  Files           ?      110           
  Lines           ?    10913           
  Branches        ?       50           
=======================================
  Hits            ?     9755           
  Misses          ?     1100           
  Partials        ?       58           

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


## Overview

Snippets allow Cluster Operators to insert NGINX configuration into different contexts of the
Copy link
Contributor

@sjberman sjberman Oct 24, 2024

Choose a reason for hiding this comment

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

I think we need to be clear calling them SnippetsFilters, not just Snippets. And also make it clear that these attach to an HTTP/GRPCRoute rule and apply to that rule specifically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need to be clear calling them SnippetsFilters, not just Snippets.

I followed Ingress controller's precedence here: https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-snippets/

And think that its good to stick with Snippets because it seems like that's already an established NGINX term? At least with the NIC crowd it will strike a familiar bell if we stick with saying Snippets are configured through SnippetsFilters.

And also make it clear that these attach to an HTTP/GRPCRoute rule and apply to that rule specifically.

Though, if a SF sets things in the main, http, or http.server contexts, then the SF doesn't apply to that rule specifically right? I was a little confused on this behavior as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair; after re-reading, I think it makes sense to talk about the general idea of snippets, but then describe specifically what a SnippetsFilter is (because in the future we may also have SnippetsPolicy). I'd also rename the doc to snippets.md.

Though, if a SF sets things in the main, http, or http.server contexts, then the SF doesn't apply to that rule specifically right? I was a little confused on this behavior as well.

True, but I think we should make it clear what the intention is. Maybe it can be phrased better. If someone puts something in main, it really should be because it's required for a configuration for a rule. Technically a user could put anything in there, but that's not what it's for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added some information on this, please let me know if what I have is correct and/or if there is more stuff I should add.

examples/snippets-filter/README.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ADubhlaoich ADubhlaoich left a comment

Choose a reason for hiding this comment

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

LGTM. Small changes, having taken a fresher look at the document in its totality.

site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
Copy link
Contributor

@kate-osborn kate-osborn 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 @bjee19. Sorry to jump in late with comments.

site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
NGINX configurations that NGINX Gateway Fabric generates.

Snippets are for advanced NGINX users who need more control over the generated NGINX configuration,
and can be used in cases where Gateway API resources or NGINX extension policies don't apply.
Copy link
Contributor

Choose a reason for hiding this comment

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

continuation of the suggestion above:

Suggested change
and can be used in cases where Gateway API resources or NGINX extension policies don't apply.
and only in cases where Gateway API resources or NGINX extension policies don't apply.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same comment as above with copying NIC's precedence

site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
---

## Further reading

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need a section here or in our troubleshooting guide about how to diagnose issues with SnippetsFilters. Most importantly, we need to mention somewhere (probably here) that if the SnippetsFilter cannot be resolved, the route will return a 500 HTTP error code response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a troubleshooting section in the document, let me know if you think there's anything that needs to be adjusted or added/removed, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should move this to troubleshooting guide . Its better consolidated in one place and we don't generally follow the practice of having troubleshooting sections with our traffic-management guides

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, though I did see https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-snippets/ and how they put a troubleshooting guide in with the snippets that is separate from all of their other troubleshooting guides. this also breaks their practices too it seems (I just checked some of their guides and they don't have troubleshooting guides in them)

@ADubhlaoich thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Really great troubleshooting section!

I personally like the troubleshooting info to be close to the documentation on the feature, but I'll defer to @ADubhlaoich.

site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
---

## Further reading

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should move this to troubleshooting guide . Its better consolidated in one place and we don't generally follow the practice of having troubleshooting sections with our traffic-management guides

site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
---

## Further reading

Copy link
Contributor

Choose a reason for hiding this comment

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

Really great troubleshooting section!

I personally like the troubleshooting info to be close to the documentation on the feature, but I'll defer to @ADubhlaoich.

site/content/how-to/traffic-management/snippets.md Outdated Show resolved Hide resolved
Copy link
Contributor

@kate-osborn kate-osborn left a comment

Choose a reason for hiding this comment

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

Left one suggestion that I'll leave up to you. Great work!

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
Projects
Status: 🏗 In Progress
Development

Successfully merging this pull request may close these issues.

Guide for Configuring Snippets in NGF
5 participants