add deployment and schedule impl
Some checks failed
Lint / Run on Ubuntu (push) Has been cancelled
E2E Tests / Run on Ubuntu (push) Has been cancelled
Tests / Run on Ubuntu (push) Has been cancelled

This commit is contained in:
baschno
2026-01-13 21:01:29 +01:00
parent 32682899a5
commit bf3948713d
2 changed files with 248 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package controller
import (
"context"
"time"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log"
schedulev1 "github.com/baschno/tdset-operator/api/v1"
)
func (r *TDSetReconciler) GetExpectedReplica(ctx context.Context, req ctrl.Request, tdSet *schedulev1.TDSet) (int32, error) {
log := log.FromContext(ctx)
if tdSet.Spec.SchedulingConfig != nil && len(tdSet.Spec.SchedulingConfig) != 0 {
now := time.Now()
hour := now.Hour()
log.Info("current server", "hour", hour, "time", now)
for _, config := range tdSet.Spec.SchedulingConfig {
if hour >= config.StartTime && hour < config.EndTime {
return int32(config.Replica), nil
}
}
}
return tdSet.Spec.DefaultReplica, nil
}