V2 types and TPR (#266)
This changes the core fission function, environment and trigger types. It also changes Fission's storage to use ThirdPartyResources. - Functions are now specified by packages. Functions can also have both source and deployment packages. A package can be specified by a literal, or by a URL. - Environments have a build and runtime component. - Triggers reference functions by a FunctionReference. This is a layer of indirection between triggers and functions, and will allow things like incremental function upgrades in future releases. See Documentation/wip/env-v2.md for design discussion about points 1 and 2. Changes: * V2 Types All types now have a spec, following the pattern of K8s objects. Functions now have source and deployment packages. A Package can be specified by literal, or by URL. Environments now have a builder and runtime component. All triggers use a new FunctionReference to specify the function. This for now only uses a function name, but in the future can be extended to be more flexible. A new FunctionLoadRequest type is added for specialization requests to the environment runtime. * TPR types, TPR init code, and a "fission client" Implements TPR types using the spec types in fission/types.go. Adds code for adding creating TPR types, and convenient types for crud operations on each of our resource types. Adds code for connecting to K8s API and configuring a REST client with fission types set up. * Change old stateful controller into a thin apiserver This apiserver is now simply a stateless api layer on top of the TPR types. At the moment it doesn't do anything that couldn't be done by simply talking to the TPR types. In the future we can have better validation and potentially some higher level APIs (like versioning for example) in here. * Split controller client into files and update for v2 types. * Update CLI for v2 types. As far as possible we keep the CLI flags the same. We'll have to add flags for source/deploy packages and builder/runtime environments. That will come in the next change. * Update poolmgr and fetcher for v2 types. Also adds a poolmgr_test. * Update router for new types. Also adds a function reference resolver, which separates out the job of resolving a FunctionReference to a function. * Update kubewatcher and timer for v2 types. * Update Message Queue trigger type for v2 types. * Minor odds and ends. * Fission bundle CLI updates Remove controllerUrl flag, since we don't need it any more. * Remove etcd deployment (replaced by storing state in TPR) Also update the poolmgr commandline, and use an env var for the fetcher image URL. * Explicit ChecksumType and consts * Clarify separation of environment interface types
This commit is contained in:
+26
-40
@@ -14,37 +14,25 @@ import (
|
||||
"github.com/fission/fission/timer"
|
||||
)
|
||||
|
||||
func runController(port int, etcdUrl string, filepath string) {
|
||||
// filePath will be created if it doesn't exist.
|
||||
fileStore := controller.MakeFileStore(filepath)
|
||||
if fileStore == nil {
|
||||
log.Fatalf("Failed to initialize filestore")
|
||||
}
|
||||
|
||||
rs, err := controller.MakeResourceStore(fileStore, []string{etcdUrl})
|
||||
if err != nil {
|
||||
log.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
api := controller.MakeAPI(rs)
|
||||
api.Serve(port)
|
||||
func runController(port int) {
|
||||
controller.Start(port)
|
||||
log.Fatalf("Error: Controller exited.")
|
||||
}
|
||||
|
||||
func runRouter(port int, controllerUrl string, poolmgrUrl string) {
|
||||
router.Start(port, controllerUrl, poolmgrUrl)
|
||||
func runRouter(port int, poolmgrUrl string) {
|
||||
router.Start(port, poolmgrUrl)
|
||||
log.Fatalf("Error: Router exited.")
|
||||
}
|
||||
|
||||
func runPoolmgr(port int, controllerUrl string, namespace string) {
|
||||
err := poolmgr.StartPoolmgr(controllerUrl, namespace, port)
|
||||
func runPoolmgr(port int, fissionNamespace, functionNamespace string) {
|
||||
err := poolmgr.StartPoolmgr(fissionNamespace, functionNamespace, port)
|
||||
if err != nil {
|
||||
log.Fatalf("Error starting poolmgr: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func runKubeWatcher(controllerUrl, routerUrl string) {
|
||||
err := kubewatcher.Start(controllerUrl, routerUrl)
|
||||
func runKubeWatcher(routerUrl string) {
|
||||
err := kubewatcher.Start(routerUrl)
|
||||
if err != nil {
|
||||
log.Fatalf("Error starting kubewatcher: %v", err)
|
||||
}
|
||||
@@ -55,15 +43,15 @@ func runLogger() {
|
||||
log.Fatalf("Error: Logger exited.")
|
||||
}
|
||||
|
||||
func runTimer(controllerUrl, routerUrl string) {
|
||||
err := timer.Start(controllerUrl, routerUrl)
|
||||
func runTimer(routerUrl string) {
|
||||
err := timer.Start(routerUrl)
|
||||
if err != nil {
|
||||
log.Fatalf("Error starting timer: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func runMessageQueueMgr(controllerUrl, routerUrl string) {
|
||||
err := messagequeue.Start(controllerUrl, routerUrl)
|
||||
func runMessageQueueMgr(routerUrl string) {
|
||||
err := messagequeue.Start(routerUrl)
|
||||
if err != nil {
|
||||
log.Fatalf("Error starting timer: %v", err)
|
||||
}
|
||||
@@ -98,18 +86,17 @@ Use it to start one or more of the fission servers:
|
||||
Router implements HTTP triggers: it routes to running instances, working with the controller and poolmgr.
|
||||
|
||||
Usage:
|
||||
fission-bundle --controllerPort=<port> [--etcdUrl=<etcdUrl>] --filepath=<filepath>
|
||||
fission-bundle --routerPort=<port> [--controllerUrl=<url> --poolmgrUrl=<url>]
|
||||
fission-bundle --poolmgrPort=<port> [--controllerUrl=<url> --namespace=<namespace>]
|
||||
fission-bundle --kubewatcher [--controllerUrl=<url> --routerUrl=<url>]
|
||||
fission-bundle --controllerPort=<port>
|
||||
fission-bundle --routerPort=<port> [--poolmgrUrl=<url>]
|
||||
fission-bundle --poolmgrPort=<port> [--namespace=<namespace>] [--fission-namespace=<namespace>]
|
||||
fission-bundle --kubewatcher [--routerUrl=<url>]
|
||||
fission-bundle --logger
|
||||
fission-bundle --timer [--controllerUrl=<url> --routerUrl=<url>]
|
||||
fission-bundle --mqt [--controllerUrl=<url> --routerUrl=<url>]
|
||||
fission-bundle --timer [--routerUrl=<url>]
|
||||
fission-bundle --mqt [--routerUrl=<url>]
|
||||
Options:
|
||||
--controllerPort=<port> Port that the controller should listen on.
|
||||
--routerPort=<port> Port that the router should listen on.
|
||||
--poolmgrPort=<port> Port that the poolmgr should listen on.
|
||||
--controllerUrl=<url> Controller URL. Not required if --controllerPort is specified.
|
||||
--poolmgrUrl=<url> Poolmgr URL. Not required if --poolmgrPort is specified.
|
||||
--routerUrl=<url> Router URL.
|
||||
--etcdUrl=<etcdUrl> Etcd URL.
|
||||
@@ -125,30 +112,29 @@ Options:
|
||||
log.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
namespace := getStringArgWithDefault(arguments["--namespace"], "fission-function")
|
||||
functionNs := getStringArgWithDefault(arguments["--namespace"], "fission-function")
|
||||
fissionNs := getStringArgWithDefault(arguments["--fission-namespace"], "fission")
|
||||
|
||||
controllerUrl := getStringArgWithDefault(arguments["--controllerUrl"], "http://controller.fission")
|
||||
etcdUrl := getStringArgWithDefault(arguments["--etcdUrl"], "http://etcd:2379")
|
||||
poolmgrUrl := getStringArgWithDefault(arguments["--poolmgrUrl"], "http://poolmgr.fission")
|
||||
routerUrl := getStringArgWithDefault(arguments["--routerUrl"], "http://router.fission")
|
||||
|
||||
if arguments["--controllerPort"] != nil {
|
||||
port := getPort(arguments["--controllerPort"])
|
||||
runController(port, etcdUrl, arguments["--filepath"].(string))
|
||||
runController(port)
|
||||
}
|
||||
|
||||
if arguments["--routerPort"] != nil {
|
||||
port := getPort(arguments["--routerPort"])
|
||||
runRouter(port, controllerUrl, poolmgrUrl)
|
||||
runRouter(port, poolmgrUrl)
|
||||
}
|
||||
|
||||
if arguments["--poolmgrPort"] != nil {
|
||||
port := getPort(arguments["--poolmgrPort"])
|
||||
runPoolmgr(port, controllerUrl, namespace)
|
||||
runPoolmgr(port, fissionNs, functionNs)
|
||||
}
|
||||
|
||||
if arguments["--kubewatcher"] == true {
|
||||
runKubeWatcher(controllerUrl, routerUrl)
|
||||
runKubeWatcher(routerUrl)
|
||||
}
|
||||
|
||||
if arguments["--logger"] == true {
|
||||
@@ -156,11 +142,11 @@ Options:
|
||||
}
|
||||
|
||||
if arguments["--timer"] == true {
|
||||
runTimer(controllerUrl, routerUrl)
|
||||
runTimer(routerUrl)
|
||||
}
|
||||
|
||||
if arguments["--mqt"] == true {
|
||||
runMessageQueueMgr(controllerUrl, routerUrl)
|
||||
runMessageQueueMgr(routerUrl)
|
||||
}
|
||||
|
||||
select {}
|
||||
|
||||
Reference in New Issue
Block a user