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

Allow Requests to be Mirrored to different backends #4379

Merged
merged 1 commit into from
Aug 14, 2019

Conversation

diazjf
Copy link

@diazjf diazjf commented Jul 30, 2019

Add a feature which allows traffic to be mirrored to additional backends. This is useful for testing how requests will behave on different "test" backends.

See https://nginx.org/en/docs/http/ngx_http_mirror_module.html

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 30, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @diazjf. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 30, 2019
@aledbf
Copy link
Member

aledbf commented Jul 30, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 30, 2019
nginx.ingress.kubernetes.io/mirror-request-body: "off"
```

For more information on the mirror module see https://nginx.org/en/docs/http/ngx_http_mirror_module.html
Copy link
Member

Choose a reason for hiding this comment

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

Please add a note mentioning the side effects of using this feature against a slow backend
https://alex.dzyoba.com/blog/nginx-mirror/

Copy link
Author

Choose a reason for hiding this comment

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

👍

@aledbf
Copy link
Member

aledbf commented Jul 30, 2019

@diazjf what's the behavior if the ingress rule contains multiple paths?

@diazjf
Copy link
Author

diazjf commented Jul 30, 2019

@diazjf what's the behavior if the ingress rule contains multiple paths?

If there are multiple paths within an ingress rule, then the traffic will be mirrored to the mirror-uri from all paths. Maybe I can specify in the docs that ideally it should be applied to one path at a time?

^ @aledbf

@diazjf
Copy link
Author

diazjf commented Jul 31, 2019

/retest

@diazjf diazjf force-pushed the mirror branch 2 times, most recently from 04b9101 to dca2ecd Compare July 31, 2019 22:05
@codecov-io
Copy link

codecov-io commented Jul 31, 2019

Codecov Report

Merging #4379 into master will increase coverage by 2.49%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4379      +/-   ##
==========================================
+ Coverage   58.63%   61.13%   +2.49%     
==========================================
  Files          88       89       +1     
  Lines        6569     7150     +581     
==========================================
+ Hits         3852     4371     +519     
- Misses       2288     2331      +43     
- Partials      429      448      +19
Impacted Files Coverage Δ
internal/ingress/types.go 0% <ø> (ø) ⬆️
internal/ingress/types_equals.go 17.91% <0%> (-0.22%) ⬇️
internal/ingress/annotations/mirror/main.go 100% <100%> (ø)
internal/ingress/annotations/annotations.go 81.42% <100%> (+0.26%) ⬆️
internal/ingress/controller/controller.go 46.82% <100%> (+0.06%) ⬆️
internal/ingress/controller/config/config.go 98.64% <0%> (+0.07%) ⬆️
internal/ingress/metric/collectors/process.go 90.42% <0%> (+2.12%) ⬆️
internal/ingress/controller/template/template.go 85.92% <0%> (+2.43%) ⬆️
internal/watch/file_watcher.go 84.61% <0%> (+3.84%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 292aca7...386486e. Read the comment docs.

@diazjf diazjf force-pushed the mirror branch 2 times, most recently from 2c2f6c5 to 1792a62 Compare August 1, 2019 03:35
Add a feature which allows traffic to be mirrored to
additional backends. This is useful for testing how
requests will behave on different "test" backends.

See https://nginx.org/en/docs/http/ngx_http_mirror_module.html
@diazjf
Copy link
Author

diazjf commented Aug 1, 2019

/retest

@diazjf
Copy link
Author

diazjf commented Aug 1, 2019

^ @aledbf ready to review 👍

@aledbf
Copy link
Member

aledbf commented Aug 6, 2019

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2019
@aledbf
Copy link
Member

aledbf commented Aug 6, 2019

@diazjf my only doubt with this feature is why not just use the canary annotations?

@diazjf
Copy link
Author

diazjf commented Aug 8, 2019

Canary does provide some of the same benefits in an easy to use way. Great post https://www.elvinefendi.com/2018/11/25/canary-deployment-with-ingress-nginx.html by @ElvinEfendi

The benefits I see for mirror are as follows:

  1. Easier migration to Kubernetes from NGINX config using mirror
  2. Exact mirror of all requests, where canary will split the traffic by weight (correct me if I'm wrong), this is good because we can test production traffic on other environments.

^ @aledbf

@aledbf
Copy link
Member

aledbf commented Aug 8, 2019

Exact mirror of all requests,

Yes, is not the same thing.

@aledbf
Copy link
Member

aledbf commented Aug 8, 2019

/approve

@ElvinEfendi
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 11, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aledbf, diazjf, ElvinEfendi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@diazjf
Copy link
Author

diazjf commented Aug 13, 2019

/retest

1 similar comment
@aledbf
Copy link
Member

aledbf commented Aug 14, 2019

/retest

@k8s-ci-robot k8s-ci-robot merged commit adef152 into kubernetes:master Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants