Skip to content

Commit

Permalink
fix: nat rules
Browse files Browse the repository at this point in the history
  • Loading branch information
fanriming committed Nov 19, 2020
1 parent a128d7f commit 7301e99
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/daemon/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package daemon

import (
"fmt"
"net"
"os"
"strings"

kubeovnv1 "github.com/alauda/kube-ovn/pkg/apis/kubeovn/v1"
"github.com/alauda/kube-ovn/pkg/ovs"
"github.com/alauda/kube-ovn/pkg/util"
Expand All @@ -11,9 +15,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/klog"
"net"
"os"
"strings"
)

const (
Expand Down Expand Up @@ -231,6 +232,7 @@ func (c *Controller) getLocalPodIPsNeedNAT(protocol string) ([]string, error) {
nsGWType := subnet.Spec.GatewayType
nsGWNat := subnet.Spec.NatOutgoing
if nsGWNat &&
subnet.Spec.Vpc == util.DefaultVpc &&
nsGWType == kubeovnv1.GWDistributedType &&
pod.Spec.NodeName == hostname &&
util.CheckProtocol(pod.Status.PodIP) == protocol {
Expand All @@ -250,7 +252,8 @@ func (c *Controller) getSubnetsNeedNAT(protocol string) ([]string, error) {
return nil, err
}
for _, subnet := range subnets {
if subnet.Spec.GatewayType == kubeovnv1.GWCentralizedType &&
if subnet.Spec.Vpc == util.DefaultVpc &&
subnet.Spec.GatewayType == kubeovnv1.GWCentralizedType &&
subnet.Status.ActivateGateway == c.config.NodeName &&
subnet.Spec.Protocol == protocol &&
subnet.Spec.NatOutgoing {
Expand All @@ -271,7 +274,7 @@ func (c *Controller) getSubnetsCIDR(protocol string) ([]string, error) {
return nil, err
}
for _, subnet := range subnets {
if subnet.Spec.Protocol == protocol {
if subnet.Spec.Protocol == protocol && subnet.Spec.Vpc == util.DefaultVpc {
ret = append(ret, subnet.Spec.CIDRBlock)
}
}
Expand Down

0 comments on commit 7301e99

Please sign in to comment.