Skip to content

Commit

Permalink
remove subnet's spec.underlayGateway field
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Aug 22, 2021
1 parent 8339e02 commit 70fbbec
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 69 deletions.
7 changes: 1 addition & 6 deletions dist/images/install-pre-1.16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,6 @@ spec:
type: boolean
vlan:
type: string
underlayGateway:
type: boolean
disableGatewayCheck:
type: boolean
disableInterConnection:
Expand Down Expand Up @@ -2342,11 +2340,8 @@ trace(){
exit 1
fi
vlan=$(kubectl get subnet "$ls" -o jsonpath={.spec.vlan})
underlayGateway=$(kubectl get subnet "$ls" -o jsonpath={.spec.underlayGateway})
gwMac=""
if [ ! -z "$vlan" -a "$underlayGateway" = "true" ]; then
if [ ! -z "$(kubectl get subnet $ls -o jsonpath={.spec.vlan})" ]; then
ovnCni=$(kubectl get pod -n $KUBE_OVN_NS -o wide | grep -w kube-ovn-cni | grep " $nodeName " | awk '{print $1}')
if [ -z "$ovnCni" ]; then
echo "No kube-ovn-cni Pod running on node $nodeName"
Expand Down
7 changes: 1 addition & 6 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,6 @@ spec:
type: boolean
vlan:
type: string
underlayGateway:
type: boolean
disableGatewayCheck:
type: boolean
disableInterConnection:
Expand Down Expand Up @@ -2386,11 +2384,8 @@ trace(){
exit 1
fi
vlan=$(kubectl get subnet "$ls" -o jsonpath={.spec.vlan})
underlayGateway=$(kubectl get subnet "$ls" -o jsonpath={.spec.underlayGateway})
gwMac=""
if [ ! -z "$vlan" -a "$underlayGateway" = "true" ]; then
if [ ! -z "$(kubectl get subnet $ls -o jsonpath={.spec.vlan})" ]; then
ovnCni=$(kubectl get pod -n $KUBE_OVN_NS -o wide | grep -w kube-ovn-cni | grep " $nodeName " | awk '{print $1}')
if [ -z "$ovnCni" ]; then
echo "No kube-ovn-cni Pod running on node $nodeName"
Expand Down
5 changes: 1 addition & 4 deletions dist/images/kubectl-ko
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ trace(){
exit 1
fi

vlan=$(kubectl get subnet "$ls" -o jsonpath={.spec.vlan})
underlayGateway=$(kubectl get subnet "$ls" -o jsonpath={.spec.underlayGateway})

gwMac=""
if [ ! -z "$vlan" -a "$underlayGateway" = "true" ]; then
if [ ! -z "$(kubectl get subnet $ls -o jsonpath={.spec.vlan})" ]; then
ovnCni=$(kubectl get pod -n $KUBE_OVN_NS -o wide | grep -w kube-ovn-cni | grep " $nodeName " | awk '{print $1}')
if [ -z "$ovnCni" ]; then
echo "No kube-ovn-cni Pod running on node $nodeName"
Expand Down
6 changes: 0 additions & 6 deletions docs/OpenstackOnKubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,7 @@ spec:
namespaces:
- net2
cidrBlock: 12.0.1.0/24
default: false
gatewayType: distributed
natOutgoing: false
private: false
protocol: IPv4
provider: ovn
underlayGateway: false
```
4. Add pod and test.
Expand Down
2 changes: 1 addition & 1 deletion docs/multi-nic.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ spec:
- 172.17.0.1..172.17.0.10
```

Other options like gatewayType, gatewayNode, private, allowSubnets, vlan, underlayGateway, natOutgoing are not available for attachment network.
Other options like gatewayType, gatewayNode, private, allowSubnets, vlan, natOutgoing are not available for attachment network.

### Create Pod with multi network

Expand Down
1 change: 0 additions & 1 deletion docs/subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Since kube-ovn v1.8.0, kube-ovn support using designative egress ip on node, the
## Advance Options

- `vlan`: if enable vlan network, use this field to specific which vlan the subnet should bind to.
- `underlayGateway`: if enable vlan network, use this field to use underlay network gateway directly, instead of ovs virtual gateway
- `externalEgressGateway`: External egress gateway address. When set, egress traffic is redirected to the external gateway through gateway node(s) by policy-based routing. Conflict with `natOutgoing`.
- `policyRoutingPriority`/`policyRoutingTableID`: Priority & table ID used in policy-based routing. Required when `externalEgressGateway` is set. NOTICE: `policyRoutingTableID` MUST be unique.
- `disableGatewayCheck`: By default Kube-OVN checks Pod's network by sending ICMP request to the subnet's gateway. Set it to `true` if the subnet is in underlay mode and the physical gateway does not respond to ICMP requests.
Expand Down
4 changes: 0 additions & 4 deletions docs/vlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ metadata:
name: product
spec:
cidrBlock: 10.100.0.0/16
default: false
gateway: 10.100.0.1
vlan: product
underlayGateway: true
```
### Dynamical Management
Expand Down Expand Up @@ -150,10 +148,8 @@ metadata:
name: subnet1
spec:
cidrBlock: 10.100.0.0/16
default: false
gateway: 10.100.0.1
vlan: vlan1
underlayGateway: true
```

### Install Hybrid mode
Expand Down
15 changes: 2 additions & 13 deletions docs/vpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ spec:
- ns1
cidrBlock: 10.0.1.0/24
default: true
gatewayType: distributed
natOutgoing: false
private: false
protocol: IPv4
provider: ovn
underlayGateway: false
---
kind: Subnet
apiVersion: kubeovn.io/v1
Expand All @@ -50,13 +45,7 @@ metadata:
spec:
vpc: test-vpc-2
cidrBlock: 10.0.1.0/24
default: false
gatewayType: distributed
natOutgoing: false
private: false
protocol: IPv4
provider: ovn
underlayGateway: false
```

In the examples above, two subnet in different VPCs can use same IP space
Expand All @@ -70,15 +59,15 @@ apiVersion: v1
kind: Pod
metadata:
annotations:
ovn.kubernetes.io/logical_switch: ne1
ovn.kubernetes.io/logical_switch: net1
namespace: default
name: vpc1-pod
---
apiVersion: v1
kind: Pod
metadata:
annotations:
ovn.kubernetes.io/logical_switch: ne2
ovn.kubernetes.io/logical_switch: net2
namespace: default
name: vpc2-pod
```
Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/kubeovn/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ type SubnetSpec struct {
Private bool `json:"private"`
AllowSubnets []string `json:"allowSubnets,omitempty"`

Vlan string `json:"vlan,omitempty"`
UnderlayGateway bool `json:"underlayGateway"`
Vlan string `json:"vlan,omitempty"`

DisableGatewayCheck bool `json:"disableGatewayCheck"`
DisableInterConnection bool `json:"disableInterConnection"`
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func (c *Controller) initDefaultLogicalSwitch() error {
}
if c.config.NetworkType == util.NetworkTypeVlan {
defaultSubnet.Spec.Vlan = c.config.DefaultVlanName
defaultSubnet.Spec.UnderlayGateway = true
}

_, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Create(context.Background(), &defaultSubnet, metav1.CreateOptions{})
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func (c *Controller) checkGatewayReady() error {
}

for _, subnet := range subnetList {
if subnet.Spec.UnderlayGateway || subnet.Spec.GatewayType != kubeovnv1.GWCentralizedType || subnet.Spec.GatewayNode == "" {
if subnet.Spec.Vlan != "" || subnet.Spec.GatewayType != kubeovnv1.GWCentralizedType || subnet.Spec.GatewayNode == "" {
continue
}

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

if podIP != "" && subnet.Spec.Vpc == util.DefaultVpc && !subnet.Spec.UnderlayGateway {
if podIP != "" && subnet.Spec.Vlan == "" && subnet.Spec.Vpc == util.DefaultVpc {
if pod.Annotations[util.EipAnnotation] != "" || pod.Annotations[util.SnatAnnotation] != "" {
cm, err := c.configMapsLister.ConfigMaps("kube-system").Get(util.ExternalGatewayConfig)
if err != nil {
Expand Down
11 changes: 5 additions & 6 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func (c *Controller) enqueueUpdateSubnet(old, new interface{}) {
!reflect.DeepEqual(oldSubnet.Spec.Namespaces, newSubnet.Spec.Namespaces) ||
oldSubnet.Spec.GatewayType != newSubnet.Spec.GatewayType ||
oldSubnet.Spec.GatewayNode != newSubnet.Spec.GatewayNode ||
oldSubnet.Spec.UnderlayGateway != newSubnet.Spec.UnderlayGateway ||
oldSubnet.Spec.Gateway != newSubnet.Spec.Gateway ||
!reflect.DeepEqual(oldSubnet.Spec.ExcludeIps, newSubnet.Spec.ExcludeIps) ||
oldSubnet.Spec.Vlan != newSubnet.Spec.Vlan {
Expand Down Expand Up @@ -551,7 +550,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error {
klog.Errorf("failed to list nodes %v", err)
return err
}
if subnet.Spec.Vpc != util.DefaultVpc && subnet.Spec.Vlan != "" && !subnet.Spec.UnderlayGateway {
if subnet.Spec.Vlan != "" && subnet.Spec.Vpc != util.DefaultVpc {
for _, node := range nodes {
for _, addr := range node.Status.Addresses {
if addr.Type == v1.NodeInternalIP && util.CIDRContainIP(subnet.Spec.CIDRBlock, addr.Address) {
Expand All @@ -574,17 +573,17 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error {
if !exist {
subnet.Status.EnsureStandardConditions()
// If multiple namespace use same ls name, only first one will success
if err := c.ovnClient.CreateLogicalSwitch(subnet.Name, vpc.Status.Router, subnet.Spec.Protocol, subnet.Spec.CIDRBlock, subnet.Spec.Gateway, subnet.Spec.ExcludeIps, subnet.Spec.UnderlayGateway, vpc.Status.Default); err != nil {
if err := c.ovnClient.CreateLogicalSwitch(subnet.Name, vpc.Status.Router, subnet.Spec.Protocol, subnet.Spec.CIDRBlock, subnet.Spec.Gateway, subnet.Spec.ExcludeIps, subnet.Spec.Vlan != "", vpc.Status.Default); err != nil {
c.patchSubnetStatus(subnet, "CreateLogicalSwitchFailed", err.Error())
return err
}
} else {
// logical switch exists, only update other_config
if err := c.ovnClient.SetLogicalSwitchConfig(subnet.Name, subnet.Spec.UnderlayGateway, vpc.Status.Router, subnet.Spec.Protocol, subnet.Spec.CIDRBlock, subnet.Spec.Gateway, subnet.Spec.ExcludeIps); err != nil {
if err := c.ovnClient.SetLogicalSwitchConfig(subnet.Name, subnet.Spec.Vlan != "", vpc.Status.Router, subnet.Spec.Protocol, subnet.Spec.CIDRBlock, subnet.Spec.Gateway, subnet.Spec.ExcludeIps); err != nil {
c.patchSubnetStatus(subnet, "SetLogicalSwitchConfigFailed", err.Error())
return err
}
if subnet.Spec.UnderlayGateway {
if subnet.Spec.Vlan != "" {
if err := c.ovnClient.RemoveRouterPort(subnet.Name, vpc.Status.Router); err != nil {
klog.Errorf("failed to remove router port from %s, %v", subnet.Name, err)
return err
Expand Down Expand Up @@ -869,7 +868,7 @@ func (c *Controller) reconcileGateway(subnet *kubeovnv1.Subnet) error {
return err
}

if subnet.Spec.UnderlayGateway {
if subnet.Spec.Vlan != "" {
for _, pod := range pods {
if pod.Annotations[util.LogicalSwitchAnnotation] == subnet.Name && pod.Annotations[util.IpAddressAnnotation] != "" {
if err := c.deleteStaticRoute(pod.Annotations[util.IpAddressAnnotation], c.config.ClusterRouter, subnet); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/daemon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ func (c *Controller) reconcileRouters(event subnetEvent) error {

cidrs := make([]string, 0, len(subnets)*2)
for _, subnet := range subnets {
if subnet.Spec.Vpc != util.DefaultVpc || !subnet.Status.IsReady() || subnet.Spec.UnderlayGateway {
if subnet.Spec.Vlan != "" || subnet.Spec.Vpc != util.DefaultVpc || !subnet.Status.IsReady() {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/daemon/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ func (c *Controller) getEgressNatIpByNode(nodeName string) (map[string]string, e
}

for _, subnet := range subnetList {
if subnet.Spec.UnderlayGateway || subnet.Spec.GatewayType != kubeovnv1.GWCentralizedType || subnet.Spec.GatewayNode == "" || !util.GatewayContains(subnet.Spec.GatewayNode, nodeName) {
if subnet.Spec.Vlan != "" || subnet.Spec.GatewayType != kubeovnv1.GWCentralizedType || subnet.Spec.GatewayNode == "" || !util.GatewayContains(subnet.Spec.GatewayNode, nodeName) {
continue
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (c Client) ListPodLogicalSwitchPorts(pod, namespace string) ([]string, erro
return result, nil
}

func (c Client) SetLogicalSwitchConfig(ls string, isUnderlayGW bool, lr, protocol, subnet, gateway string, excludeIps []string) error {
func (c Client) SetLogicalSwitchConfig(ls string, underlay bool, lr, protocol, subnet, gateway string, excludeIps []string) error {
var err error
cidrBlocks := strings.Split(subnet, ",")
mask := strings.Split(cidrBlocks[0], "/")[1]
Expand Down Expand Up @@ -239,7 +239,7 @@ func (c Client) SetLogicalSwitchConfig(ls string, isUnderlayGW bool, lr, protoco
"set", "logical_switch", ls, fmt.Sprintf("other_config:ipv6_prefix=%s", strings.Split(cidrBlocks[1], "/")[0]), "--",
"set", "logical_switch", ls, fmt.Sprintf("other_config:exclude_ips=%s", strings.Join(excludeIps, " "))}
}
if !isUnderlayGW {
if !underlay {
cmd = append(cmd, []string{"--",
"set", "logical_router_port", fmt.Sprintf("%s-%s", lr, ls), fmt.Sprintf("networks=%s", networks)}...)
}
Expand All @@ -254,7 +254,7 @@ func (c Client) SetLogicalSwitchConfig(ls string, isUnderlayGW bool, lr, protoco
}

// CreateLogicalSwitch create logical switch in ovn, connect it to router and apply tcp/udp lb rules
func (c Client) CreateLogicalSwitch(ls, lr, protocol, subnet, gateway string, excludeIps []string, underlayGateway, defaultVpc bool) error {
func (c Client) CreateLogicalSwitch(ls, lr, protocol, subnet, gateway string, excludeIps []string, underlay, defaultVpc bool) error {
var err error
switch protocol {
case kubeovnv1.ProtocolIPv4:
Expand Down Expand Up @@ -287,7 +287,7 @@ func (c Client) CreateLogicalSwitch(ls, lr, protocol, subnet, gateway string, ex

ip := util.GetIpAddrWithMask(gateway, subnet)
mac := util.GenerateMac()
if !underlayGateway {
if !underlay {
if err := c.createRouterPort(ls, lr, ip, mac); err != nil {
klog.Errorf("failed to connect switch %s to router, %v", ls, err)
return err
Expand Down
11 changes: 5 additions & 6 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,11 @@ var _ = SynchronizedBeforeSuite(func() []byte {
Labels: map[string]string{"e2e": "true"},
},
Spec: kubeovn.SubnetSpec{
CIDRBlock: underlayCIDR,
Gateway: underlayGateway,
ExcludeIps: underlayNodeIPs,
Vlan: vlan.Name,
UnderlayGateway: true,
Namespaces: []string{underlay.Namespace},
CIDRBlock: underlayCIDR,
Gateway: underlayGateway,
ExcludeIps: underlayNodeIPs,
Vlan: vlan.Name,
Namespaces: []string{underlay.Namespace},
},
}
if _, err = f.OvnClientSet.KubeovnV1().Subnets().Create(context.Background(), &subnet, metav1.CreateOptions{}); err != nil {
Expand Down
1 change: 0 additions & 1 deletion test/e2e/subnet/normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ var _ = Describe("[Subnet]", func() {
Spec: kubeovn.SubnetSpec{
CIDRBlock: "11.17.0.0/16",
Namespaces: []string{namespace.Name},
UnderlayGateway: true,
DisableGatewayCheck: true,
},
}
Expand Down
2 changes: 0 additions & 2 deletions yamls/crd-pre-1.16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ spec:
type: boolean
vlan:
type: string
underlayGateway:
type: boolean
disableGatewayCheck:
type: boolean
disableInterConnection:
Expand Down
2 changes: 0 additions & 2 deletions yamls/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ spec:
type: boolean
vlan:
type: string
underlayGateway:
type: boolean
disableGatewayCheck:
type: boolean
disableInterConnection:
Expand Down

0 comments on commit 70fbbec

Please sign in to comment.