Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion cmd/binder/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,29 @@ func New(options *Options, config *rest.Config) (*App, error) {
}
}

var podSecurityContext *corev1.PodSecurityContext
if options.ResourceReservationPodSecurityContextJSON != "" {
podSecurityContext = &corev1.PodSecurityContext{}
if err := json.Unmarshal([]byte(options.ResourceReservationPodSecurityContextJSON), podSecurityContext); err != nil {
setupLog.Error(err, "failed to unmarshal resource reservation pod security context")
return nil, fmt.Errorf("failed to unmarshal resource reservation pod security context: %w", err)
}
}

var containerSecurityContext *corev1.SecurityContext
if options.ResourceReservationContainerSecurityJSON != "" {
containerSecurityContext = &corev1.SecurityContext{}
if err := json.Unmarshal([]byte(options.ResourceReservationContainerSecurityJSON), containerSecurityContext); err != nil {
setupLog.Error(err, "failed to unmarshal resource reservation container security context")
return nil, fmt.Errorf("failed to unmarshal resource reservation container security context: %w", err)
}
}

rrs := resourcereservation.NewService(options.FakeGPUNodes, clientWithWatch, options.ResourceReservationPodImage,
time.Duration(options.ResourceReservationAllocationTimeout)*time.Second,
options.ResourceReservationNamespace, options.ResourceReservationServiceAccount,
options.ResourceReservationAppLabel, options.ScalingPodNamespace, options.RuntimeClassName,
podResources)
podResources, podSecurityContext, containerSecurityContext)

reconcilerParams := &controllers.ReconcilerParams{
MaxConcurrentReconciles: options.MaxConcurrentReconciles,
Expand Down
48 changes: 28 additions & 20 deletions cmd/binder/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@ import (
)

type Options struct {
SchedulerName string
ResourceReservationNamespace string
ResourceReservationServiceAccount string
ResourceReservationPodImage string
ResourceReservationAppLabel string
ResourceReservationAllocationTimeout int
ResourceReservationPodResourcesJSON string
ScalingPodNamespace string
QPS float64
Burst int
MaxConcurrentReconciles int
RateLimiterBaseDelaySeconds int
RateLimiterMaxDelaySeconds int
EnableLeaderElection bool
MetricsAddr string
ProbeAddr string
FakeGPUNodes bool
GpuCdiEnabled bool
VolumeBindingTimeoutSeconds int
RuntimeClassName string
SchedulerName string
ResourceReservationNamespace string
ResourceReservationServiceAccount string
ResourceReservationPodImage string
ResourceReservationAppLabel string
ResourceReservationAllocationTimeout int
ResourceReservationPodResourcesJSON string
ResourceReservationPodSecurityContextJSON string
ResourceReservationContainerSecurityJSON string
ScalingPodNamespace string
QPS float64
Burst int
MaxConcurrentReconciles int
RateLimiterBaseDelaySeconds int
RateLimiterMaxDelaySeconds int
EnableLeaderElection bool
MetricsAddr string
ProbeAddr string
FakeGPUNodes bool
GpuCdiEnabled bool
VolumeBindingTimeoutSeconds int
RuntimeClassName string
}

func InitOptions(fs *pflag.FlagSet) *Options {
Expand Down Expand Up @@ -61,6 +63,12 @@ func InitOptions(fs *pflag.FlagSet) *Options {
fs.StringVar(&options.ResourceReservationPodResourcesJSON,
"resource-reservation-pod-resources", "",
"JSON-serialized ResourceRequirements for GPU reservation pods (optional, empty means not set)")
fs.StringVar(&options.ResourceReservationPodSecurityContextJSON,
"resource-reservation-pod-security-context", "",
"JSON-serialized PodSecurityContext for GPU reservation pods")
fs.StringVar(&options.ResourceReservationContainerSecurityJSON,
"resource-reservation-container-security-context", "",
"JSON-serialized SecurityContext for GPU reservation pod containers")
fs.StringVar(&options.ScalingPodNamespace,
"scale-adjust-namespace", constants.DefaultScaleAdjustName,
"Scaling pods namespace")
Expand Down
Loading
Loading