Skip to content

Commit

Permalink
support k8s 1.26
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjunchen committed May 14, 2024
1 parent c2c0533 commit 87cde68
Show file tree
Hide file tree
Showing 54 changed files with 690 additions and 734 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
kubeschedulerscheme "k8s.io/kubernetes/pkg/scheduler/apis/config/scheme"

"github.com/gocrane/crane-scheduler/pkg/plugins/apis/config"
"github.com/gocrane/crane-scheduler/pkg/plugins/apis/config/v1beta2"
"github.com/gocrane/crane-scheduler/pkg/plugins/apis/config/v1beta3"
"github.com/gocrane/crane-scheduler/apis/config"
v1 "github.com/gocrane/crane-scheduler/apis/config/v1"
"github.com/gocrane/crane-scheduler/apis/config/v1beta2"
"github.com/gocrane/crane-scheduler/apis/config/v1beta3"
)

var (
Expand All @@ -26,6 +27,7 @@ func init() {
// AddToScheme builds the kubescheduler scheme using all known versions of the kubescheduler api.
func AddToScheme(scheme *runtime.Scheme) {
utilruntime.Must(config.AddToScheme(scheme))
utilruntime.Must(v1.AddToScheme(scheme))
utilruntime.Must(v1beta2.AddToScheme(scheme))
utilruntime.Must(v1beta3.AddToScheme(scheme))
}
File renamed without changes.
19 changes: 19 additions & 0 deletions apis/config/v1/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package v1

var (
defaultNodeResource = []string{"cpu"}
)

func SetDefaults_DynamicArgs(obj *DynamicArgs) {
if obj.PolicyConfigPath == "" {
obj.PolicyConfigPath = "/etc/kubernetes/dynamic-scheduler-policy.yaml"
}
return
}

func SetDefaults_NodeResourceTopologyMatchArgs(obj *NodeResourceTopologyMatchArgs) {
if len(obj.TopologyAwareResources) == 0 {
obj.TopologyAwareResources = defaultNodeResource
}
return
}
9 changes: 9 additions & 0 deletions apis/config/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=github.com/gocrane/crane-scheduler/apis/config
// +k8s:defaulter-gen=TypeMeta
// +k8s:defaulter-gen-input=github.com/gocrane/crane-scheduler/apis/config/v1

// +groupName=kubescheduler.config.k8s.io

// Package v1 is the v1 version of the API.
package v1 // import "crane.io/scheduler-plugins/apis/config/v1"
36 changes: 36 additions & 0 deletions apis/config/v1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package v1

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
kubeschedulerschemev1 "k8s.io/kube-scheduler/config/v1"
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
)

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: kubeschedulerconfig.GroupName, Version: "v1"}

var (
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
localSchemeBuilder = &kubeschedulerschemev1.SchemeBuilder
// AddToScheme is a global function that registers this API group & version to a scheme
AddToScheme = localSchemeBuilder.AddToScheme
)

// addKnownTypes registers known types to the given scheme
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&DynamicArgs{},
&NodeResourceTopologyMatchArgs{},
)
return nil
}

func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
localSchemeBuilder.Register(RegisterDefaults)
localSchemeBuilder.Register(RegisterConversions)
}
23 changes: 23 additions & 0 deletions apis/config/v1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// DynamicArgs is the args struction of Dynamic scheduler plugin.
type DynamicArgs struct {
metav1.TypeMeta `json:",inline"`
// PolicyConfigPath specified the path of policy config.
PolicyConfigPath string `json:"policyConfigPath"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// NodeResourceTopologyMatchArgs holds arguments used to configure the NodeResourceTopologyMatch plugin.
type NodeResourceTopologyMatchArgs struct {
metav1.TypeMeta `json:",inline"`
// TopologyAwareResources represents the resource names of topology.
TopologyAwareResources []string `json:"topologyAwareResources,omitempty"`
}
84 changes: 84 additions & 0 deletions apis/config/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions apis/config/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions apis/config/v1/zz_generated.defaults.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=github.com/gocrane/crane-scheduler/pkg/plugins/apis/config
// +k8s:conversion-gen=github.com/gocrane/crane-scheduler/apis/config
// +k8s:defaulter-gen=TypeMeta
// +k8s:defaulter-gen-input=github.com/gocrane/crane-scheduler/pkg/plugins/apis/config/v1beta2
// +k8s:defaulter-gen-input=github.com/gocrane/crane-scheduler/apis/config/v1beta2

// +groupName=kubescheduler.config.k8s.io

Expand Down
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=github.com/gocrane/crane-scheduler/pkg/plugins/apis/config
// +k8s:conversion-gen=github.com/gocrane/crane-scheduler/apis/config
// +k8s:defaulter-gen=TypeMeta
// +k8s:defaulter-gen-input=github.com/gocrane/crane-scheduler/pkg/plugins/apis/config/v1beta3
// +k8s:defaulter-gen-input=github.com/gocrane/crane-scheduler/apis/config/v1beta3

// +groupName=kubescheduler.config.k8s.io

Expand Down
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package scheme

import (
dynamicpolicy "github.com/gocrane/crane-scheduler/pkg/plugins/apis/policy"
dynamicpolicyv1alpha1 "github.com/gocrane/crane-scheduler/pkg/plugins/apis/policy/v1alpha1"
dynamicpolicy "github.com/gocrane/crane-scheduler/apis/policy"
dynamicpolicyv1alpha1 "github.com/gocrane/crane-scheduler/apis/policy/v1alpha1"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=github.com/gocrane/crane-scheduler/pkg/plugins/apis/policy
// +k8s:conversion-gen=github.com/gocrane/crane-scheduler/apis/policy

package v1alpha1 // import "crane.io/crane-scheduler/pkg/plugins/apis/policy/v1alpha1"
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 87cde68

Please sign in to comment.