Mode in CMD
This commit is contained in:
parent
6621d14d74
commit
7246dea2b2
21
Dockerfile
21
Dockerfile
@ -1,25 +1,24 @@
|
||||
FROM golang:alpine AS builder
|
||||
LABEL maintainer="IRT PFN"
|
||||
ENV DOCKER_ENVIRONMENT=true
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN go build .
|
||||
RUN go build
|
||||
|
||||
FROM oc-monitord:latest AS monitord
|
||||
|
||||
FROM argoproj/argocd:latest
|
||||
|
||||
ENV MONITORD_PATH = "./oc-monitord"
|
||||
FROM scratch
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY conf/docker_schedulerd.json /etc/oc/schedulerd.json
|
||||
COPY 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
|
||||
COPY --from=monitord /app/oc-monitord /usr/bin/oc-monitord
|
||||
COPY --from=builder /app/oc-schedulerd /usr/bin/oc-schedulerd
|
||||
|
||||
ENTRYPOINT ["/app/oc-schedulerd"]
|
||||
COPY docker_schedulerd.json /etc/oc/schedulerd.json
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["oc-schedulerd"]
|
||||
|
@ -14,6 +14,7 @@ type Config struct {
|
||||
Logs string
|
||||
LokiUrl string
|
||||
NatsUrl string
|
||||
Mode string
|
||||
}
|
||||
|
||||
var instance *Config
|
||||
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"LOKI_URL" : "http://loki:3100",
|
||||
"MONGO_URL":"mongodb://mongo:27017/",
|
||||
"MONGO_DATABASE":"DC_myDC",
|
||||
"NATS_URL": "nats://nats:4222"
|
||||
}
|
@ -31,7 +31,7 @@ func (lm *LocalMonitor) LaunchLocalMonitor() {
|
||||
}
|
||||
|
||||
func (lm *LocalMonitor) execLocalKube() {
|
||||
args := []string{"-e", lm.ExecutionID, "-p", lm.PeerID, "-u", lm.LokiURL, "-m", conf.GetConfig().MongoUrl, "-d", conf.GetConfig().DBName}
|
||||
args := []string{"-e", lm.ExecutionID, "-p", lm.PeerID, "-u", lm.LokiURL, "-m", conf.GetConfig().MongoUrl, "-d", conf.GetConfig().DBName, "-M", conf.GetConfig().Mode}
|
||||
if lm.Duration > 0 {
|
||||
args = append(args, "-t", fmt.Sprintf("%d", lm.Duration))
|
||||
}
|
||||
|
@ -10,33 +10,33 @@ import (
|
||||
workflow_execution "cloud.o-forge.io/core/oc-lib/models/workflow_execution"
|
||||
)
|
||||
|
||||
var Bookings = ScheduledBooking{Bookings: []*workflow_execution.WorkflowExecutions{}}
|
||||
var Executions = ScheduledExecution{Execs: []*workflow_execution.WorkflowExecution{}}
|
||||
|
||||
type ExecutionManager struct{}
|
||||
|
||||
// Loop every second on the booking's list and move the booking that must start to a new list
|
||||
// Loop every second on the Execution's list and move the Execution that must start to a new list
|
||||
// that will be looped over to start them
|
||||
func (em *ExecutionManager) RetrieveNextExecutions() {
|
||||
logger := oclib.GetLogger()
|
||||
for {
|
||||
fmt.Println("Checking for bookings", len(Bookings.Bookings))
|
||||
Bookings.Mu.Lock()
|
||||
if len(Bookings.Bookings) > 0 {
|
||||
bookings := Bookings.Bookings
|
||||
for i := len(bookings) - 1; i >= 0; i-- {
|
||||
if bookings[i].ExecDate.Before(time.Now().UTC()) {
|
||||
logger.Info().Msg("Will execute " + bookings[i].UUID + " soon")
|
||||
go em.executeBooking(bookings[i])
|
||||
Bookings.Bookings = append(bookings[:i], bookings[i+1:]...)
|
||||
fmt.Println("Checking for executions", len(Executions.Execs))
|
||||
Executions.Mu.Lock()
|
||||
if len(Executions.Execs) > 0 {
|
||||
executions := Executions.Execs
|
||||
for i := len(executions) - 1; i >= 0; i-- {
|
||||
if executions[i].ExecDate.Before(time.Now().UTC()) {
|
||||
logger.Info().Msg("Will execute " + executions[i].UUID + " soon")
|
||||
go em.executeExecution(executions[i])
|
||||
Executions.Execs = append(executions[:i], executions[i+1:]...)
|
||||
}
|
||||
}
|
||||
}
|
||||
Bookings.Mu.Unlock()
|
||||
Executions.Mu.Unlock()
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func (em *ExecutionManager) executeBooking(booking *workflow_execution.WorkflowExecutions) {
|
||||
func (em *ExecutionManager) executeExecution(Execution *workflow_execution.WorkflowExecution) {
|
||||
// start execution
|
||||
// create the yaml that describes the pod : filename, path/url to Loki
|
||||
exec_method := os.Getenv("MONITOR_METHOD")
|
||||
@ -46,16 +46,16 @@ func (em *ExecutionManager) executeBooking(booking *workflow_execution.WorkflowE
|
||||
} else {
|
||||
logger.Debug().Msg("Executing oc-monitor localy")
|
||||
duration := 0
|
||||
if booking.EndDate != nil {
|
||||
duration = int(booking.EndDate.Sub(booking.ExecDate).Seconds())
|
||||
if Execution.EndDate != nil {
|
||||
duration = int(Execution.EndDate.Sub(Execution.ExecDate).Seconds())
|
||||
}
|
||||
monitor := LocalMonitor{
|
||||
Logger: logger,
|
||||
Duration: duration,
|
||||
LokiURL: conf.GetConfig().LokiUrl,
|
||||
KubeURL: "localhost",
|
||||
ExecutionID: booking.UUID,
|
||||
PeerID: booking.CreatorID,
|
||||
ExecutionID: Execution.UUID,
|
||||
PeerID: Execution.CreatorID,
|
||||
}
|
||||
monitor.LaunchLocalMonitor()
|
||||
}
|
||||
|
@ -17,36 +17,36 @@ import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type ScheduledBooking struct {
|
||||
Bookings []*workflow_execution.WorkflowExecutions
|
||||
Mu sync.Mutex
|
||||
type ScheduledExecution struct {
|
||||
Execs []*workflow_execution.WorkflowExecution
|
||||
Mu sync.Mutex
|
||||
}
|
||||
|
||||
func (sb *ScheduledBooking) DeleteSchedules(workflow_id string) {
|
||||
toNotDelete := []*workflow_execution.WorkflowExecutions{}
|
||||
for _, b := range sb.Bookings {
|
||||
func (sb *ScheduledExecution) DeleteSchedules(workflow_id string) {
|
||||
toNotDelete := []*workflow_execution.WorkflowExecution{}
|
||||
for _, b := range sb.Execs {
|
||||
if b.WorkflowID != workflow_id {
|
||||
toNotDelete = append(toNotDelete, b)
|
||||
}
|
||||
}
|
||||
Bookings.Mu.Lock()
|
||||
defer Bookings.Mu.Unlock()
|
||||
sb.Bookings = toNotDelete
|
||||
Executions.Mu.Lock()
|
||||
defer Executions.Mu.Unlock()
|
||||
sb.Execs = toNotDelete
|
||||
}
|
||||
|
||||
func (sb *ScheduledBooking) AddSchedules(new_bookings []*workflow_execution.WorkflowExecutions, logger zerolog.Logger) {
|
||||
Bookings.Mu.Lock()
|
||||
defer Bookings.Mu.Unlock()
|
||||
for _, exec := range new_bookings {
|
||||
func (sb *ScheduledExecution) AddSchedules(new_executions []*workflow_execution.WorkflowExecution, logger zerolog.Logger) {
|
||||
Executions.Mu.Lock()
|
||||
defer Executions.Mu.Unlock()
|
||||
for _, exec := range new_executions {
|
||||
fmt.Println("Adding "+exec.UUID, !sb.execIsSet(exec))
|
||||
if !sb.execIsSet(exec) {
|
||||
sb.Bookings = append(sb.Bookings, exec)
|
||||
sb.Execs = append(sb.Execs, exec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (sb *ScheduledBooking) execIsSet(exec *workflow_execution.WorkflowExecutions) bool {
|
||||
for _, b := range sb.Bookings {
|
||||
func (sb *ScheduledExecution) execIsSet(exec *workflow_execution.WorkflowExecution) bool {
|
||||
for _, b := range sb.Execs {
|
||||
if b.Equals(exec) {
|
||||
return true
|
||||
}
|
||||
@ -102,7 +102,7 @@ func (s *ScheduleManager) listenForChange(nc *nats.Conn, chanName string, delete
|
||||
}
|
||||
fmt.Println("Catching " + str + " workflow... " + map_mess["id"])
|
||||
if delete {
|
||||
Bookings.DeleteSchedules(map_mess["id"])
|
||||
Executions.DeleteSchedules(map_mess["id"])
|
||||
} else {
|
||||
s.getNextScheduledWorkflows(1)
|
||||
}
|
||||
@ -115,11 +115,11 @@ func (s *ScheduleManager) SchedulePolling() {
|
||||
var sleep_time float64 = 1
|
||||
for {
|
||||
s.getNextScheduledWorkflows(1)
|
||||
s.Logger.Info().Msg("Current list of schedules -------> " + fmt.Sprintf("%v", len(Bookings.Bookings)))
|
||||
s.Logger.Info().Msg("Current list of schedules -------> " + fmt.Sprintf("%v", len(Executions.Execs)))
|
||||
time.Sleep(time.Minute * time.Duration(sleep_time))
|
||||
}
|
||||
}
|
||||
func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list []*workflow_execution.WorkflowExecutions, err error) {
|
||||
func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list []*workflow_execution.WorkflowExecution, err error) {
|
||||
fmt.Printf("Getting workflows execution from %s to %s \n", from.String(), to.String())
|
||||
f := dbs.Filters{
|
||||
And: map[string][]dbs.Filter{
|
||||
@ -133,7 +133,7 @@ func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list
|
||||
return
|
||||
}
|
||||
for _, exec := range res.Data {
|
||||
exec_list = append(exec_list, exec.(*workflow_execution.WorkflowExecutions))
|
||||
exec_list = append(exec_list, exec.(*workflow_execution.WorkflowExecution))
|
||||
}
|
||||
fmt.Println("Found "+fmt.Sprintf("%v", len(exec_list))+" workflows", res)
|
||||
return
|
||||
@ -151,6 +151,6 @@ func (s *ScheduleManager) getNextScheduledWorkflows(minutes float64) {
|
||||
); err != nil {
|
||||
s.Logger.Error().Msg("Could not retrieve next schedules")
|
||||
} else {
|
||||
Bookings.AddSchedules(next_wf_exec, s.Logger)
|
||||
Executions.AddSchedules(next_wf_exec, s.Logger)
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ services:
|
||||
oc-schedulerd:
|
||||
environment:
|
||||
- MONGO_DATABASE=DC_myDC
|
||||
- KUBERNETES_SERVICE_HOST=${KUBERNETES_SERVICE_HOST:-193.50.43.14}
|
||||
- KUBE_CA=${KUBE_CA:-LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk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ClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFRc3hXWk9pbnIrcVp4TmFEQjVGMGsvTDF5cE01VHAxOFRaeU92ektJazQKRTFsZWVqUm9STW0zNmhPeVljbnN3d3JoNnhSUnBpMW5RdGhyMzg0S0Z6MlBvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVTBYZkVmYXJsZm8zTWhIL3lmemx6Cnl0OWlqbHN3Q2dZSUtvWkl6ajBFQXdJRFNRQXdSZ0loQUxJL2dNYnNMT3MvUUpJa3U2WHVpRVMwTEE2cEJHMXgKcnBlTnpGdlZOekZsQWlFQW1wdjBubjZqN3M0MVI0QzFNMEpSL0djNE53MHdldlFmZWdEVGF1R2p3cFk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K}
|
||||
- KUBE_TOKEN=${KUBE_TOKEN:-LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSU5ZS1BFb1dhd1NKUzJlRW5oWmlYMk5VZlY1ZlhKV2krSVNnV09TNFE5VTlvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFVUozblJZN0tCNEtUWUx0WnFUMS96VS84a0Z2Sk1lUGhYMm1Vc25pczBiR3FZblkyaVZEeApYVzR2SVhTYjNqcm9iZ1YwSUtDT0twUWs2OHJEbE03ckRBPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=}
|
||||
image: 'oc-schedulerd:latest'
|
||||
ports:
|
||||
- 9001:8080
|
||||
|
9
docker_schedulerd.json
Normal file
9
docker_schedulerd.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"LOKI_URL" : "loki://loki:3100",
|
||||
"MONGO_URL":"mongodb://mongo:27017/",
|
||||
"NATS_URL":"nats://nats:4222",
|
||||
"MONGO_DATABASE":"DC_myDC",
|
||||
"KUBERNETES_SERVICE_HOST" : "193.50.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VFEREJock0zTXRZMnhwWlc1MExXTmhRREUzTWpNeE1USXdNell3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFRc3hXWk9pbnIrcVp4TmFEQjVGMGsvTDF5cE01VHAxOFRaeU92ektJazQKRTFsZWVqUm9STW0zNmhPeVljbnN3d3JoNnhSUnBpMW5RdGhyMzg0S0Z6MlBvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVTBYZkVmYXJsZm8zTWhIL3lmemx6Cnl0OWlqbHN3Q2dZSUtvWkl6ajBFQXdJRFNRQXdSZ0loQUxJL2dNYnNMT3MvUUpJa3U2WHVpRVMwTEE2cEJHMXgKcnBlTnpGdlZOekZsQWlFQW1wdjBubjZqN3M0MVI0QzFNMEpSL0djNE53MHdldlFmZWdEVGF1R2p3cFk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K",
|
||||
"KUBE_TOKEN":"LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSU5ZS1BFb1dhd1NKUzJlRW5oWmlYMk5VZlY1ZlhKV2krSVNnV09TNFE5VTlvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFVUozblJZN0tCNEtUWUx0WnFUMS96VS84a0Z2Sk1lUGhYMm1Vc25pczBiR3FZblkyaVZEeApYVzR2SVhTYjNqcm9iZ1YwSUtDT0twUWs2OHJEbE03ckRBPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo="
|
||||
}
|
59
go.mod
59
go.mod
@ -5,99 +5,50 @@ go 1.22.0
|
||||
toolchain go1.22.5
|
||||
|
||||
require (
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250213085018-271cc2caa026
|
||||
github.com/beego/beego v1.12.12
|
||||
github.com/beego/beego/v2 v2.3.1
|
||||
github.com/goraz/onion v0.1.3
|
||||
github.com/nats-io/nats.go v1.37.0
|
||||
github.com/nwtgck/go-fakelish v0.1.3
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/tidwall/gjson v1.17.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
k8s.io/client-go v0.30.3
|
||||
go.mongodb.org/mongo-driver v1.17.1
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.o-forge.io/core/oc-lib v0.0.0-20250205160221-88b7cfe2fd0f // indirect
|
||||
github.com/Klathmon/StructToMap v0.0.0-20140724123129-3d0229e2dce7 // indirect
|
||||
github.com/antihax/optional v1.0.0 // indirect
|
||||
github.com/aws/aws-sdk-go v1.36.29 // indirect
|
||||
github.com/beego/beego/v2 v2.3.1 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/biter777/countries v1.7.5 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.22.1 // indirect
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/gnostic-models v0.6.8 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/imdario/mergo v0.3.8 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/marcinwyszynski/geopoint v0.0.0-20140302213024-cf2a6f750c5b // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/nats-io/jwt v0.3.2 // indirect
|
||||
github.com/nats-io/nkeys v0.4.7 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/prometheus/client_golang v1.19.0 // indirect
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.48.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
github.com/robfig/cron v1.2.0 // indirect
|
||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/ugorji/go/codec v1.1.7 // indirect
|
||||
github.com/vk496/cron v1.2.0 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.2 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
|
||||
github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
||||
go.mongodb.org/mongo-driver v1.17.1 // indirect
|
||||
golang.org/x/crypto v0.28.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/oauth2 v0.16.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
golang.org/x/term v0.25.0 // indirect
|
||||
golang.org/x/text v0.19.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/protobuf v1.35.1 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
k8s.io/api v0.30.3 // indirect
|
||||
k8s.io/apimachinery v0.30.3 // indirect
|
||||
k8s.io/klog/v2 v2.120.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
|
||||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
|
||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
Copyright 2016 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Note: the example only works with the code within the same release/branch.
|
||||
package k8s
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"path/filepath"
|
||||
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/util/homedir"
|
||||
//
|
||||
// Uncomment to load all auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
//
|
||||
// Or uncomment to load specific auth plugins
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/azure"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
|
||||
// _ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
|
||||
)
|
||||
|
||||
func NewK8SClient() *kubernetes.Clientset {
|
||||
var kubeconfig *string
|
||||
if home := homedir.HomeDir(); home != "" {
|
||||
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
|
||||
} else {
|
||||
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
|
||||
}
|
||||
flag.Parse()
|
||||
|
||||
// use the current context in kubeconfig
|
||||
config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
// create the clientset
|
||||
clientset, err := kubernetes.NewForConfig(config)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
return clientset
|
||||
}
|
5
main.go
5
main.go
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"oc-schedulerd/conf"
|
||||
"oc-schedulerd/daemons"
|
||||
|
||||
@ -10,6 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
o := oclib.GetConfLoader()
|
||||
|
||||
oclib.InitDaemon("oc-schedulerd")
|
||||
oclib.SetConfig(
|
||||
conf.GetConfig().MongoUrl,
|
||||
@ -18,6 +19,8 @@ func main() {
|
||||
conf.GetConfig().LokiUrl,
|
||||
conf.GetConfig().Logs,
|
||||
)
|
||||
conf.GetConfig().Mode = o.GetStringDefault("MODE", "kubernetes")
|
||||
|
||||
sch_mngr := daemons.ScheduleManager{Logger: oclib.GetLogger()}
|
||||
exe_mngr := daemons.ExecutionManager{}
|
||||
|
||||
|
BIN
oc-schedulerd
BIN
oc-schedulerd
Binary file not shown.
Loading…
Reference in New Issue
Block a user