-
Notifications
You must be signed in to change notification settings - Fork 742
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 additional CIDRs to be excluded from SNAT #520
Allow additional CIDRs to be excluded from SNAT #520
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
Hi @mogren , do you think this PR could be looked at? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks again!
Thanks @mogren ! |
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_CIDRS
toprovide 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:
iptable
rules to prevent SNATing for packets directed tothe excluded CIDRs
ip rule
entries to route packets directed to the excludedCIDRs through the pod's
eni
. This configuration is done both at thecni
plugin level via therpc_handler
, and the runtimenetwork
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.
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