deployment added
This commit is contained in:
26
deployment/deploy-yml.tmpl
Normal file
26
deployment/deploy-yml.tmpl
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: udi
|
||||||
|
namespace: udi
|
||||||
|
labels:
|
||||||
|
app: udi
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: udi
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: udi
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: udi
|
||||||
|
image: %IMAGE%
|
||||||
|
env:
|
||||||
|
- name: UDI_CONF
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: udi-conf
|
||||||
|
key: UDI_CONF
|
@ -4,6 +4,10 @@ import "encoding/json"
|
|||||||
import "log"
|
import "log"
|
||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
|
type HandlerConfigT struct {
|
||||||
|
DatabaseConnStr string `json:"databaseConnStr"`
|
||||||
|
Attributes map[string]string `json:"attributes"`
|
||||||
|
}
|
||||||
|
|
||||||
type ConfigT struct {
|
type ConfigT struct {
|
||||||
Mqtt struct {
|
Mqtt struct {
|
||||||
@ -16,11 +20,7 @@ type ConfigT struct {
|
|||||||
Topics []string `json:"topics"`
|
Topics []string `json:"topics"`
|
||||||
Handler string `json:"handler"`
|
Handler string `json:"handler"`
|
||||||
} `json:"topicMappings"`
|
} `json:"topicMappings"`
|
||||||
Handlers []struct {
|
Handlers map[string]HandlerConfigT `json:"handlers"`
|
||||||
Name string `json:"name"`
|
|
||||||
DatabaseConnStr string `json:"databaseConnStr"`
|
|
||||||
Attributes map[string]string `json:"attributes"`
|
|
||||||
} `json:"handlers"`
|
|
||||||
Archiver struct {
|
Archiver struct {
|
||||||
Dir string `json:"dir"`
|
Dir string `json:"dir"`
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ func InitDispatcher() {
|
|||||||
go archiver()
|
go archiver()
|
||||||
handlerMap["TTN"] = ttn.NewTTNHandler()
|
handlerMap["TTN"] = ttn.NewTTNHandler()
|
||||||
handlerMap["IoT"] = iot.NewIoTHandler()
|
handlerMap["IoT"] = iot.NewIoTHandler()
|
||||||
handlerMap["PV"] = pv.NewPvHandler()
|
handlerMap["PV"] = pv.NewPvHandler(config.Config.Handlers["PV"])
|
||||||
handlerMap["MBGW3"] = mbgw3.NewMbgw3Handler()
|
handlerMap["MBGW3"] = mbgw3.NewMbgw3Handler(config.Config.Handlers["MBGW3"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func storeMessage(filename string, item handler.MessageT) {
|
func storeMessage(filename string, item handler.MessageT) {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
"strconv"
|
"strconv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"udi/config"
|
||||||
"udi/handlers/handler"
|
"udi/handlers/handler"
|
||||||
"udi/database"
|
"udi/database"
|
||||||
)
|
)
|
||||||
@ -29,12 +30,12 @@ type Observation struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewMbgw3Handler() *Mbgw3Handler {
|
func NewMbgw3Handler(config config.HandlerConfigT) *Mbgw3Handler {
|
||||||
t := &Mbgw3Handler {
|
t := &Mbgw3Handler {
|
||||||
id: idSeq,
|
id: idSeq,
|
||||||
}
|
}
|
||||||
idSeq += 1
|
idSeq += 1
|
||||||
t.dbh = database.NewDatabaseHandle("")
|
t.dbh = database.NewDatabaseHandle(config.DatabaseConnStr)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"udi/config"
|
||||||
"udi/handlers/handler"
|
"udi/handlers/handler"
|
||||||
"udi/database"
|
"udi/database"
|
||||||
)
|
)
|
||||||
@ -38,12 +39,12 @@ type PvValue struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewPvHandler() *PvHandler {
|
func NewPvHandler(config config.HandlerConfigT) *PvHandler {
|
||||||
t := &PvHandler {
|
t := &PvHandler {
|
||||||
id: idSeq,
|
id: idSeq,
|
||||||
}
|
}
|
||||||
idSeq += 1
|
idSeq += 1
|
||||||
t.dbh = database.NewDatabaseHandle("")
|
t.dbh = database.NewDatabaseHandle(config.DatabaseConnStr)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user