This commit is contained in:
mr 2024-08-20 09:23:05 +02:00
parent e5cfd6f4fb
commit 825c18b6d6
8 changed files with 66 additions and 62 deletions

View File

@ -15,6 +15,8 @@ ENV MONITORD_PATH = "./oc-monitord"
WORKDIR /app
COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json
COPY --from=monitord /app/oc-monitord .
COPY --from=builder /app/oc-schedulerd .
COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json

View File

@ -9,7 +9,6 @@ import (
type Config struct {
MonitorPath string
OcCatalogUrl string
MongoUrl string
DBName string
Logs string
@ -21,7 +20,6 @@ var instance *Config
var once sync.Once
const defaultConfigFile = "/etc/oc/schedulerd.json"
const localConfigFile = "./conf/local_schedulerd.json"
func init() {
configFile := ""
@ -33,28 +31,18 @@ func init() {
logs.Info("Config file found : " + defaultConfigFile)
configFile = defaultConfigFile
}
l1, err := onion.NewFileLayer(localConfigFile, nil)
if err == nil {
logs.Info("Local config file found " + localConfigFile + ", overriding default file")
configFile = localConfigFile
}
if configFile == "" {
if configFile == "" || l2 == nil {
logs.Info("No config file found, using env")
o = onion.New(l3)
} else if l1 == nil && l2 == nil {
o = onion.New(l1, l2, l3)
} else if l1 == nil {
} else {
o = onion.New(l2, l3)
} else if l2 == nil {
o = onion.New(l1, l3)
}
GetConfig().MonitorPath = o.GetStringDefault("MONITORD_PATH", "../oc-monitord/oc-monitord")
GetConfig().OcCatalogUrl = o.GetStringDefault("oc-catalog", "https://localhost:49618")
GetConfig().Logs = o.GetStringDefault("loglevel", "info")
GetConfig().LokiUrl = o.GetStringDefault("loki_url", "http://127.0.0.1:3100")
GetConfig().NatsUrl = o.GetStringDefault("nats_url", "http://127.0.0.1:4222")
GetConfig().MongoUrl = o.GetStringDefault("mongo_url", "mongodb://127.0.0.1:27017")
GetConfig().DBName = o.GetStringDefault("database_name", "DC_myDC")
GetConfig().Logs = o.GetStringDefault("LOG_LEVEL", "info")
GetConfig().LokiUrl = o.GetStringDefault("LOKI_URL", "http://127.0.0.1:3100")
GetConfig().NatsUrl = o.GetStringDefault("NATS_URL", "http://127.0.0.1:4222")
GetConfig().MongoUrl = o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017")
GetConfig().DBName = o.GetStringDefault("MONGO_DATABASE", "DC_myDC")
}

View File

@ -1,4 +1,6 @@
{
"oc-catalog" : "http://oc-catalog:49618/",
"loki_url" : "http://192.168.1.18:3100"
"LOKI_URL" : "http://loki:3100",
"MONGO_URL":"mongodb://mongo:27017/",
"MONGO_DATABASE":"DC_myDC",
"NATS_URL": "nats://nats:4222"
}

View File

@ -1,5 +0,0 @@
{
"oc-catalog" : "http://localhost:49618/",
"logs" : "",
"mongo_url": "mongodb://127.0.0.1:27017"
}

View File

@ -3,6 +3,7 @@ package daemons
import (
"encoding/json"
"fmt"
"oc-schedulerd/conf"
"sync"
"time"
@ -72,7 +73,7 @@ type ScheduleManager struct {
// on workflows' scheduling. Messages must contain
// workflow execution ID, to allow retrieval of execution infos
func (s *ScheduleManager) ListenForWorkflowSubmissions() {
nc, err := nats.Connect(nats.DefaultURL)
nc, err := nats.Connect(conf.GetConfig().NatsUrl)
if err != nil {
s.Logger.Error().Msg("Could not connect to NATS")
return

39
docker-compose.tools.yml Normal file
View File

@ -0,0 +1,39 @@
version: '3.4'
services:
nats:
image: 'nats:latest'
container_name: nats
ports:
- 4222:4222
command:
- "--debug"
networks:
- scheduler
- catalog
loki:
image: 'grafana/loki'
container_name: loki
ports :
- "3100:3100"
networks:
- scheduler
grafana:
image: 'grafana/grafana'
container_name: grafana
ports:
- '3000:3000'
networks:
- scheduler
volumes:
- ./conf/grafana_data_source.yml:/etc/grafana/provisioning/datasources/datasource.yml
environment:
- GF_SECURITY_ADMIN_PASSWORD=pfnirt # Change this to anything but admin to not have a password change page at startup
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_DISABLE_INITIAL_ADMIN_PASSWORD_CHANGE=true
networks:
scheduler:
external: true
catalog:
external: true

View File

@ -1,39 +1,16 @@
version: '3.4'
services:
nats:
image: 'nats:latest'
container_name: nats
ports:
- 4222:4222
command:
- "--debug"
networks:
- scheduler
- catalog
loki:
image: 'grafana/loki'
container_name: loki
ports :
- "3100:3100"
networks:
- scheduler
grafana:
image: 'grafana/grafana'
container_name: grafana
ports:
- '3000:3000'
networks:
- scheduler
volumes:
- ./conf/grafana_data_source.yml:/etc/grafana/provisioning/datasources/datasource.yml
oc-schedulerd:
environment:
- GF_SECURITY_ADMIN_PASSWORD=pfnirt # Change this to anything but admin to not have a password change page at startup
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_DISABLE_INITIAL_ADMIN_PASSWORD_CHANGE=true
- MONGO_DATABASE=DC_myDC
image: 'oc-schedulerd:latest'
ports:
- 9001:8080
container_name: oc-schedulerd
networks:
- catalog
networks:
scheduler:
external: true
catalog:
external: true

Binary file not shown.