Allow additional CIDRs to be excluded from SNAT#520
Merged
mogren merged 4 commits intoaws:masterfrom Jul 11, 2019
Conversation
21a8a6a to
65aa823
Compare
Introduces a mechanism to provide an exclusion list of CIDRs that should not be SNATed. Adds an environment variable `AWS_VPC_K8S_CNI_EXCLUDE_SNAT_CIDRS` to provide a comma separated list of ipv4 CIDRs to exclude from SNAT. The value of this environment variable will only be use when `AWS_VPC_K8S_CNI_EXTERNALSNAT` is false. The SNAT exclusion CIDRs will be used to: - Generate `iptable` rules to prevent SNATing for packets directed to the excluded CIDRs - Generate `ip rule` entries to route packets directed to the excluded CIDRs through the pod's `eni`. These configuration is done both at the `cni` plugin level via the `rpc_handler`, and the runtime `network` api. Given that the list of excluded CIDRs may vary by configuration it was necessary to include a mechanism to clean up stale SNAT rules. If a CIDR is removed from the exclusion list, the corresponding `iptable` rule will be removed as well, and the chain will be adjusted. Connects aws#469 Co-authored-by: @rewiko Co-authored-by: @yorg1st
65aa823 to
b30f2ba
Compare
Contributor
Author
|
Hi @mogren , do you think this PR could be looked at? |
mogren
suggested changes
Jul 10, 2019
Contributor
mogren
left a comment
There was a problem hiding this comment.
Nice work, thanks a lot for adding this.
Just a few small nitpicks to fix and I'd be happy to merge it.
`format` applies formatting to the project's go files. `check-format` checks that no files require formatting; if they do it will fail the command. It adds the `check-format` target to the travis build so that CI fails if files are not properly formatted.
mogren
approved these changes
Jul 11, 2019
Contributor
mogren
left a comment
There was a problem hiding this comment.
Looks great, thanks again!
Contributor
Author
|
Thanks @mogren ! |
This was referenced Sep 18, 2019
This was referenced Sep 28, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connects to #469
Introduces a mechanism to provide an exclusion list of CIDRs that should
not be SNATed.
Adds an environment variable
AWS_VPC_K8S_CNI_EXCLUDE_SNAT_CIDRStoprovide a comma separated list of ipv4 CIDRs to exclude from SNAT.
The value of this environment variable will only be use when
AWS_VPC_K8S_CNI_EXTERNALSNATis false.The SNAT exclusion CIDRs will be used to:
iptablerules to prevent SNATing for packets directed tothe excluded CIDRs
ip ruleentries to route packets directed to the excludedCIDRs through the pod's
eni. This configuration is done both at thecniplugin level via therpc_handler, and the runtimenetworkapi.Given that the list of excluded CIDRs may vary by configuration it was
necessary to include a mechanism to clean up stale SNAT rules. If a
CIDR is removed from the exclusion list, the corresponding
iptablerule will be removed as well, and the chain will be adjusted.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Co-authored-by: @rewiko
Co-authored-by: @yorg1st