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

Egress via Ingress VirtualServer Resource #3491

Merged
merged 19 commits into from Apr 14, 2023

Conversation

chase-kiefer
Copy link
Contributor

@chase-kiefer chase-kiefer commented Jan 26, 2023

Proposed changes

NSM would like the ability to egress traffic through a KIC VirtualServer. This PR adds the functionality and templating necessary to configure a VS resource for NSM egress. It diverges from the pattern implemented for ingress by using a CRD field instead of an annotation.

  • added internalRoute field to the virtualserver CRD
  • updated templates for internal routes in virtualserver for n+ and oss
  • added unit test to validate virtual server internal routes
  • updated virtualServerConfigurator type to have an enableInternalRoutes boolean
  • updated virtualserver configuration items to include internRoute docs

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

@chase-kiefer
Copy link
Contributor Author

chase-kiefer commented Jan 26, 2023

@nginxinc/service-mesh Looking for a review from someone on our team also. I can't add us as reviewers, so just adding a comment tagging our team.

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2023

Codecov Report

Merging #3491 (ae6aa50) into main (96d28b2) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3491      +/-   ##
==========================================
+ Coverage   52.34%   52.36%   +0.01%     
==========================================
  Files          59       59              
  Lines       16880    16890      +10     
==========================================
+ Hits         8836     8844       +8     
- Misses       7747     7749       +2     
  Partials      297      297              
Impacted Files Coverage Δ
internal/configs/version2/http.go 0.00% <ø> (ø)
internal/configs/virtualserver.go 95.16% <100.00%> (+0.02%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

internal/configs/annotations.go Outdated Show resolved Hide resolved
internal/configs/version2/nginx-plus.virtualserver.tmpl Outdated Show resolved Hide resolved
internal/configs/version2/nginx.virtualserver.tmpl Outdated Show resolved Hide resolved
Copy link
Contributor

@jbyers19 jbyers19 left a comment

Choose a reason for hiding this comment

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

LGTM

@chase-kiefer chase-kiefer force-pushed the nsm-virtualserver-egress branch 2 times, most recently from 0f677bc to 54e2ad0 Compare January 30, 2023 17:43
@github-actions github-actions bot added the helm_chart Pull requests that update the Helm Chart label Feb 27, 2023
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.

LGTM, be sure to update commit messages and PR description with the new approach.

@github-actions github-actions bot added the documentation Pull requests/issues for documentation label Feb 27, 2023
…resource

- added internalRoute field to the virtualserver CRD
- added templates for internal routes in virtualserver templates for n+ and oss
- added unit test to validate virtualserver internal routes
- added enableInternalRoutes boolean to virtualServerConfigurator type
- updated virtualserver configuration items to include internRoute docs
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.

Thanks so much @chase-kiefer ! Great work 😄

@ciarams87 ciarams87 enabled auto-merge (squash) March 9, 2023 16:45
auto-merge was automatically disabled March 10, 2023 17:40

Head branch was pushed to by a user without write access

@lucacome
Copy link
Member

@chase-kiefer I think we need a couple of changes:

  • we're missing the check for the CLI argument enable-internal-routes, if the flag is not set and we add internalRoute in the VirtualServer we should throw a warning and not write the config for it.
  • we should align the logic and variables with the Ingress side to make it easier to maintain the code. Right now in the template we have InternalRouteServer for the Spiffe server certs and SpiffeCerts for the client certs, but in Ingress we use SpiffeCerts for the server certs and SpiffeClientCerts for the client certs. I'm fine with whatever names you think make the most sense, I'd just like to have them consistent. Maybe for the sake of merging this PR, you can just use the same logic of Ingress and then refactor for both later. Up to you.

Also #3602 might remove the CLI arguments, so we might need to change the logic and look at the annotation instead...

- Add warning to catch cases where a virtual server internal route should not be created
- Switch variable names to match ingress naming scheme
@chase-kiefer chase-kiefer requested review from lucacome and removed request for jjngx and shaun-nx March 21, 2023 20:05
@ciarams87 ciarams87 self-requested a review March 29, 2023 14:33
@ciarams87 ciarams87 requested a review from vepatel March 30, 2023 16:01
@tomasohaodha tomasohaodha merged commit 36ac2ef into nginxinc:main Apr 14, 2023
59 checks passed
@brianehlert brianehlert added this to the v3.1.1 milestone Apr 17, 2023
lucacome pushed a commit that referenced this pull request May 4, 2023
* Add ability for nginx service mesh to egress through a virtualserver resource

- added internalRoute field to the virtualserver CRD
- added templates for internal routes in virtualserver templates for n+ and oss
- added unit test to validate virtualserver internal routes
- added enableInternalRoutes boolean to virtualServerConfigurator type
- updated virtualserver configuration items to include internRoute docs

* Add a description for the InternalRoute field in the VS CRD

* Add test case for nsmEgress being true in TestIsTLSEnabled

* Update the isTLSEnabled function for clarity

* Reverse function params for isTLSEnabled

* Add virtual server internal route validation and warning

- Add warning to catch cases where a virtual server internal route should not be created
- Switch variable names to match ingress naming scheme

* Add refactored VS templates to avoid duplicate listen blocks

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add conditional to prevent SpiffeClientCerts being set for internal routes

* Fix unit tests

---------

Co-authored-by: Ciara Stacke <18287516+ciarams87@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tomás Ó hAodha <86358393+tomasohaodha@users.noreply.github.com>
Co-authored-by: Venktesh Shivam Patel <ve.patel@f5.com>
(cherry picked from commit 36ac2ef)
lucacome added a commit that referenced this pull request May 4, 2023
* Add ability for nginx service mesh to egress through a virtualserver resource

- added internalRoute field to the virtualserver CRD
- added templates for internal routes in virtualserver templates for n+ and oss
- added unit test to validate virtualserver internal routes
- added enableInternalRoutes boolean to virtualServerConfigurator type
- updated virtualserver configuration items to include internRoute docs

* Add a description for the InternalRoute field in the VS CRD

* Add test case for nsmEgress being true in TestIsTLSEnabled

* Update the isTLSEnabled function for clarity

* Reverse function params for isTLSEnabled

* Add virtual server internal route validation and warning

- Add warning to catch cases where a virtual server internal route should not be created
- Switch variable names to match ingress naming scheme

* Add refactored VS templates to avoid duplicate listen blocks

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add conditional to prevent SpiffeClientCerts being set for internal routes

* Fix unit tests

---------

Co-authored-by: Ciara Stacke <18287516+ciarams87@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tomás Ó hAodha <86358393+tomasohaodha@users.noreply.github.com>
Co-authored-by: Venktesh Shivam Patel <ve.patel@f5.com>
(cherry picked from commit 36ac2ef)

Co-authored-by: Chase Kiefer <112438922+chase-kiefer@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Pull requests/issues for documentation helm_chart Pull requests that update the Helm Chart
Projects
Status: Done 🚀
Development

Successfully merging this pull request may close these issues.

None yet

9 participants