Skip to content

Commit

Permalink
readme updates, and some go report fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnburn committed Oct 5, 2017
1 parent 6fa5b01 commit b654bc3
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 86 deletions.
50 changes: 19 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ for providing data-plane connectivity for cloud native containers. The
containers may be [Ligato VPP-agent][0] enabled containers which in turn use
[VPP][1] based cloud-native [Virtual Network Functions][2] (VNFs) or the
containers may be application containers communicating via veth interfaces.
The VPP Agent is built on top of the [CN-Infra platform][16] for developing
The VPP Agent is built on top of the [CN-Infra platform][5] for developing
cloud-native Virtual Network Functions (VNFs).

The SFC Controller supports a wide variety of topologies. The controller can
Expand Down Expand Up @@ -44,27 +44,25 @@ controlled hosts.
* **VPP agent containers**: these containers are VPP enabled and have a
[Ligato VPP-agent][0] which controls the VPP in the container. VNF's are
developed as extensions to [VPP][1].
* non-VPP containers: these are application containers which communicate
* **non-VPP containers**: these are application containers which communicate
with other containers or externally via veth interfaces. The VSwitch VPP
creates the veth interfaces.

The SFC Controller is basically a set of plugins that use the
CN-Infra platform to interact with other services / microservices in the
cloud (e.g. a KV data store, messaging, log warehouse, etc.). The SFC Controller
exposes VPP functionality to client apps via a higher-level model-driven
API. Clients that consume this API may be either external (connecting to
the VPP Agent via REST, gRPC API, Etcd or message bus transport), or local
Apps and/or Extension plugins running on the same CN-Infra platform in the
same Linux process.
## SFC Toppologies
The SFC Controller supports the following topologies:

![SFC Topolgies](docs/imgs/sfc_topologies.png "SFC Topologies")

## Plugins

The SFC controller is written with a plugin architecture so that functionality
can be extended.

The set of plugins in the SFC Controller is as follows:
* [CN-Infra core][13] - lifecycle management of plugins (loading,
initialization, unloading)
* [l2_driver][3] - l2 bridge, vxlan tunnel plugin (wire inter-host,
and host-external router)
* [CN-Infra core][5] - lifecycle management of plugins (loading,
initialization, unloading)

## Tools
The SFC Controller repository also contains tools for building and troubleshooting
Expand All @@ -75,12 +73,12 @@ of VNFs based on the VPP Agent:

## Quickstart
For a quick start with the sfc-controller, you can use pre-built Docker images with
the Agent and VPP on [Dockerhub][14].
the Agent and VPP on [Dockerhub][6].

0. Start ETCD and Kafka on your host (e.g. in Docker as described [here][15]).
0. Start ETCD and Kafka on your host (e.g. in Docker as described [here][7]).
Note: **The SFC Controller in the pre-built Docker image will not start if it can't
connect to both Etcd and Kafka**. Note: also start the VSwitch VPP. See the
[Quickstart VSwitch VPP][17]
[Quickstart VSwitch VPP][8]

1. Run VPP + VPP Agent in a Docker image:
```
Expand All @@ -93,12 +91,6 @@ docker run -it --name sfc-contoller --rm ligato/sfc-controller
docker exec -it sfc-controller sfcdump
```

3. Check the configuration (using agentctl or directly using VPP console):
```
docker exec -it vpp agentctl -e 172.17.0.1:2379 show
docker exec -it vpp vppctl -s localhost:5002
```

## Documentation
GoDoc can be browsed [online](https://godoc.org/github.com/ligato/sfc-controller).

Expand All @@ -109,19 +101,15 @@ Read the README for the [Development Docker Image](docker/dev_sfc-controller/REA
### Deployment:
[![K8s integration](docs/imgs/k8s_deployment_thumb.png "SFC Controller - K8s integration")](docs/Deployment.md)

### Extensibility:
[![VPP Agent Extensibility](docs/imgs/extensibility_thumb.png "VPP Agent - example of extensibility")](https://github.com/ligato/cn-sample-service)

## Contribution:
If you are interested in contributing, please see the [contribution guidelines](CONTRIBUTING.md).

[0]: https://github.com/ligato/vpp-agent
[1]: https://fd.io/
[2]: https://github.com/ligato/cn-infra/blob/master/docs/readmes/cn_virtual_function.md
[3]: https://developers.google.com/protocol-buffers/
[4]: https://wiki.fd.io/view/GoVPP
[13]: https://github.com/ligato/cn-infra/tree/master/core
[14]: https://hub.docker.com/r/ligato/sfc-controller/
[15]: docker/dev_vpp_agent/README.md#running-etcd-server-on-local-host
[16]: https://github.com/ligato/cn-infra
[17]: https://github.com/ligato/vpp-agent#quickstart
[3]: https://github.com/ligato/sfc-controller/tree/master/controller/cnpdriver
[4]: https://github.com/ligato/cn-infra
[5]: https://github.com/ligato/cn-infra/tree/master/core
[6]: https://hub.docker.com/r/ligato/sfc-controller/
[7]: docker/dev_vpp_agent/README.md#running-etcd-server-on-local-host
[8]: https://github.com/ligato/vpp-agent#quickstart
4 changes: 2 additions & 2 deletions cmd/sfcdump/sfcdump/sfcdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import (
"github.com/ligato/cn-infra/db/keyval/kvproto"
"github.com/ligato/cn-infra/logging"
"github.com/ligato/cn-infra/logging/logroot"
"github.com/ligato/sfc-controller/controller/model/controller"
"github.com/ligato/sfc-controller/controller/utils"
"github.com/ligato/vpp-agent/plugins/defaultplugins/ifplugin/model/interfaces"
"github.com/ligato/vpp-agent/plugins/defaultplugins/l2plugin/model/l2"
"github.com/ligato/vpp-agent/plugins/defaultplugins/l3plugin/model/l3"
linuxIntf "github.com/ligato/vpp-agent/plugins/linuxplugin/model/interfaces"
"github.com/ligato/sfc-controller/controller/model/controller"
"github.com/ligato/sfc-controller/controller/utils"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions controller/cnpdriver/cnp_driver_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

// cnp_driver_api is an interface definition for the container network policy.
// The goal of this interface is to provide generic routines for wiring contianers,
// The goal of this interface is to provide generic routines for wiring containers,
// host to hosts, and hosts to external routers.
//
// The current networking policies are the L2 policy with VxLan tunnels between
Expand All @@ -38,7 +38,7 @@ var (
// are invoked, the sfc controller will call methods on this interface for the
// registered plugin to effect the inter-host, intra-host network connectivity. As well,
// as host-external entity wiring.
// sfc controller natively supports its own container netwroking policy driver for both
// sfc controller natively supports its own container networking policy driver for both
// l3 and l2 overlays.
type SfcControllerCNPDriverAPI interface {
InitPlugin() error
Expand Down
19 changes: 10 additions & 9 deletions controller/cnpdriver/sfcctlr_l2_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ import (
"github.com/ligato/cn-infra/logging/logroot"
"github.com/ligato/cn-infra/servicelabel"
"github.com/ligato/cn-infra/utils/addrs"
"github.com/ligato/sfc-controller/controller/extentitydriver"
"github.com/ligato/sfc-controller/controller/model/controller"
"github.com/ligato/sfc-controller/controller/utils"
"github.com/ligato/vpp-agent/clientv1/linux"
"github.com/ligato/vpp-agent/clientv1/linux/remoteclient"
"github.com/ligato/vpp-agent/plugins/defaultplugins/ifplugin/model/interfaces"
"github.com/ligato/vpp-agent/plugins/defaultplugins/l2plugin/model/l2"
"github.com/ligato/vpp-agent/plugins/defaultplugins/l3plugin/model/l3"
linuxIntf "github.com/ligato/vpp-agent/plugins/linuxplugin/model/interfaces"
"strings"
"github.com/ligato/sfc-controller/controller/extentitydriver"
"github.com/ligato/sfc-controller/controller/model/controller"
"github.com/ligato/sfc-controller/controller/utils"
)

var (
Expand Down Expand Up @@ -534,35 +534,36 @@ func (cnpd *sfcCtlrL2CNPDriver) WireInternalsForExternalEntity(ee *controller.Ex
// Perform CNP specific wiring for inter-container wiring, and container to external router wiring
func (cnpd *sfcCtlrL2CNPDriver) WireSfcEntity(sfc *controller.SfcEntity) error {

var err error = nil
// the semantic difference between a north_south vs an east-west sfc entity, it what is the bridge that
// the memIf/afPkt if's will be associated.
switch sfc.Type {

case controller.SfcType_SFC_NS_VXLAN:
// north/south VXLAN type, memIfs/cntrs connect to vrouters/RASs bridge
cnpd.l2CNPEntityCache.SFCs[sfc.Name] = *sfc
return cnpd.wireSfcNorthSouthVXLANElements(sfc)
err = cnpd.wireSfcNorthSouthVXLANElements(sfc)

case controller.SfcType_SFC_NS_NIC_BD:
fallthrough
case controller.SfcType_SFC_NS_NIC_L2XCONN:
// north/south NIC type, memIfs/cntrs connect to physical NIC
cnpd.l2CNPEntityCache.SFCs[sfc.Name] = *sfc
return cnpd.wireSfcNorthSouthNICElements(sfc)
err = cnpd.wireSfcNorthSouthNICElements(sfc)

case controller.SfcType_SFC_EW_BD:
fallthrough
case controller.SfcType_SFC_EW_L2XCONN:
// east/west type, memIfs/cntrs connect to the hosts easet/west bridge
cnpd.l2CNPEntityCache.SFCs[sfc.Name] = *sfc
return cnpd.wireSfcEastWestElements(sfc)
err = cnpd.wireSfcEastWestElements(sfc)

default:
err := fmt.Errorf("WireSfcEntity: unknown entity type: '%s'", sfc.Type)
err = fmt.Errorf("WireSfcEntity: unknown entity type: '%s'", sfc.Type)
log.Error(err.Error())
return err
}
return nil

return err
}

// for now, ensure there is only one ee ... as each container will be wirred to it
Expand Down
4 changes: 1 addition & 3 deletions controller/cnpdriver/sfcctlr_l3_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import (
"github.com/ligato/sfc-controller/controller/model/controller"
)

const (
)
const ()

type sfcCtlrL3CNPDriver struct {
name string
Expand Down Expand Up @@ -54,7 +53,6 @@ func (cnpd *sfcCtlrL3CNPDriver) ReconcileStart(vppEtcdLabels map[string]struct{}
return nil
}


// Perform end processing for the reconcile of the CNP datastore
func (cnpd *sfcCtlrL3CNPDriver) ReconcileEnd() error {
return nil
Expand Down
25 changes: 12 additions & 13 deletions controller/core/controller_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@
package core

import (
"os"
"github.com/ligato/cn-infra/core"
"github.com/ligato/cn-infra/db/keyval"
"github.com/ligato/cn-infra/db/keyval/etcdv3"
"github.com/ligato/cn-infra/logging"
"github.com/ligato/cn-infra/logging/logroot"
"github.com/ligato/cn-infra/rpc/rest"
"github.com/ligato/cn-infra/utils/safeclose"
"github.com/namsral/flag"
"github.com/ligato/sfc-controller/controller/cnpdriver"
"github.com/ligato/sfc-controller/controller/extentitydriver"
"github.com/ligato/sfc-controller/controller/model/controller"
"github.com/namsral/flag"
"os"
)

// Plugin identifier (must be unique throughout the system)
const PluginID core.PluginName = "SfcController"

var (
cnpDriverName string // cli flag - see RegisterFlags
sfcConfigFile string // cli flag - see RegisterFlags
cleanSfcDatastore bool // cli flag - see RegisterFlags
log = logroot.StandardLogger()
cnpDriverName string // cli flag - see RegisterFlags
sfcConfigFile string // cli flag - see RegisterFlags
cleanSfcDatastore bool // cli flag - see RegisterFlags
log = logroot.StandardLogger()
)

// Add command line flags here.
func RegisterFlags() {
flag.StringVar(&cnpDriverName, "cnp-driver", "sfcctlrl2",
"Container Netowrking Policy driver: sfcctlrl2, sfcctlrl3")
"Container Networking Policy driver: sfcctlrl2, sfcctlrl3")
flag.StringVar(&sfcConfigFile, "sfc-config", "",
"Name of a sfc config (yaml) file to load at startup")
flag.BoolVar(&cleanSfcDatastore, "clean", false,
Expand Down Expand Up @@ -83,11 +83,11 @@ type SfcControllerPluginHandler struct {
Etcd *etcdv3.Plugin
HTTPmux *rest.Plugin

cnpDriverPlugin cnpdriver.SfcControllerCNPDriverAPI
yamlConfig *YamlConfig
ramConfigCache SfcControllerCacheType
controllerReady bool
db keyval.ProtoBroker
cnpDriverPlugin cnpdriver.SfcControllerCNPDriverAPI
yamlConfig *YamlConfig
ramConfigCache SfcControllerCacheType
controllerReady bool
db keyval.ProtoBroker
ReconcileVppLabelsMap ReconcileVppLabelsMapType
}

Expand Down Expand Up @@ -124,7 +124,6 @@ func (sfcCtrlPlugin *SfcControllerPluginHandler) Init() error {

log.Infof("CNP Driver: %s", sfcCtrlPlugin.cnpDriverPlugin.GetName())


sfcCtrlPlugin.ReconcileInit()

sfcCtrlPlugin.ReconcileStart()
Expand Down
4 changes: 2 additions & 2 deletions controller/core/http_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"github.com/ligato/sfc-controller/controller/model/controller"
"github.com/unrolled/render"
"io/ioutil"
"net/http"
"github.com/ligato/sfc-controller/controller/model/controller"
)

const (
Expand All @@ -37,7 +37,7 @@ var ()

var sfcplg *SfcControllerPluginHandler

// register the handler frunc for GET and POST, TODO PUT/DELETE
// InitHttpHandlers: register the handler funcs for GET and POST, TODO PUT/DELETE
func (sfcCtrlPlugin *SfcControllerPluginHandler) InitHttpHandlers() {

sfcplg = sfcCtrlPlugin
Expand Down
29 changes: 14 additions & 15 deletions controller/core/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,33 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// The reconcile process "resyncs" the configuration stored in the database, and
// the provided config yaml file (if there is one). It is possible to start
// with an empty datbase if desired by providing the -clean command line arg.
// The resync procedure loads the configuration into a reconcile "before"
// resync data structure then applies the configuration which causes new ETCD
// entries to be made, however, these will be put into the "after" resync data
// structure during reconcile. Once all config has been processed, the before
// and after data structures are post-processed.
//
// This module drives the reconile for the plugins.
// Package core: The reconcile process "resyncs" the configuration stored in
// the database, and the provided config yaml file (if there is one). It is
// possible to start with an empty database if desired by providing the -clean
// command line arg. The resync procedure loads the configuration into a
// reconcile "before" resync data structure then applies the configuration
// which causes new ETCD entries to be made, however, these will be put into
// the "after" resync data structure during reconcile. Once all config has
// been processed, the before and after data structures are post-processed.
// This module drives the resync for the plugins.
package core

import (
"github.com/ligato/sfc-controller/controller/utils"
)

// track all the vpp agents in etcd
// ReconcileVppLabelsMapType: track all the vpp agents in etcd
type ReconcileVppLabelsMapType map[string]struct{}

// initialize the map of all etcd vpp/agent labels
// ReconcileInit: initialize the map of all etcd vpp/agent labels
func (sfcCtrlPlugin *SfcControllerPluginHandler) ReconcileInit() error {

sfcCtrlPlugin.ReconcileVppLabelsMap = make(ReconcileVppLabelsMapType)

return nil
}

// init the reconcile procedure for all plguins
// ReconcileStart: init the reconcile procedure for all plguins
func (sfcCtrlPlugin *SfcControllerPluginHandler) ReconcileStart() error {

log.Info("ReconcileStart: enter ...")
Expand All @@ -55,7 +54,7 @@ func (sfcCtrlPlugin *SfcControllerPluginHandler) ReconcileStart() error {
return nil
}

// perform post processing of the reconcile procedure
// ReconcileEnd: perform post processing of the reconcile procedure
func (sfcCtrlPlugin *SfcControllerPluginHandler) ReconcileEnd() error {

log.Info("ReconcileEnd: begin ...")
Expand All @@ -66,7 +65,7 @@ func (sfcCtrlPlugin *SfcControllerPluginHandler) ReconcileEnd() error {
return nil
}

// pull all vpp lavels from the etcd datastore
// ReconcileLoadAllVppLabels: retrieve all vpp lavels from the etcd datastore
func (sfcCtrlPlugin *SfcControllerPluginHandler) ReconcileLoadAllVppLabels() {

log.Info("ReconcileLoadAllVppLabels: begin ...")
Expand Down
8 changes: 4 additions & 4 deletions controller/core/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// The renderer uses the config for hosts, external entites, and SFC's and
// invokes the registered CNP driver. Driver API's are invoked for wiring
// hosts to hosts, hosts to external routers, and the SFC's.
// Package core: The renderer uses the config for hosts, external entites,
// and SFC's and invokes the registered CNP driver. Driver API's are invoked
// for wiring hosts to hosts, hosts to external routers, and the SFC's.
package core

import (
"os"
"github.com/ligato/sfc-controller/controller/model/controller"
"os"
)

// Render the config: note that because we are wiring everything, we wire only one end when we
Expand Down
2 changes: 1 addition & 1 deletion controller/core/sfc_config_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package core

import (
"github.com/ghodss/yaml"
"io/ioutil"
"github.com/ligato/sfc-controller/controller/model/controller"
"io/ioutil"
)

type YamlConfig struct {
Expand Down
Loading

0 comments on commit b654bc3

Please sign in to comment.