Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7df86e1e
Commit
7df86e1e
authored
Feb 02, 2016
by
Mike Danese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create external api for scheduler config
move defaulting into external pacakge
parent
8d8de2ef
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
12 deletions
+96
-12
register.go
pkg/apis/componentconfig/register.go
+3
-1
types.go
pkg/apis/componentconfig/types.go
+2
-0
defaults.go
pkg/apis/componentconfig/v1alpha1/defaults.go
+34
-0
register.go
pkg/apis/componentconfig/v1alpha1/register.go
+3
-1
types.go
pkg/apis/componentconfig/v1alpha1/types.go
+50
-0
options.go
plugin/cmd/kube-scheduler/app/options/options.go
+4
-10
No files found.
pkg/apis/componentconfig/register.go
View file @
7df86e1e
...
@@ -45,7 +45,9 @@ func addKnownTypes(scheme *runtime.Scheme) {
...
@@ -45,7 +45,9 @@ func addKnownTypes(scheme *runtime.Scheme) {
// TODO this will get cleaned up with the scheme types are fixed
// TODO this will get cleaned up with the scheme types are fixed
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
KubeProxyConfiguration
{},
&
KubeProxyConfiguration
{},
&
KubeSchedulerConfiguration
{},
)
)
}
}
func
(
obj
*
KubeProxyConfiguration
)
GetObjectKind
()
unversioned
.
ObjectKind
{
return
&
obj
.
TypeMeta
}
func
(
obj
*
KubeProxyConfiguration
)
GetObjectKind
()
unversioned
.
ObjectKind
{
return
&
obj
.
TypeMeta
}
func
(
obj
*
KubeSchedulerConfiguration
)
GetObjectKind
()
unversioned
.
ObjectKind
{
return
&
obj
.
TypeMeta
}
pkg/apis/componentconfig/types.go
View file @
7df86e1e
...
@@ -291,6 +291,8 @@ type KubeletConfiguration struct {
...
@@ -291,6 +291,8 @@ type KubeletConfiguration struct {
}
}
type
KubeSchedulerConfiguration
struct
{
type
KubeSchedulerConfiguration
struct
{
unversioned
.
TypeMeta
// port is the port that the scheduler's http service runs on.
// port is the port that the scheduler's http service runs on.
Port
int
`json:"port"`
Port
int
`json:"port"`
// address is the IP address to serve on.
// address is the IP address to serve on.
...
...
pkg/apis/componentconfig/v1alpha1/defaults.go
View file @
7df86e1e
...
@@ -19,8 +19,10 @@ package v1alpha1
...
@@ -19,8 +19,10 @@ package v1alpha1
import
(
import
(
"time"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/kubelet/qos"
"k8s.io/kubernetes/pkg/kubelet/qos"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
)
)
...
@@ -44,5 +46,37 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
...
@@ -44,5 +46,37 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
obj
.
IPTablesSyncPeriod
=
unversioned
.
Duration
{
5
*
time
.
Second
}
obj
.
IPTablesSyncPeriod
=
unversioned
.
Duration
{
5
*
time
.
Second
}
}
}
},
},
func
(
obj
*
KubeSchedulerConfiguration
)
{
if
obj
.
Port
==
0
{
obj
.
Port
=
ports
.
SchedulerPort
}
if
obj
.
Address
==
""
{
obj
.
Address
=
"0.0.0.0"
}
if
obj
.
AlgorithmProvider
==
""
{
obj
.
AlgorithmProvider
=
"DefaultProvider"
}
if
obj
.
KubeAPIQPS
==
0
{
obj
.
KubeAPIQPS
=
50.0
}
if
obj
.
KubeAPIBurst
==
0
{
obj
.
KubeAPIBurst
=
100
}
if
obj
.
SchedulerName
==
""
{
obj
.
SchedulerName
=
api
.
DefaultSchedulerName
}
},
func
(
obj
*
LeaderElectionConfiguration
)
{
zero
:=
unversioned
.
Duration
{}
if
obj
.
LeaseDuration
==
zero
{
obj
.
LeaseDuration
=
unversioned
.
Duration
{
15
*
time
.
Second
}
}
if
obj
.
RenewDeadline
==
zero
{
obj
.
RenewDeadline
=
unversioned
.
Duration
{
10
*
time
.
Second
}
}
if
obj
.
RetryPeriod
==
zero
{
obj
.
RetryPeriod
=
unversioned
.
Duration
{
2
*
time
.
Second
}
}
},
)
)
}
}
pkg/apis/componentconfig/v1alpha1/register.go
View file @
7df86e1e
...
@@ -35,7 +35,9 @@ func AddToScheme(scheme *runtime.Scheme) {
...
@@ -35,7 +35,9 @@ func AddToScheme(scheme *runtime.Scheme) {
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
{
func
addKnownTypes
(
scheme
*
runtime
.
Scheme
)
{
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
KubeProxyConfiguration
{},
&
KubeProxyConfiguration
{},
&
KubeSchedulerConfiguration
{},
)
)
}
}
func
(
obj
*
KubeProxyConfiguration
)
GetObjectKind
()
unversioned
.
ObjectKind
{
return
&
obj
.
TypeMeta
}
func
(
obj
*
KubeProxyConfiguration
)
GetObjectKind
()
unversioned
.
ObjectKind
{
return
&
obj
.
TypeMeta
}
func
(
obj
*
KubeSchedulerConfiguration
)
GetObjectKind
()
unversioned
.
ObjectKind
{
return
&
obj
.
TypeMeta
}
pkg/apis/componentconfig/v1alpha1/types.go
View file @
7df86e1e
...
@@ -74,3 +74,53 @@ const (
...
@@ -74,3 +74,53 @@ const (
ProxyModeUserspace
ProxyMode
=
"userspace"
ProxyModeUserspace
ProxyMode
=
"userspace"
ProxyModeIPTables
ProxyMode
=
"iptables"
ProxyModeIPTables
ProxyMode
=
"iptables"
)
)
type
KubeSchedulerConfiguration
struct
{
unversioned
.
TypeMeta
// port is the port that the scheduler's http service runs on.
Port
int
`json:"port"`
// address is the IP address to serve on.
Address
string
`json:"address"`
// algorithmProvider is the scheduling algorithm provider to use.
AlgorithmProvider
string
`json:"algorithmProvider"`
// policyConfigFile is the filepath to the scheduler policy configuration.
PolicyConfigFile
string
`json:"policyConfigFile"`
// enableProfiling enables profiling via web interface.
EnableProfiling
*
bool
`json:"enableProfiling"`
// kubeAPIQPS is the QPS to use while talking with kubernetes apiserver.
KubeAPIQPS
float32
`json:"kubeAPIQPS"`
// kubeAPIBurst is the QPS burst to use while talking with kubernetes apiserver.
KubeAPIBurst
int
`json:"kubeAPIBurst"`
// schedulerName is name of the scheduler, used to select which pods
// will be processed by this scheduler, based on pod's annotation with
// key 'scheduler.alpha.kubernetes.io/name'.
SchedulerName
string
`json:"schedulerName"`
// leaderElection defines the configuration of leader election client.
LeaderElection
LeaderElectionConfiguration
`json:"leaderElection"`
}
// LeaderElectionConfiguration defines the configuration of leader election
// clients for components that can run with leader election enabled.
type
LeaderElectionConfiguration
struct
{
// leaderElect enables a leader election client to gain leadership
// before executing the main loop. Enable this when running replicated
// components for high availability.
LeaderElect
*
bool
`json:"leaderElect"`
// leaseDuration is the duration that non-leader candidates will wait
// after observing a leadership renewal until attempting to acquire
// leadership of a led but unrenewed leader slot. This is effectively the
// maximum duration that a leader can be stopped before it is replaced
// by another candidate. This is only applicable if leader election is
// enabled.
LeaseDuration
unversioned
.
Duration
`json:"leaseDuration"`
// renewDeadline is the interval between attempts by the acting master to
// renew a leadership slot before it stops leading. This must be less
// than or equal to the lease duration. This is only applicable if leader
// election is enabled.
RenewDeadline
unversioned
.
Duration
`json:"renewDeadline"`
// retryPeriod is the duration the clients should wait between attempting
// acquisition and renewal of a leadership. This is only applicable if
// leader election is enabled.
RetryPeriod
unversioned
.
Duration
`json:"retryPeriod"`
}
plugin/cmd/kube-scheduler/app/options/options.go
View file @
7df86e1e
...
@@ -20,8 +20,8 @@ package options
...
@@ -20,8 +20,8 @@ package options
import
(
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/componentconfig"
"k8s.io/kubernetes/pkg/apis/componentconfig"
"k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
"k8s.io/kubernetes/pkg/client/leaderelection"
"k8s.io/kubernetes/pkg/client/leaderelection"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/plugin/pkg/scheduler/factory"
"k8s.io/kubernetes/plugin/pkg/scheduler/factory"
"github.com/spf13/pflag"
"github.com/spf13/pflag"
...
@@ -40,16 +40,10 @@ type SchedulerServer struct {
...
@@ -40,16 +40,10 @@ type SchedulerServer struct {
// NewSchedulerServer creates a new SchedulerServer with default parameters
// NewSchedulerServer creates a new SchedulerServer with default parameters
func
NewSchedulerServer
()
*
SchedulerServer
{
func
NewSchedulerServer
()
*
SchedulerServer
{
config
:=
componentconfig
.
KubeSchedulerConfiguration
{}
api
.
Scheme
.
Convert
(
&
v1alpha1
.
KubeSchedulerConfiguration
{},
&
config
)
s
:=
SchedulerServer
{
s
:=
SchedulerServer
{
KubeSchedulerConfiguration
:
componentconfig
.
KubeSchedulerConfiguration
{
KubeSchedulerConfiguration
:
config
,
Port
:
ports
.
SchedulerPort
,
Address
:
"0.0.0.0"
,
AlgorithmProvider
:
factory
.
DefaultProvider
,
KubeAPIQPS
:
50.0
,
KubeAPIBurst
:
100
,
SchedulerName
:
api
.
DefaultSchedulerName
,
LeaderElection
:
leaderelection
.
DefaultLeaderElectionConfiguration
(),
},
}
}
return
&
s
return
&
s
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment