Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade version to support k8s 1.26 #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
ARG PKGNAME

# Build the manager binary
FROM golang:1.17.2-alpine as builder
FROM golang:1.19-alpine3.18 as builder

ARG LDFLAGS
ARG PKGNAME

WORKDIR /go/src/github.com/gocrane/crane-scheduler

# Add build deps
RUN apk add build-base

# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
Expand All @@ -20,12 +15,13 @@ RUN unset https_proxy HTTPS_PROXY HTTP_PROXY http_proxy && go mod download

# Copy the go source
COPY pkg pkg/
COPY apis apis/
COPY cmd cmd/

# Build
RUN go build -ldflags="${LDFLAGS}" -a -o ${PKGNAME} /go/src/github.com/gocrane/crane-scheduler/cmd/${PKGNAME}/main.go
RUN CGO_ENABLED=0 go build -ldflags="${LDFLAGS}" -a -o ${PKGNAME} /go/src/github.com/gocrane/crane-scheduler/cmd/${PKGNAME}/main.go

FROM alpine:3.13.5
FROM alpine:3.18
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN unset https_proxy HTTPS_PROXY HTTP_PROXY http_proxy && apk add -U tzdata

Expand Down
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.

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.

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

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.

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.
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"

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

Loading
Loading