|
| 1 | +package specs |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/blueprint-uservices/blueprint/blueprint/pkg/wiring" |
| 5 | + "github.com/blueprint-uservices/blueprint/examples/leaf/workflow/leaf" |
| 6 | + "github.com/blueprint-uservices/blueprint/plugins/cmdbuilder" |
| 7 | + "github.com/blueprint-uservices/blueprint/plugins/goproc" |
| 8 | + "github.com/blueprint-uservices/blueprint/plugins/grpc" |
| 9 | + "github.com/blueprint-uservices/blueprint/plugins/kubernetes" |
| 10 | + "github.com/blueprint-uservices/blueprint/plugins/linuxcontainer" |
| 11 | + "github.com/blueprint-uservices/blueprint/plugins/mongodb" |
| 12 | + "github.com/blueprint-uservices/blueprint/plugins/simple" |
| 13 | + "github.com/blueprint-uservices/blueprint/plugins/workflow" |
| 14 | +) |
| 15 | + |
| 16 | +var Kubernetes = cmdbuilder.SpecOption{ |
| 17 | + Name: "kubernetes", |
| 18 | + Description: "Deploys each service as a Kubernetes Service connected with gRPC, uses mongodb as NoSQL database backends, and applies a number of modifiers", |
| 19 | + Build: makeKubernetesSpec, |
| 20 | +} |
| 21 | + |
| 22 | +func makeKubernetesSpec(spec wiring.WiringSpec) ([]string, error) { |
| 23 | + applyKubeDefaults := func(spec wiring.WiringSpec, serviceName string) string { |
| 24 | + grpc.Deploy(spec, serviceName) |
| 25 | + goproc.Deploy(spec, serviceName) |
| 26 | + return linuxcontainer.Deploy(spec, serviceName) |
| 27 | + } |
| 28 | + |
| 29 | + leaf_db := mongodb.Container(spec, "leaf_db") |
| 30 | + leaf_cache := simple.Cache(spec, "leaf_cache") |
| 31 | + leaf_service := workflow.Service[*leaf.LeafServiceImpl](spec, "leaf_service", leaf_cache, leaf_db) |
| 32 | + leaf_ctr := applyKubeDefaults(spec, leaf_service) |
| 33 | + |
| 34 | + nonleaf_service := workflow.Service[leaf.NonLeafService](spec, "nonleaf_service", leaf_service) |
| 35 | + nonleaf_ctr := applyKubeDefaults(spec, nonleaf_service) |
| 36 | + |
| 37 | + kube_app := kubernetes.NewApplication(spec, "leaf", leaf_db, leaf_ctr, nonleaf_ctr) |
| 38 | + return []string{kube_app}, nil |
| 39 | +} |
0 commit comments