Skip to content

Commit

Permalink
rename ExternalGateway to ExternalEgressGateway
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed May 14, 2021
1 parent cdc3bb7 commit a2e4fec
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions dist/images/install-pre-1.16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ spec:
- name: NAT
type: boolean
JSONPath: .spec.natOutgoing
- name: ExternalGateway
- name: ExternalEgressGateway
type: string
JSONPath: .spec.externalGateway
JSONPath: .spec.externalEgressGateway
- name: PolicyRoutingPriority
type: integer
JSONPath: .spec.policyRoutingPriority
Expand Down Expand Up @@ -315,7 +315,7 @@ spec:
type: string
natOutgoing:
type: boolean
externalGateway:
externalEgressGateway:
type: string
policyRoutingPriority:
type: integer
Expand Down
6 changes: 3 additions & 3 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ spec:
- name: NAT
type: boolean
jsonPath: .spec.natOutgoing
- name: ExternalGateway
- name: ExternalEgressGateway
type: string
jsonPath: .spec.externalGateway
jsonPath: .spec.externalEgressGateway
- name: PolicyRoutingPriority
type: integer
jsonPath: .spec.policyRoutingPriority
Expand Down Expand Up @@ -508,7 +508,7 @@ spec:
type: string
natOutgoing:
type: boolean
externalGateway:
externalEgressGateway:
type: string
policyRoutingPriority:
type: integer
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/kubeovn/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type SubnetSpec struct {
GatewayNode string `json:"gatewayNode"`
NatOutgoing bool `json:"natOutgoing"`

ExternalGateway string `json:"externalGateway,omitempty"`
ExternalEgressGateway string `json:"externalEgressGateway,omitempty"`
PolicyRoutingPriority uint32 `json:"policyRoutingPriority,omitempty"`
PolicyRoutingTableID uint32 `json:"policyRoutingTableID,omitempty"`

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error {
return err
}

if subnet.Spec.ExternalGateway != "" && sub.Spec.ExternalGateway != "" &&
if subnet.Spec.ExternalEgressGateway != "" && sub.Spec.ExternalEgressGateway != "" &&
subnet.Spec.PolicyRoutingTableID == sub.Spec.PolicyRoutingTableID {
err = fmt.Errorf("subnet %s policy routing table ID %d is conflict with subnet %s policy routing table ID %d", subnet.Name, subnet.Spec.PolicyRoutingTableID, sub.Name, sub.Spec.PolicyRoutingTableID)
klog.Error(err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/daemon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,23 +413,23 @@ func (c *Controller) diffPolicyRouting(oldSubnet, newSubnet *kubeovnv1.Subnet) (
}

func (c *Controller) getPolicyRouting(subnet *kubeovnv1.Subnet) ([]netlink.Rule, []netlink.Route, error) {
if subnet == nil || subnet.Spec.ExternalGateway == "" || subnet.Spec.Vpc != util.DefaultVpc {
if subnet == nil || subnet.Spec.ExternalEgressGateway == "" || subnet.Spec.Vpc != util.DefaultVpc {
return nil, nil, nil
}
if subnet.Spec.GatewayType == kubeovnv1.GWCentralizedType && !util.GatewayContains(subnet.Spec.GatewayNode, c.config.NodeName) {
return nil, nil, nil
}

protocols := make([]string, 1, 2)
if protocol := util.CheckProtocol(subnet.Spec.ExternalGateway); protocol == kubeovnv1.ProtocolDual {
if protocol := util.CheckProtocol(subnet.Spec.ExternalEgressGateway); protocol == kubeovnv1.ProtocolDual {
protocols[0] = kubeovnv1.ProtocolIPv4
protocols = append(protocols, kubeovnv1.ProtocolIPv6)
} else {
protocols[0] = protocol
}

cidr := strings.Split(subnet.Spec.CIDRBlock, ",")
egw := strings.Split(subnet.Spec.ExternalGateway, ",")
egw := strings.Split(subnet.Spec.ExternalEgressGateway, ",")

// rules
var rules []netlink.Rule
Expand Down
24 changes: 12 additions & 12 deletions pkg/daemon/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ func (c *Controller) addEgressConfig(subnet, ip string) error {
c.addIPSetMembers(LocalPodSet, protocol, podIPs)
return nil
}
if podSubnet.Spec.ExternalGateway != "" {
return c.addPodPolicyRouting(protocol, podSubnet.Spec.ExternalGateway, podSubnet.Spec.PolicyRoutingPriority, podSubnet.Spec.PolicyRoutingTableID, podIPs)
if podSubnet.Spec.ExternalEgressGateway != "" {
return c.addPodPolicyRouting(protocol, podSubnet.Spec.ExternalEgressGateway, podSubnet.Spec.PolicyRoutingPriority, podSubnet.Spec.PolicyRoutingTableID, podIPs)
}

return nil
Expand Down Expand Up @@ -215,8 +215,8 @@ func (c *Controller) removeEgressConfig(subnet, ip string) error {
c.removeIPSetMembers(LocalPodSet, protocol, podIPs)
return nil
}
if podSubnet.Spec.ExternalGateway != "" {
return c.deletePodPolicyRouting(protocol, podSubnet.Spec.ExternalGateway, podSubnet.Spec.PolicyRoutingPriority, podSubnet.Spec.PolicyRoutingTableID, podIPs)
if podSubnet.Spec.ExternalEgressGateway != "" {
return c.deletePodPolicyRouting(protocol, podSubnet.Spec.ExternalEgressGateway, podSubnet.Spec.PolicyRoutingPriority, podSubnet.Spec.PolicyRoutingTableID, podIPs)
}

return nil
Expand Down Expand Up @@ -246,8 +246,8 @@ func (c *Controller) removeIPSetMembers(setID, protocol string, ips []string) {
}
}

func (c *Controller) addPodPolicyRouting(podProtocol, externalGateway string, priority, tableID uint32, ips []string) error {
egw := strings.Split(externalGateway, ",")
func (c *Controller) addPodPolicyRouting(podProtocol, externalEgressGateway string, priority, tableID uint32, ips []string) error {
egw := strings.Split(externalEgressGateway, ",")
prMetas := make([]policyRouteMeta, 0, 2)
if len(egw) == 1 {
family, _ := util.ProtocolToFamily(util.CheckProtocol(egw[0]))
Expand All @@ -271,8 +271,8 @@ func (c *Controller) addPodPolicyRouting(podProtocol, externalGateway string, pr
return nil
}

func (c *Controller) deletePodPolicyRouting(podProtocol, externalGateway string, priority, tableID uint32, ips []string) error {
egw := strings.Split(externalGateway, ",")
func (c *Controller) deletePodPolicyRouting(podProtocol, externalEgressGateway string, priority, tableID uint32, ips []string) error {
egw := strings.Split(externalEgressGateway, ",")
prMetas := make([]policyRouteMeta, 0, 2)
if len(egw) == 1 {
family, _ := util.ProtocolToFamily(util.CheckProtocol(egw[0]))
Expand Down Expand Up @@ -617,7 +617,7 @@ func (c *Controller) getLocalPodIPsNeedPR(protocol string) (map[policyRouteMeta]
continue
}

if subnet.Spec.ExternalGateway != "" &&
if subnet.Spec.ExternalEgressGateway != "" &&
subnet.Spec.Vpc == util.DefaultVpc &&
subnet.Spec.GatewayType == kubeovnv1.GWDistributedType &&
pod.Spec.NodeName == hostname {
Expand All @@ -626,7 +626,7 @@ func (c *Controller) getLocalPodIPsNeedPR(protocol string) (map[policyRouteMeta]
tableID: subnet.Spec.PolicyRoutingTableID,
}

egw := strings.Split(subnet.Spec.ExternalGateway, ",")
egw := strings.Split(subnet.Spec.ExternalEgressGateway, ",")
if util.CheckProtocol(egw[0]) == protocol {
meta.gateway = egw[0]
if util.CheckProtocol(pod.Status.PodIPs[0].IP) == protocol {
Expand Down Expand Up @@ -679,12 +679,12 @@ func (c *Controller) getSubnetsNeedPR(protocol string) (map[policyRouteMeta]stri
subnet.Spec.GatewayType == kubeovnv1.GWCentralizedType &&
util.GatewayContains(subnet.Spec.GatewayNode, c.config.NodeName) &&
(subnet.Spec.Protocol == kubeovnv1.ProtocolDual || subnet.Spec.Protocol == protocol) &&
subnet.Spec.ExternalGateway != "" {
subnet.Spec.ExternalEgressGateway != "" {
meta := policyRouteMeta{
priority: subnet.Spec.PolicyRoutingPriority,
tableID: subnet.Spec.PolicyRoutingTableID,
}
egw := strings.Split(subnet.Spec.ExternalGateway, ",")
egw := strings.Split(subnet.Spec.ExternalEgressGateway, ",")
if util.CheckProtocol(subnet.Spec.CIDRBlock) == kubeovnv1.ProtocolDual && protocol == kubeovnv1.ProtocolIPv6 {
if len(egw) == 2 {
meta.gateway = egw[1]
Expand Down
10 changes: 5 additions & 5 deletions pkg/util/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,22 @@ func ValidateSubnet(subnet kubeovnv1.Subnet) error {
}
}

if egw := subnet.Spec.ExternalGateway; egw != "" {
if egw := subnet.Spec.ExternalEgressGateway; egw != "" {
if subnet.Spec.NatOutgoing {
return fmt.Errorf("conflict configuration: natOutgoing and externalGateway")
return fmt.Errorf("conflict configuration: natOutgoing and externalEgressGateway")
}
ips := strings.Split(egw, ",")
if len(ips) > 2 {
return fmt.Errorf("invalid external gateway configuration")
return fmt.Errorf("invalid external egress gateway configuration")
}
for _, ip := range ips {
if net.ParseIP(ip) == nil {
return fmt.Errorf("external gateway %s is not a valid address", ip)
return fmt.Errorf("IP %s in externalEgressGateway is not a valid address", ip)
}
}
egwProtocol, cidrProtocol := CheckProtocol(egw), CheckProtocol(subnet.Spec.CIDRBlock)
if egwProtocol != cidrProtocol && cidrProtocol != kubeovnv1.ProtocolDual {
return fmt.Errorf("invalid external gateway configuration")
return fmt.Errorf("invalid external egress gateway configuration: address family is conflict with CIDR")
}
}

Expand Down
6 changes: 3 additions & 3 deletions yamls/crd-pre-1.16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ spec:
- name: NAT
type: boolean
JSONPath: .spec.natOutgoing
- name: ExternalGateway
- name: ExternalEgressGateway
type: string
JSONPath: .spec.externalGateway
JSONPath: .spec.externalEgressGateway
- name: PolicyRoutingPriority
type: integer
JSONPath: .spec.policyRoutingPriority
Expand Down Expand Up @@ -176,7 +176,7 @@ spec:
type: string
natOutgoing:
type: boolean
externalGateway:
externalEgressGateway:
type: string
policyRoutingPriority:
type: integer
Expand Down
6 changes: 3 additions & 3 deletions yamls/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ spec:
- name: NAT
type: boolean
jsonPath: .spec.natOutgoing
- name: ExternalGateway
- name: ExternalEgressGateway
type: string
jsonPath: .spec.externalGateway
jsonPath: .spec.externalEgressGateway
- name: PolicyRoutingPriority
type: integer
jsonPath: .spec.policyRoutingPriority
Expand Down Expand Up @@ -177,7 +177,7 @@ spec:
type: string
natOutgoing:
type: boolean
externalGateway:
externalEgressGateway:
type: string
policyRoutingPriority:
type: integer
Expand Down

0 comments on commit a2e4fec

Please sign in to comment.