Skip to content

Commit

Permalink
Add scaffolding for k8s scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
Mtze committed May 24, 2024
1 parent 33a3ba4 commit 7a0f646
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 12 deletions.
23 changes: 20 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,38 @@
}
},
{
"name": "HadesScheduler",
"name": "HadesScheduler (docker)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/HadesScheduler",
"preLaunchTask": "Start Redis Container", // This will start the Redis container before launching the scheduler - defined in .vscode/tasks.json
"env": {
"DEBUG": "true",
"HADES_EXECUTOR": "docker"
}
}
{
"name": "HadesScheduler (k8s)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/HadesScheduler",
"preLaunchTask": "Start Redis Container", // This will start the Redis container before launching the scheduler - defined in .vscode/tasks.json
"env": {
"DEBUG": "true",
"HADES_EXECUTOR": "k8s"
}
}
],
"compounds": [
{
"name": "HadesAPI and HadesScheduler",
"configurations": ["HadesAPI", "HadesScheduler"]
"name": "HadesAPI and HadesScheduler (docker)",
"configurations": ["HadesAPI", "HadesScheduler (docker)"]
}
{
"name": "HadesAPI and HadesScheduler (k8s)",
"configurations": ["HadesAPI", "HadesScheduler (k8s)"]
}
]
}
28 changes: 28 additions & 0 deletions HadesScheduler/k8s/k8s.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package k8s

import (
"context"

"github.com/ls1intum/hades/shared/payload"
"github.com/ls1intum/hades/shared/utils"
log "github.com/sirupsen/logrus"
)

type Scheduler struct{}

type K8sConfig struct{}

func NewK8sScheduler() Scheduler {
log.Debug("Initializing Kubernetes scheduler")

var k8sCfg K8sConfig
utils.LoadConfig(&k8sCfg)
log.Debugf("Kubernetes config: %+v", k8sCfg)

return Scheduler{}
}

func (k Scheduler) ScheduleJob(ctx context.Context, job payload.QueuePayload) error {
log.Debug("Scheduling job in Kubernetes")
return nil
}
8 changes: 4 additions & 4 deletions HadesScheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/hibiken/asynq"
"github.com/ls1intum/hades/hadesScheduler/docker"
"github.com/ls1intum/hades/hadesScheduler/k8s"
"github.com/ls1intum/hades/shared/payload"
"github.com/ls1intum/hades/shared/utils"

Expand Down Expand Up @@ -41,10 +42,9 @@ func main() {

var scheduler JobScheduler
switch executorCfg.Executor {
// case "k8s":
// log.Info("Started HadesScheduler in Kubernetes mode")
// kube.Init()
// scheduler = kube.Scheduler{}
case "k8s":
log.Info("Started HadesScheduler in Kubernetes mode")
scheduler = k8s.NewK8sScheduler()
case "docker":
log.Info("Started HadesScheduler in Docker mode")
scheduler = docker.NewDockerScheduler()
Expand Down
5 changes: 4 additions & 1 deletion go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ github.com/containerd/go-cni v1.1.9/go.mod h1:XYrZJ1d5W6E2VOvjffL3IZq0Dz6bsVlERH
github.com/containerd/go-runc v1.0.0/go.mod h1:cNU0ZbCgCQVZK4lgG3P+9tn9/PaJNmoDXPpoJhDR+Ok=
github.com/containerd/imgcrypt v1.1.7/go.mod h1:FD8gqIcX5aTotCtOmjeCsi3A1dHmTZpnMISGKSczt4k=
github.com/containerd/nri v0.4.0/go.mod h1:Zw9q2lP16sdg0zYybemZ9yTDy8g7fPCIB3KXOGlggXI=
github.com/containerd/nri v0.6.0/go.mod h1:F7OZfO4QTPqw5r87aq+syZJwiVvRYLIlHZiZDBV1W3A=
github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o=
github.com/containerd/ttrpc v1.2.2/go.mod h1:sIT6l32Ph/H9cvnJsfXM5drIVzTr5A2flTf1G5tYZak=
github.com/containerd/ttrpc v1.2.3/go.mod h1:ieWsXucbb8Mj9PH0rXCw1i8IunRbbAiDkpXkbfflWBM=
github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s=
github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0=
github.com/containerd/zfs v1.1.0/go.mod h1:oZF9wBnrnQjpWLaPKEinrx3TQ9a+W/RJO7Zb41d8YLE=
Expand Down Expand Up @@ -247,7 +249,6 @@ github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980/go.mod h1:AO3tvPzVZ/ayst6UlUKUv6rcPQInYe3IknH3jYhAKu8=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/tchap/go-patricia/v2 v2.3.1/go.mod h1:VZRHKAb53DLaG+nA9EaYYiaEx6YztwDlLElMsnSHD4k=
github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8=
Expand Down Expand Up @@ -320,3 +321,5 @@ k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5/go.mod h1:OLgZIPagt7ERELqWJFomSt
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
tags.cncf.io/container-device-interface v0.6.2/go.mod h1:Shusyhjs1A5Na/kqPVLL0KqnHQHuunol9LFeUNkuGVE=
tags.cncf.io/container-device-interface/specs-go v0.6.0/go.mod h1:hMAwAbMZyBLdmYqWgYcKH0F/yctNpV3P35f+/088A80=
4 changes: 0 additions & 4 deletions shared/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ type RedisConfig struct {
TLS_Enabled bool `env:"REDIS_TLS_ENABLED" envDefault:"false"`
}

type K8sConfig struct {
HadesCInamespace string `env:"HADES_CI_NAMESPACE" envDefault:"hades-ci"`
}

type ExecutorConfig struct {
Executor string `env:"HADES_EXECUTOR,notEmpty" envDefault:"docker"`
}
Expand Down

0 comments on commit 7a0f646

Please sign in to comment.