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: add ovn dnat #2565

Merged
merged 5 commits into from Mar 30, 2023
Merged

feat: add ovn dnat #2565

merged 5 commits into from Mar 30, 2023

Conversation

ShaPoHun
Copy link
Contributor

@ShaPoHun ShaPoHun commented Mar 28, 2023

What type of this PR

Examples of user facing changes:

  • Features
    add ovn dnat

@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 determine if there are any performance issues without further context on the codebase and the changes made.
  • Ways to improve could include adding comments to explain the purpose of certain functions or variables, improving variable naming conventions, and ensuring consistency in coding style throughout the file.

pkg/ovs/ovn-nbctl-legacy.go Outdated Show resolved Hide resolved
pkg/ovs/ovn-nbctl-legacy.go Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

  • The commit message should be more descriptive and informative. It should clearly state the purpose of the code changes made in the patch.
  • There are no potential bugs or format errors in the patch diff.
  • It is difficult to assess performance issues without further context on the code changes made.
  • Ways to improve could include adding comments to explain the code changes, using more descriptive variable names, and following consistent coding conventions throughout the codebase.

pkg/controller/ovn_dnat.go Outdated Show resolved Hide resolved
pkg/controller/ovn_dnat.go Outdated Show resolved Hide resolved
pkg/controller/ovn_dnat.go Outdated Show resolved Hide resolved
pkg/controller/ovn_dnat.go Outdated Show resolved Hide resolved
@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 complex logic, refactoring repetitive code, or optimizing algorithms for better efficiency.

pkg/controller/ovn_dnat.go Outdated Show resolved Hide resolved
pkg/controller/ovn_dnat.go Outdated Show resolved Hide resolved
@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 any potential edge cases that were considered.
  • Consider adding unit tests to ensure that the changes do not introduce new bugs or regressions.
  • It may be beneficial to refactor some of the code to improve readability and maintainability.

@ShaPoHun
Copy link
Contributor Author

  1. 前置部署方式:https://kubeovn.github.io/docs/v1.12.x/advance/ovn-eip-fip-snat/

  2. 方案使用方式:

kind: OvnDnatRule
apiVersion: kubeovn.io/v1
metadata:
  name: eip-dnat
spec:
  ovnEip: eip-dnat
  ipName: cjhvpc-3.qa
  protocol: tcp
  internalPort: "22"
  externalPort: "22"
  • ovnEip:ovnEip资源名称
  • ipName:ip资源名称
  • protocol:dnat使用协议,支持tcp、udp
  1. 资源查看:
# k get odnat
NAME            EIP             PROTOCOL   V4EIP        V4IP           INTERNALPORT   EXTERNALPORT   IPNAME          READY
eip-dnat        eip-dnat        tcp        10.5.49.4    10.116.16.30   22             22             cjhvpc-3.qa     true

@bobz965
Copy link
Collaborator

bobz965 commented Mar 29, 2023

  1. 前置部署方式:https://kubeovn.github.io/docs/v1.12.x/advance/ovn-eip-fip-snat/
  2. 方案使用方式:
kind: OvnDnatRule
apiVersion: kubeovn.io/v1
metadata:
  name: eip-dnat
spec:
  ovnEip: eip-dnat
  ipName: cjhvpc-3.qa
  protocol: tcp
  internalPort: "22"
  externalPort: "22"
  • ovnEip:ovnEip资源名称
  • ipName:ip资源名称
  • protocol:dnat使用协议,支持tcp、udp
  1. 资源查看:
# k get odnat
NAME            EIP             PROTOCOL   V4EIP        V4IP           INTERNALPORT   EXTERNALPORT   IPNAME          READY
eip-dnat        eip-dnat        tcp        10.5.49.4    10.116.16.30   22             22             cjhvpc-3.qa     true

再贴下lb的记录,以及连通性的测试 ??

pkg/apis/kubeovn/v1/types.go Outdated Show resolved Hide resolved

eipName := cachedDnat.Spec.OvnEip
if len(eipName) == 0 {
klog.Errorf("failed to create dnat rule, should set eip")
Copy link
Collaborator

Choose a reason for hiding this comment

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

should return err?

pkg/controller/ovn_dnat.go Outdated Show resolved Hide resolved
pkg/controller/ovn_dnat.go Show resolved Hide resolved
pkg/controller/ovn_dnat.go Outdated Show resolved Hide resolved
externalEndpoint := net.JoinHostPort(externalIp, externalPort)
internalEndpoint := net.JoinHostPort(internalIp, internalPort)

if err := c.ovnLegacyClient.CreateLoadBalancerRule(dnatName, externalEndpoint, internalEndpoint, protocol); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

使用 libovsdb api 替换原有 api 接口的操作,正在进行中,可以看下 LoadBalancer 的操作,是不是有新的api?
如果有的话,可以考虑替换为新的 api 接口

@ShaPoHun
Copy link
Contributor Author

  1. 前置部署方式:https://kubeovn.github.io/docs/v1.12.x/advance/ovn-eip-fip-snat/

  2. 方案使用方式:

kind: OvnDnatRule
apiVersion: kubeovn.io/v1
metadata:
  name: eip-dnat
spec:
  ovnEip: eip-dnat
  ipName: cjhvpc-3.qa
  protocol: tcp
  internalPort: "22"
  externalPort: "22"
  • ovnEip:ovnEip资源名称
  • ipName:ip资源名称
  • protocol:dnat使用协议,支持tcp、udp
  1. 资源查看:
# k get odnat
NAME            EIP             PROTOCOL   V4EIP        V4IP           INTERNALPORT   EXTERNALPORT   IPNAME          READY
eip-dnat        eip-dnat        tcp        10.5.49.4    10.116.16.30   22             22             cjhvpc-3.qa     true

4.验证

# k ko nbctl lb-list
UUID                                    LB                  PROTO      VIP              IPs
d78d8ef5-bb5d-404e-98a6-6ef16e230078    eip-dnat            tcp        10.5.49.4:22     10.116.16.30:22
# k ko nbctl lr-lb-list qa
UUID                                    LB                  PROTO      VIP             IPs
d78d8ef5-bb5d-404e-98a6-6ef16e230078    eip-dnat            tcp        10.5.49.4:22    10.116.16.30:22
$ telnet 10.5.49.4 22 
Connecting to 10.5.49.4:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
SSH-2.0-OpenSSH_9.0

@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 code patch diff.
  • It is difficult to assess performance issues without seeing the actual code changes.
  • Ways to improve could include adding comments to the code for better readability, refactoring repetitive code, and optimizing algorithms if applicable.

@hongzhen-ma
Copy link
Collaborator

使用 libovsdb api 接口,替换原有的 ovnLegacyClient 接口,可以单独提个PR 修改下。
把 SNAT、DNAT、EIP、FIP 的接口,统一做整改。

@bobz965 bobz965 merged commit 887df21 into kubeovn:master Mar 30, 2023
52 checks passed
@ShaPoHun ShaPoHun deleted the ovn_dnat branch April 7, 2023 01:37
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.

None yet

3 participants