Skip to content

Commit

Permalink
feat: support subnet isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Apr 2, 2019
1 parent 4c71690 commit 4367ba0
Show file tree
Hide file tree
Showing 65 changed files with 152 additions and 7,450 deletions.
39 changes: 0 additions & 39 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,50 +1,11 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/emicklei/go-restful"
version = "2.8.0"

[[constraint]]
name = "github.com/fatih/structs"
version = "1.1.0"

[[constraint]]
version = "v0.1.1"
name = "github.com/oilbeater/libovsdb"

[[constraint]]
name = "github.com/spf13/pflag"
version = "1.0.3"

[[constraint]]
name = "github.com/cenkalti/hub"
revision = "11382a9960d39b0ecda16fd01c424c11ff765a34"

[[constraint]]
branch = "master"
name = "github.com/cenkalti/rpc2"

[[constraint]]
name = "github.com/containernetworking/cni"
version = "v0.6.0"
Expand Down
2 changes: 1 addition & 1 deletion cmd/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func main() {
}
klog.Infof("create bridge %v for gw", bridge)

ovnClient := ovs.NewClient(config.OvnNbHost, config.OvnNbPort, config.OvnSbHost, config.OvnSbPort, "", "", "")
ovnClient := ovs.NewClient(config.OvnNbHost, config.OvnNbPort, config.OvnSbHost, config.OvnSbPort, "", "", "", "")

err = ovnClient.CreateGatewayRouter(config.EdgeRouterName, config.Chassis)
if err != nil {
Expand Down
24 changes: 0 additions & 24 deletions pkg/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package controller

import (
"flag"
"github.com/oilbeater/libovsdb"
"github.com/spf13/pflag"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
Expand All @@ -17,7 +16,6 @@ type Configuration struct {
OvnNbPort int
KubeConfigFile string
KubeClient kubernetes.Interface
OvnClient *libovsdb.OvsdbClient

DefaultLogicalSwitch string
DefaultCIDR string
Expand Down Expand Up @@ -89,10 +87,6 @@ func ParseFlags() (*Configuration, error) {
if err != nil {
return nil, err
}
err = config.initOvnClient()
if err != nil {
return nil, err
}

klog.Infof("config is %v", config)

Expand Down Expand Up @@ -125,21 +119,3 @@ func (config *Configuration) initKubeClient() error {
config.KubeClient = kubeClient
return nil
}

func (config *Configuration) initOvnClient() error {
var ovs *libovsdb.OvsdbClient
var err error
if config.OvnNbSocket != "" {
ovs, err = libovsdb.ConnectWithUnixSocket(config.OvnNbSocket)
if err != nil {
return err
}
} else {
ovs, err = libovsdb.Connect(config.OvnNbHost, config.OvnNbPort)
if err != nil {
return err
}
}
config.OvnClient = ovs
return nil
}
6 changes: 5 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Controller struct {
namespacesSynced cache.InformerSynced
addNamespaceQueue workqueue.RateLimitingInterface
deleteNamespaceQueue workqueue.RateLimitingInterface
updateNamespaceQueue workqueue.RateLimitingInterface

nodesLister v1.NodeLister
nodesSynced cache.InformerSynced
Expand Down Expand Up @@ -83,7 +84,7 @@ func NewController(

controller := &Controller{
config: config,
ovnClient: ovs.NewClient(config.OvnNbHost, config.OvnNbPort, "", 0, config.ClusterRouter, config.ClusterTcpLoadBalancer, config.ClusterUdpLoadBalancer),
ovnClient: ovs.NewClient(config.OvnNbHost, config.OvnNbPort, "", 0, config.ClusterRouter, config.ClusterTcpLoadBalancer, config.ClusterUdpLoadBalancer, config.NodeSwitchCIDR),
kubeclientset: config.KubeClient,

podsLister: podInformer.Lister(),
Expand All @@ -94,6 +95,7 @@ func NewController(
namespacesLister: namespaceInformer.Lister(),
namespacesSynced: namespaceInformer.Informer().HasSynced,
addNamespaceQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "AddNamespace"),
updateNamespaceQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "UpdateNamespace"),
deleteNamespaceQueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "DeleteNamespace"),

nodesLister: nodeInformer.Lister(),
Expand All @@ -120,6 +122,7 @@ func NewController(

namespaceInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: controller.enqueueAddNamespace,
UpdateFunc: controller.enqueueUpdateNamespace,
DeleteFunc: controller.enqueueDeleteNamespace,
})

Expand Down Expand Up @@ -167,6 +170,7 @@ func (c *Controller) Run(stopCh <-chan struct{}) error {

go wait.Until(c.runAddNamespaceWorker, time.Second, stopCh)
go wait.Until(c.runDeleteNamespaceWorker, time.Second, stopCh)
go wait.Until(c.runUpdateNamespaceWorker, time.Second, stopCh)

go wait.Until(c.runAddNodeWorker, time.Second, stopCh)
go wait.Until(c.runDeleteNodeWorker, time.Second, stopCh)
Expand Down

0 comments on commit 4367ba0

Please sign in to comment.