Skip to content

Commit

Permalink
read cidr from ns annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
halfcrazy committed Apr 10, 2019
1 parent ad64163 commit cb91d98
Show file tree
Hide file tree
Showing 21 changed files with 6 additions and 2,676 deletions.
9 changes: 0 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
name = "github.com/coreos/go-iptables"
version = "v0.4.0"

[[constraint]]
name = "github.com/thoas/go-funk"
version = "v0.4"

[[constraint]]
name = "github.com/juju/errors"
branch = "master"
26 changes: 6 additions & 20 deletions pkg/daemon/gateway.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package daemon

import (
"fmt"
"os"
"strings"
"time"

"bitbucket.org/mathildetech/kube-ovn/pkg/util"
"github.com/projectcalico/felix/ipsets"
"github.com/thoas/go-funk"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/klog"
)
Expand Down Expand Up @@ -111,27 +110,14 @@ func (c *Controller) getLocalPodIPs() ([]string, error) {

func (c *Controller) getSubnets() ([]string, error) {
var subnets []string
output, err := c.ovnClient.ListLogicalRouterPort()
allNamespaces, err := c.namespacesLister.List(labels.Everything())
if err != nil {
klog.Errorf("list logical router port failed, %+v", err)
klog.Errorf("list namespaces failed, %+v", err)
return nil, err
}
outputs := funk.FilterString(strings.Split(output, "\n"), func(s string) bool {
return s != ""
})
/*
ovn-cluster-join
100.64.0.1/16
ovn-cluster-ovn-default
10.16.0.1/16
*/
chucks := funk.Chunk(outputs, 2).([][]string)
for _, chuck := range chucks {
name := chuck[0]
network := chuck[1]
if name != fmt.Sprintf("%s-%s", c.config.ClusterRouter, c.config.NodeSwitch) {
subnets = append(subnets, network)
for _, namespace := range allNamespaces {
if subnet := namespace.Annotations[util.CidrAnnotation]; subnet != "" {
subnets = append(subnets, subnet)
}
}
klog.V(5).Infof("subnets %v", subnets)
Expand Down
21 changes: 0 additions & 21 deletions vendor/github.com/thoas/go-funk/LICENSE

This file was deleted.

106 changes: 0 additions & 106 deletions vendor/github.com/thoas/go-funk/builder.go

This file was deleted.

130 changes: 0 additions & 130 deletions vendor/github.com/thoas/go-funk/chain_builder.go

This file was deleted.

50 changes: 0 additions & 50 deletions vendor/github.com/thoas/go-funk/compact.go

This file was deleted.

0 comments on commit cb91d98

Please sign in to comment.