Coder Social home page Coder Social logo

jozef-slezak / cn-infra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ligato/cn-infra

0.0 2.0 0.0 61.17 MB

A Framework for Cloud-Native Virtual Network Functions (VNFs).

License: Apache License 2.0

Makefile 0.97% Go 95.56% Shell 3.47%

cn-infra's Introduction

CN-Infra

Build Status Coverage Status Go Report Card GoDoc GitHub license

CN-Infra (cloud-native infrastructure) is a Golang platform for building cloud-native microservices. Although it was originally intended for development/implementation of custom management/control plane agents for cloud-native Virtual Network Functions (VNFs), it can be used to develop any microservice.

Architecture

Each management/control plane app built on top of the CN-Infra platform is basically a set of modules called "plugins" in CN-Infra lingo, where each plugin provides a very specific/focused functionality. Some plugins are provided by the CN-Infra platform itself, some are written by the app's implementors. In other words, the CN-Infra platform itself is implemented as a set of plugins that together provide the platform's functionality, such as logging, health checks, messaging (e.g. Kafka), a common front-end API and back-end connectivity to various KV data stores (Etcd, Cassandra, Redis, ...), and REST and gRPC APIs.

The architecture of the CN-Infra platform is shown in the following figure.

arch

The CN-Infra platform consists of a Core that provides plugin lifecycle management (initialization and graceful shutdown of plugins) and a set of platform plugins. Note that the figure shows not only CN-Infra plugins that are a part of the CN-Infra platform, but also app plugins that use the platform. CN-Infra platform plugins provide APIs that are consumed by app plugins. App plugins themselves may provide their own APIs consumed by external clients.

The platform is modular and extensible. Plugins supporting new functionality (e.g. another KV store or another message bus) can be easily added to the existing set of CN-Infra platform plugins. Moreover, CN-Infra based apps can be built in layers: a set of app plugins together with CN-Infra plugins can form a new platform providing APIs/services to higher layer apps. This approach was used in the VPP Agent - a management/control agent for VPP based software data planes.,

Extending the code base does not mean that all plugins end up in all apps - app writers can pick and choose only those platform plugins that are required by their app; for example, if an app does not need a KV store, the CN-Infra platform KV data store plugins would not be included in the app. All plugins used in an app are statically linked into the app.

CN-Infra Plugins

A CN-Infra plugin is typically implemented as a library providing the plugin's functionality/APIs wrapped in a plugin wrapper. A CN-Infra library can also be used standalone in 3rd party apps that do not use the CN-Infra platform. The plugin wrapper provides lifecycle management for the plugin component.

Platform plugins in the current CN-Infra release provide functionality in one of the following functional areas:

  • RPC - allows to expose application's API via REST or gRPC:

    • REST - HTTP requests and allows app plugins to define their own REST APIs.
  • Data Stores - provides a common data store API for app plugins (the Data Broker) and back-end clients for Etcd, Redis and Cassandra. The data store related plugin are as follows:

    • Etcd - implements keyval skeleton provides access to etcd
    • Redis - implements keyval skeleton provides access to redis
    • Casssandra - implements sql skeleton provides access to cassandra
  • Messaging - provides a common API and connectivity to message buses:

    • Kafka - provides access to a Kafka broker (Sarama)
  • Logging:

    • Logrus wrapper - implements logging skeleton using the Logrus library. An app writer can create multiple loggers - for example, each app plugin can have its own logger. Log level for each logger can be controlled individually at run time through the Log Manager REST API.
    • Log Manager - allows the operator to set log level for each logger using a REST API.
  • Health - Self health check mechanism between plugins plus RPCs:

    • StatusCheck - allows to monitor the status of plugins and exposes it via HTTP
    • Probes (callable remotely from K8s)
  • Miscellaneous - value-add plugins supporting the operation of a CN-Infra based application:

    • Config - helpers for loading plugin configuration.
    • Datasync - provides data resynchronization after HA events (restart or connectivity restoration after an outage) for data stores, gRPC and REST.
    • Flavors - predefined reusable collection of plugins.
    • IDX Map - reusable thread-safe map with advanced features:
      • multiple subscribers for watching changes in the map
      • secondary indexes
    • ServiceLabel - provides setting and retrieval of a unique identifier for a CN-Infra based app. A cloud app typically needs a unique identifier so that it can differentiated from other instances of the same app or from other apps (e.g. to have its own space in a kv data store).

Quickstart

The following code shows the initialization/start of a simple agent application built on the CN-Infra platform. The code for this example can be found here.

func main() {
	flavor := &rpc.FlavorRPC{}
	agent := core.NewAgent(flavor)

	err := core.EventLoopWithInterrupt(agent, nil)
	if err != nil {
		os.Exit(1)
	}
}

You can run this example code by using pre-build Docker images:

For quick start with the VPP Agent, you can use pre-build Docker images with the Agent and VPP on Dockerhub.

  1. Run ETCD and Kafka on your host (e.g. in Docker using this procedure).

  2. Run cn-infra example simple-agent.

docker pull ligato/dev-cn-infra
docker run -it --name dev-cn-infra --rm ligato/dev-cn-infra

Documentation

GoDoc can be browsed online.

Contributing

If you are interested in contributing, please see the contribution guidelines.

cn-infra's People

Contributors

lukasmacko avatar vladolavor avatar mpundlik avatar jozef-slezak avatar junmipan avatar jmedved avatar rastislavs avatar martinfrk avatar ondrej-fabry avatar msestak77 avatar stanislav-chlebec avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.