-
Notifications
You must be signed in to change notification settings - Fork 3.3k
egress-gateway: Add IPv6 support #39068
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
base: main
Are you sure you want to change the base?
Conversation
Commit df54cf7 does not match "(?m)^Signed-off-by:". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
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.
LGTM for docs
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.
One minor change from a @cilium/docs-structure reviewer perspective.
Please also merge all the commits together and rebase against the tip of the main branch. The merge commit seems to be causing some confusion in the pull request.
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.
The changes to docs look good to me 👍
/test |
The egress gateway Go IPv6 tests are failing, looks related to the PR. |
When I ran the privileged tests for the egressgateway package with sudo -E PRIVILEGED_TESTS=1 go test -v ./pkg/egressgateway/..., three tests failed: TestEgressGatewayManager - Failed with error: "mismatched gateway IP"
|
0cb967c
to
7f2c72a
Compare
Commits df54cf7, 53a156e, 1f16fc0 do not match "(?m)^Signed-off-by:". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
7f2c72a
to
bb32eba
Compare
This commit adds IPv6 support to the egress gateway feature. It includes: 1. A new flag `--enable-egress-gateway` that enables both IPv4 and IPv6 egress gateway functionality, while keeping the old `--enable-ipv4-egress-gateway` flag for backward compatibility. 2. Updates to the CRD schema to accept both IPv4 and IPv6 addresses. 3. Validation to reject policies with mismatched IP families. 4. Support for IPv6 egress IPs in policy configuration. 5. Tests for IPv6 egress gateway functionality. Signed-off-by: Syed Azeez <syedazeez337@gmail.com>
bb32eba
to
d1a5e73
Compare
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.
Hey @syedazeez337,
Sorry for the long delay, I'm not requested as a reviewer on this PR so it slipped of my plate. Apologies for that.
Please see my comments below for a first round of review.
// TODO: deprecate --enable-ipv4-egress-gateway, create new --enable-egress-gateway | ||
if !dcfg.EnableIPv4EgressGateway { | ||
// Check if either IPv4 or IPv6 egress gateway is enabled | ||
if !dcfg.EnableIPv4EgressGateway && !dcfg.EnableEgressGateway { |
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.
I think here we can still just have one daemon config value. However you should add some code in pkg/option/config.go
, to make sure the config value is set correctly depending on how users set the option configs flag. I would fdo this with the following steps:
- Rename
DaemonConfig.EnableIPv4EgressGateway
toDaemonConfig.EnableEgressGateway
- Set
DaemonConfig.EnableEgressGateway
to true if either of the option flagsenable-ipv4-egress-gateway
orenable-egress-gateway
is set to true. You can access them through viper.
This way we can keep most of the code the same, we added a new option flag, deprecated the old one but nothing for existing users will change if they keep running with enable-ipv4-egress-gateway
after an upgrade.
@@ -198,10 +198,19 @@ func NewEgressGatewayManager(p Params) (out struct { | |||
return out, errors.New("egress gateway is not supported in combination with the CiliumEndpointSlice feature") | |||
} | |||
|
|||
// TODO: refactor config checks for both ipv4 and ipv6, and derive whether the environment supports egress gateway policies for either protocol |
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.
I think for now we should keep this code as is, and keep the TODO comment. We can tackle this independently after this PR. That's why I created two separate issues. Making sure we do this correctly is important so that we don't break existing deployments. For example you suggested change could potentially break an existing user-deployment that uses ipv4 egress gateway policies, has ipv6 enabled as well but sets dcfg.EnableIPv6Masquerade
to false deliberately. For such users cilium would suddenly fail after an upgrade, without them having changed a thing. This should be avoided.
So let's stick to deprecating the old option flag and enabling users to use the egressIP field in this PR.
@@ -359,6 +366,28 @@ func ParseCEGP(cegp *v2.CiliumEgressGatewayPolicy) (*PolicyConfig, error) { | |||
} | |||
} | |||
|
|||
// Check for mismatched IP families |
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.
I think this code could be a bit less verbose and can be run earlier in this function. I would propose to add something like the following, right after we have collected all the destination CIDRs:
// Check for mismatched IP families | |
for _, cidr := range dstCidrList { | |
if cidr.Addr().Is6() && policyGwc.egressIP.IsValid() && policyGwc.egressIP.Is4() { | |
return nil, fmt.Errorf("mismatched IP families: IPv4 egress IP with IPv6 destination CIDRs") | |
} | |
if cidr.Addr().Is4() && policyGwc.egressIP.IsValid() && policyGwc.egressIP.Is6() { | |
return nil, fmt.Errorf("mismatched IP families: IPv6 egress IP with IPv4 destination CIDRs") | |
} | |
} |
@@ -1671,6 +1674,7 @@ type DaemonConfig struct { | |||
|
|||
EnableBPFClockProbe bool | |||
EnableIPv4EgressGateway bool |
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.
As I suggested above, I think we can remove this daemon config parameter.
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.
Instead of adding a new ipv6 only test file, please see the TestEgressGatewayCEGPParser
function in manager_privileged_test.go
and add the needed test cases there.
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.
This file is code-generated I believe, to make any changes here you'll have to change pkg/k8s/apis/cilium.io/v2/cegp_types.go
.
default route. | ||
format: ipv4 | ||
format: ip |
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.
Are you certain that ip
is a valid format parameter? I can't find it in the OpenAPI v3 spec?
egress-gateway: Add IPv6 support
Description
This PR adds IPv6 support to the egress gateway feature by introducing a new
--enable-egress-gateway
flag that enables egress gateway functionality for both IPv4 and IPv6. The existing--enable-ipv4-egress-gateway
flag is marked as deprecated but still functional for backward compatibility.Changes
--enable-egress-gateway
flag that enables egress gateway for both IPv4 and IPv6flags.MarkDeprecated
Testing
make -C Documentation update-cmdref
to update the command referenceRelated Issues
Fixes #38957
Fixes #38962