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

feat: support for multiple external network #2725

Merged
merged 1 commit into from Apr 28, 2023

Conversation

shane965
Copy link
Contributor

@shane965 shane965 commented Apr 27, 2023

What type of this PR

Examples of user facing changes:

  • Features

Which issue(s) this PR fixes:

Fixes #2679

WHAT

🤖 Generated by Copilot at 0b62674

This pull request adds support for configurable external networks for NAT gateways and EIPs in the kube-ovn project. It updates the CRD definitions, the Go structs, and the controller logic to handle the new fields externalSubnets and externalSubnet for VpcNatGateway and IptablesEIP respectively. It also removes the dependency on the default external network name and improves the subnet status and EIP allocation calculations.

🤖 Generated by Copilot at 0b62674

No more default external network
We choose our own destiny
externalSubnets and externalSubnet
We unleash the power of NAT and EIP

HOW

🤖 Generated by Copilot at 0b62674

  • Add externalSubnets field to VpcNatSpec and externalSubnet field to IptablesEipSpec in CRDs and types (link, link, link, link, link, link)
  • Update DeepCopyInto method for VpcNatSpec to copy externalSubnets field (link)
  • Remove VpcExternalNet constant from const.go and add it to net.go (link, link)
  • Add utility functions GetExternalNetwork and GetNatGwExternalNetwork to net.go to get external network name from user input or default value (link)
  • Remove checkVpcExternalNet method from vpc_nat_gateway.go as it is no longer needed (link, link)
  • Update vpc_nat_gateway.go to use GetNatGwExternalNetwork function and externalSubnets field to get external network name, gateway, CIDR, and pod annotation for NAT gateway (link, link)
  • Remove MACVLAN_NAD_PROVIDER constant from vpc_nat_gw_eip.go as it is no longer needed (link)
  • Update vpc_nat_gw_eip.go to use GetExternalNetwork function and externalSubnet field to get external network name, EIP CIDR, gateway, static address, and label for EIP (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Update subnet.go to check if subnet is OVN subnet and list EIPs by label selector based on external network name (link, link)
  • Update init.go to get static address for EIP from IPAM based on externalSubnet field (link)
  • Update pod_iptables_eip.go to get EIP object from lister and pass externalNetwork parameter to createOrUpdateCrdEip method (link, link)

@github-actions
Copy link
Contributor

  • The commit message should be more descriptive and informative. It should clearly state what changes were made and why.
  • There are no potential bugs or format errors in the diff.
  • It is difficult to assess performance issues without further context on the codebase and the changes made.
  • Ways to improve could include adding comments to explain complex logic, refactoring repetitive code, and adhering to consistent coding style guidelines.

@github-actions
Copy link
Contributor

  • The commit message should be more descriptive and informative. It should clearly state what changes were made and why.
  • There are no potential bugs or format errors in the diff.
  • It is difficult to assess performance issues without more context about the code being changed.
  • It would be helpful to include comments in the code explaining the purpose of each change and how it improves the code.
  • It would be good to run tests on the code after making these changes to ensure that everything still works as expected.

@shane965
Copy link
Contributor Author

in order to keep compatibility with the original code, we must to use the same function to get the external network, just like the following code:

 externalNetwork := util.GetExternalNetwork(newEip.Spec.ExternalSubnet)

if you use the field newEip.Spec.ExternalSubnet directly, this will cause compatibility issues. becasue the field newEip.Spec.ExternalSubnet may be empty.

this is not a great solution, but it works. if you have a better solution, please let me know.

pkg/util/net.go Outdated Show resolved Hide resolved
@shane965 shane965 force-pushed the feat-multi-external-network branch from c699ffc to 8096fc1 Compare April 28, 2023 02:47
@github-actions
Copy link
Contributor

  • The commit message should be more descriptive and informative. It should clearly state what changes were made and why.
  • There are no potential bugs or format errors in the diff.
  • It is difficult to assess performance issues without more context about the code being changed.
  • Ways to improve could include adding comments to explain the purpose of certain lines of code, refactoring repetitive code blocks, or optimizing algorithms for better efficiency.

@bobz965 bobz965 merged commit 66615b6 into kubeovn:master Apr 28, 2023
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vpc模式下是否支持多个外部网络,使用特定的外部网络绑定特定的vpc-nat-gw
3 participants