Skip to content

Commit

Permalink
Nat reuse router port external ip (#3313)
Browse files Browse the repository at this point in the history
* nat could use lrp type ovn eip

* nat support specify vpc ip

* e2e

* fix G307

* update ovn nat webhook

* test e2e

* add independent vip e2e

* update ovn vpc nat e2e about nats use ip or ip cidr

* fix e2e

* fix golint

* fix comment

* build(deps): bump the k8s-io group with 1 update (#3314)

Bumps the k8s-io group with 1 update: [k8s.io/sample-controller](https://github.com/kubernetes/sample-controller).

- [Commits](kubernetes/sample-controller@v0.28.2...v0.28.3)

---
updated-dependencies:
- dependency-name: k8s.io/sample-controller
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>

* build(deps): bump sigs.k8s.io/controller-runtime from 0.16.2 to 0.16.3 (#3315)

Bumps [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) from 0.16.2 to 0.16.3.
- [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md)
- [Commits](kubernetes-sigs/controller-runtime@v0.16.2...v0.16.3)

---
updated-dependencies:
- dependency-name: sigs.k8s.io/controller-runtime
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>

* fix golang lint error (#3323)

Signed-off-by: 张祖建 <zhangzujian.7@gmail.com>

* fix gofumpt

* ovn dnat should print vpc

---------

Signed-off-by: bobz965 <zhangbingbing2_yewu@cmss.chinamobile.com>
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: 张祖建 <zhangzujian.7@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: 张祖建 <zhangzujian.7@gmail.com>
  • Loading branch information
3 people committed Oct 24, 2023
1 parent a0228ef commit b4abb34
Show file tree
Hide file tree
Showing 25 changed files with 1,009 additions and 450 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-x86-image.yaml
Expand Up @@ -2033,7 +2033,11 @@ jobs:
- name: Install Kube-OVN
run: make kind-install

- name: Run E2E
- name: Run Vip E2E
working-directory: ${{ env.E2E_DIR }}
run: make vip-conformance-e2e

- name: Run Ovn VPC NAT GW E2E
working-directory: ${{ env.E2E_DIR }}
run: make ovn-vpc-nat-gw-conformance-e2e

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -829,7 +829,7 @@ lint:
echo "Code differs from gofmt's style" 1>&2 && exit 1; \
fi
@GOOS=linux go vet ./...
@GOOS=linux gosec -exclude=G204,G306,G404,G601,G301,G402 -exclude-dir=test -exclude-dir=pkg/client ./...
@GOOS=linux gosec -exclude=G204,G301,G306,G402,G404,G601 -exclude-dir=test -exclude-dir=pkg/client ./...

.PHONY: gofumpt
gofumpt: gofumpt
Expand Down
10 changes: 10 additions & 0 deletions Makefile.e2e
Expand Up @@ -61,6 +61,7 @@ e2e-build:
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/kube-ovn
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/ovn-ic
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/lb-svc
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/vip
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/iptables-vpc-nat-gw
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/ovn-vpc-nat-gw
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/ha
Expand Down Expand Up @@ -138,6 +139,15 @@ kube-ovn-lb-svc-conformance-e2e:
ginkgo $(GINKGO_PARALLEL_OPT) --randomize-all -v \
--focus=CNI:Kube-OVN ./test/e2e/lb-svc/lb-svc.test

.PHONY: vip-conformance-e2e
vip-conformance-e2e:
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/vip
E2E_BRANCH=$(E2E_BRANCH) \
E2E_IP_FAMILY=$(E2E_IP_FAMILY) \
E2E_NETWORK_MODE=$(E2E_NETWORK_MODE) \
ginkgo $(GINKGO_PARALLEL_OPT) --randomize-all -v \
--focus=CNI:Kube-OVN ./test/e2e/vip/vip.test -- $(TEST_BIN_ARGS)

.PHONY: iptables-vpc-nat-gw-conformance-e2e
iptables-vpc-nat-gw-conformance-e2e:
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/iptables-vpc-nat-gw
Expand Down
25 changes: 18 additions & 7 deletions charts/templates/kube-ovn-crd.yaml
Expand Up @@ -980,8 +980,6 @@ spec:
type: string
v4Ip:
type: string
macAddress:
type: string
vpc:
type: string
conditions:
Expand Down Expand Up @@ -1010,6 +1008,10 @@ spec:
type: string
ipName:
type: string
vpc:
type: string
v4Ip:
type: string
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -1038,8 +1040,8 @@ spec:
- jsonPath: .status.v4Eip
name: V4Eip
type: string
- jsonPath: .status.v4ipCidr
name: V4Ip
- jsonPath: .status.v4IpCidr
name: V4IpCidr
type: string
- jsonPath: .status.ready
name: Ready
Expand All @@ -1055,7 +1057,7 @@ spec:
type: boolean
v4Eip:
type: string
v4ipCidr:
v4IpCidr:
type: string
vpc:
type: string
Expand Down Expand Up @@ -1085,6 +1087,10 @@ spec:
type: string
ipName:
type: string
vpc:
type: string
v4IpCidr:
type: string
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand All @@ -1107,6 +1113,9 @@ spec:
subresources:
status: {}
additionalPrinterColumns:
- jsonPath: .status.vpc
name: Vpc
type: string
- jsonPath: .spec.ovnEip
name: Eip
type: string
Expand Down Expand Up @@ -1144,8 +1153,6 @@ spec:
type: string
v4Ip:
type: string
macAddress:
type: string
vpc:
type: string
externalPort:
Expand Down Expand Up @@ -1188,6 +1195,10 @@ spec:
type: string
protocol:
type: string
vpc:
type: string
v4Ip:
type: string
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
4 changes: 2 additions & 2 deletions cmd/cmdmain.go
Expand Up @@ -47,11 +47,11 @@ func dumpProfile() {
klog.Errorf("failed to create cpu profile file: %v", err)
return
}
defer f.Close()
if err = pprof.StartCPUProfile(f); err != nil {
klog.Errorf("failed to start cpu profile: %v", err)
return
}
defer f.Close()
time.Sleep(30 * time.Second)
pprof.StopCPUProfile()
}
Expand All @@ -65,10 +65,10 @@ func dumpProfile() {
klog.Errorf("failed to create memory profile file: %v", err)
return
}
defer f.Close()
if err = pprof.WriteHeapProfile(f); err != nil {
klog.Errorf("failed to write memory profile file: %v", err)
}
defer f.Close()
}
}()
}
Expand Down
25 changes: 18 additions & 7 deletions dist/images/install.sh
Expand Up @@ -1519,8 +1519,6 @@ spec:
type: string
v4Ip:
type: string
macAddress:
type: string
vpc:
type: string
conditions:
Expand Down Expand Up @@ -1549,6 +1547,10 @@ spec:
type: string
ipName:
type: string
vpc:
type: string
v4Ip:
type: string
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -1577,8 +1579,8 @@ spec:
- jsonPath: .status.v4Eip
name: V4Eip
type: string
- jsonPath: .status.v4ipCidr
name: V4Ip
- jsonPath: .status.v4IpCidr
name: V4IpCidr
type: string
- jsonPath: .status.ready
name: Ready
Expand All @@ -1594,7 +1596,7 @@ spec:
type: boolean
v4Eip:
type: string
v4ipCidr:
v4IpCidr:
type: string
vpc:
type: string
Expand Down Expand Up @@ -1624,6 +1626,10 @@ spec:
type: string
ipName:
type: string
vpc:
type: string
v4IpCidr:
type: string
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand All @@ -1646,6 +1652,9 @@ spec:
subresources:
status: {}
additionalPrinterColumns:
- jsonPath: .status.vpc
name: Vpc
type: string
- jsonPath: .spec.ovnEip
name: Eip
type: string
Expand Down Expand Up @@ -1683,8 +1692,6 @@ spec:
type: string
v4Ip:
type: string
macAddress:
type: string
vpc:
type: string
externalPort:
Expand Down Expand Up @@ -1727,6 +1734,10 @@ spec:
type: string
protocol:
type: string
vpc:
type: string
v4Ip:
type: string
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
28 changes: 16 additions & 12 deletions pkg/apis/kubeovn/v1/types.go
Expand Up @@ -1002,6 +1002,8 @@ type OvnFipSpec struct {
OvnEip string `json:"ovnEip"`
IPType string `json:"ipType"` // vip, ip
IPName string `json:"ipName"` // vip, ip crd name
Vpc string `json:"vpc"`
V4Ip string `json:"v4Ip"`
}

// OvnFipCondition describes the state of an object at a certain point.
Expand All @@ -1011,11 +1013,10 @@ type OvnFipCondition Condition
type OvnFipStatus struct {
// +optional
// +patchStrategy=merge
Ready bool `json:"ready" patchStrategy:"merge"`
V4Eip string `json:"v4Eip" patchStrategy:"merge"`
V4Ip string `json:"v4Ip" patchStrategy:"merge"`
MacAddress string `json:"macAddress" patchStrategy:"merge"`
Vpc string `json:"vpc" patchStrategy:"merge"`
Vpc string `json:"vpc" patchStrategy:"merge"`
V4Eip string `json:"v4Eip" patchStrategy:"merge"`
V4Ip string `json:"v4Ip" patchStrategy:"merge"`
Ready bool `json:"ready" patchStrategy:"merge"`

// Conditions represents the latest state of the object
// +optional
Expand Down Expand Up @@ -1050,6 +1051,8 @@ type OvnSnatRuleSpec struct {
OvnEip string `json:"ovnEip"`
VpcSubnet string `json:"vpcSubnet"`
IPName string `json:"ipName"`
Vpc string `json:"vpc"`
V4IpCidr string `json:"v4IpCidr"` // subnet cidr or pod ip address
}

// OvnSnatRuleCondition describes the state of an object at a certain point.
Expand All @@ -1059,10 +1062,10 @@ type OvnSnatRuleCondition Condition
type OvnSnatRuleStatus struct {
// +optional
// +patchStrategy=merge
Ready bool `json:"ready" patchStrategy:"merge"`
V4Eip string `json:"v4Eip" patchStrategy:"merge"`
V4IpCidr string `json:"v4ipCidr" patchStrategy:"merge"`
Vpc string `json:"vpc" patchStrategy:"merge"`
V4Eip string `json:"v4Eip" patchStrategy:"merge"`
V4IpCidr string `json:"v4IpCidr" patchStrategy:"merge"`
Ready bool `json:"ready" patchStrategy:"merge"`

// Conditions represents the latest state of the object
// +optional
Expand Down Expand Up @@ -1100,6 +1103,8 @@ type OvnDnatRuleSpec struct {
InternalPort string `json:"internalPort"`
ExternalPort string `json:"externalPort"`
Protocol string `json:"protocol,omitempty"`
Vpc string `json:"vpc"`
V4Ip string `json:"v4Ip"`
}

// OvnDnatRuleCondition describes the state of an object at a certain point.
Expand All @@ -1110,15 +1115,14 @@ type OvnDnatRuleCondition Condition
type OvnDnatRuleStatus struct {
// +optional
// +patchStrategy=merge
Ready bool `json:"ready" patchStrategy:"merge"`
Vpc string `json:"vpc" patchStrategy:"merge"`
V4Eip string `json:"v4Eip" patchStrategy:"merge"`
ExternalPort string `json:"externalPort"`
V4Ip string `json:"v4Ip" patchStrategy:"merge"`
MacAddress string `json:"macAddress" patchStrategy:"merge"`
Vpc string `json:"vpc" patchStrategy:"merge"`
InternalPort string `json:"internalPort"`
ExternalPort string `json:"externalPort"`
Protocol string `json:"protocol,omitempty"`
IPName string `json:"ipName"`
Ready bool `json:"ready" patchStrategy:"merge"`

// Conditions represents the latest state of the object
// +optional
Expand Down

0 comments on commit b4abb34

Please sign in to comment.