Skip to content

Commit

Permalink
add check switch for default subnet's gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Oct 28, 2021
1 parent bdf5b0e commit c106afa
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions dist/images/install-pre-1.16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ENABLE_SSL=${ENABLE_SSL:-false}
ENABLE_VLAN=${ENABLE_VLAN:-false}
ENABLE_MIRROR=${ENABLE_MIRROR:-false}
VLAN_NIC=${VLAN_NIC:-}
CHECK_GATEWAY=${CHECK_GATEWAY:-true}
HW_OFFLOAD=${HW_OFFLOAD:-false}
ENABLE_LB=${ENABLE_LB:-true}
ENABLE_NP=${ENABLE_NP:-true}
Expand Down Expand Up @@ -1769,6 +1770,7 @@ spec:
args:
- --default-cidr=$POD_CIDR
- --default-gateway=$POD_GATEWAY
- --default-gateway-check=$CHECK_GATEWAY
- --default-exclude-ips=$EXCLUDE_IPS
- --node-switch-cidr=$JOIN_CIDR
- --network-type=$NETWORK_TYPE
Expand Down
2 changes: 2 additions & 0 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ IPV6=${IPV6:-false}
DUAL_STACK=${DUAL_STACK:-false}
ENABLE_SSL=${ENABLE_SSL:-false}
ENABLE_VLAN=${ENABLE_VLAN:-false}
CHECK_GATEWAY=${CHECK_GATEWAY:-true}
ENABLE_MIRROR=${ENABLE_MIRROR:-false}
VLAN_NIC=${VLAN_NIC:-}
HW_OFFLOAD=${HW_OFFLOAD:-false}
Expand Down Expand Up @@ -1821,6 +1822,7 @@ spec:
args:
- --default-cidr=$POD_CIDR
- --default-gateway=$POD_GATEWAY
- --default-gateway-check=$CHECK_GATEWAY
- --default-exclude-ips=$EXCLUDE_IPS
- --node-switch-cidr=$JOIN_CIDR
- --network-type=$NETWORK_TYPE
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Configuration struct {
DefaultCIDR string
DefaultGateway string
DefaultExcludeIps string
DefaultGatewayCheck bool

ClusterRouter string
NodeSwitch string
Expand Down Expand Up @@ -73,6 +74,7 @@ func ParseFlags() (*Configuration, error) {
argDefaultLogicalSwitch = pflag.String("default-ls", "ovn-default", "The default logical switch name, default: ovn-default")
argDefaultCIDR = pflag.String("default-cidr", "10.16.0.0/16", "Default CIDR for namespace with no logical switch annotation, default: 10.16.0.0/16")
argDefaultGateway = pflag.String("default-gateway", "", "Default gateway for default-cidr, default the first ip in default-cidr")
argDefaultGatewayCheck = pflag.Bool("default-gateway-check", true, "Check switch for the default subnet's gateway, default: true")
argDefaultExcludeIps = pflag.String("default-exclude-ips", "", "Exclude ips in default switch, default equals to gateway address")

argClusterRouter = pflag.String("cluster-router", "ovn-cluster", "The router name for cluster router, default: ovn-cluster")
Expand Down Expand Up @@ -125,6 +127,7 @@ func ParseFlags() (*Configuration, error) {
DefaultLogicalSwitch: *argDefaultLogicalSwitch,
DefaultCIDR: *argDefaultCIDR,
DefaultGateway: *argDefaultGateway,
DefaultGatewayCheck: *argDefaultGatewayCheck,
DefaultExcludeIps: *argDefaultExcludeIps,
ClusterRouter: *argClusterRouter,
NodeSwitch: *argNodeSwitch,
Expand Down
19 changes: 10 additions & 9 deletions pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,16 @@ func (c *Controller) initDefaultLogicalSwitch() error {
defaultSubnet := kubeovnv1.Subnet{
ObjectMeta: metav1.ObjectMeta{Name: c.config.DefaultLogicalSwitch},
Spec: kubeovnv1.SubnetSpec{
Vpc: util.DefaultVpc,
Default: true,
Provider: util.OvnProvider,
CIDRBlock: c.config.DefaultCIDR,
Gateway: c.config.DefaultGateway,
ExcludeIps: strings.Split(c.config.DefaultExcludeIps, ","),
NatOutgoing: true,
GatewayType: kubeovnv1.GWDistributedType,
Protocol: util.CheckProtocol(c.config.DefaultCIDR),
Vpc: util.DefaultVpc,
Default: true,
Provider: util.OvnProvider,
CIDRBlock: c.config.DefaultCIDR,
Gateway: c.config.DefaultGateway,
DisableGatewayCheck: !c.config.DefaultGatewayCheck,
ExcludeIps: strings.Split(c.config.DefaultExcludeIps, ","),
NatOutgoing: true,
GatewayType: kubeovnv1.GWDistributedType,
Protocol: util.CheckProtocol(c.config.DefaultCIDR),
},
}
if c.config.NetworkType == util.NetworkTypeVlan {
Expand Down
2 changes: 2 additions & 0 deletions yamls/kube-ovn-ipv6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
args:
- --default-cidr=2001:db8:0000:0000::/64
- --default-gateway=2001:db8:0000:0000::1
- --default-gateway-check=true
- --default-exclude-ips=
- --node-switch-cidr=2001:db8:0000:0001::/64
- --node-switch-gateway=2001:db8:0000:0001::1
- --network-type=geneve
Expand Down
1 change: 1 addition & 0 deletions yamls/kube-ovn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ spec:
args:
- --default-cidr=10.16.0.0/16
- --default-gateway=10.16.0.1
- --default-gateway-check=true
- --default-exclude-ips=
- --node-switch-cidr=100.64.0.0/16
- --network-type=geneve
Expand Down

0 comments on commit c106afa

Please sign in to comment.