-
Notifications
You must be signed in to change notification settings - Fork 451
/
scheduler_config.go
64 lines (52 loc) · 2.45 KB
/
scheduler_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Package k8s provides resources which interface with Kubernetes.
package k8s
import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/resource/meta"
"github.com/cosi-project/runtime/pkg/resource/protobuf"
"github.com/cosi-project/runtime/pkg/resource/typed"
"github.com/siderolabs/talos/pkg/machinery/proto"
)
// SchedulerConfigType is type of SchedulerConfig resource.
const SchedulerConfigType = resource.Type("SchedulerConfigs.kubernetes.talos.dev")
// SchedulerConfigID is a singleton resource ID for SchedulerConfig.
const SchedulerConfigID = resource.ID(SchedulerID)
// SchedulerConfig represents configuration for kube-scheduler.
type SchedulerConfig = typed.Resource[SchedulerConfigSpec, SchedulerConfigExtension]
// SchedulerConfigSpec is configuration for kube-scheduler.
//
//gotagsrewrite:gen
type SchedulerConfigSpec struct {
Enabled bool `yaml:"enabled" protobuf:"1"`
Image string `yaml:"image" protobuf:"2"`
ExtraArgs map[string]string `yaml:"extraArgs" protobuf:"3"`
ExtraVolumes []ExtraVolume `yaml:"extraVolumes" protobuf:"4"`
EnvironmentVariables map[string]string `yaml:"environmentVariables" protobuf:"5"`
Resources Resources `yaml:"resources" protobuf:"6"`
Config map[string]any `yaml:"config" protobuf:"7"`
}
// NewSchedulerConfig returns new SchedulerConfig resource.
func NewSchedulerConfig() *SchedulerConfig {
return typed.NewResource[SchedulerConfigSpec, SchedulerConfigExtension](
resource.NewMetadata(ControlPlaneNamespaceName, SchedulerConfigType, SchedulerConfigID, resource.VersionUndefined),
SchedulerConfigSpec{})
}
// SchedulerConfigExtension defines SchedulerConfig resource definition.
type SchedulerConfigExtension struct{}
// ResourceDefinition implements meta.ResourceDefinitionProvider interface.
func (SchedulerConfigExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
return meta.ResourceDefinitionSpec{
Type: SchedulerConfigType,
DefaultNamespace: ControlPlaneNamespaceName,
}
}
func init() {
proto.RegisterDefaultTypes()
err := protobuf.RegisterDynamic[SchedulerConfigSpec](SchedulerConfigType, &SchedulerConfig{})
if err != nil {
panic(err)
}
}