mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #9038 from HaiyangDING/patch-1
Example for policy config file for scheduler
This commit is contained in:
commit
277e8aa0ab
@ -31,6 +31,8 @@ import (
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/capabilities"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/yaml"
|
||||
schedulerapi "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/api"
|
||||
schedulerapilatest "github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/api/latest"
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
@ -198,8 +200,9 @@ func TestExampleObjectSchemas(t *testing.T) {
|
||||
"http-liveness": &api.Pod{},
|
||||
},
|
||||
"../examples": {
|
||||
"pod": &api.Pod{},
|
||||
"replication": &api.ReplicationController{},
|
||||
"pod": &api.Pod{},
|
||||
"replication": &api.ReplicationController{},
|
||||
"scheduler-policy-config": &schedulerapi.Policy{},
|
||||
},
|
||||
"../examples/rbd/secret": {
|
||||
"ceph-secret": &api.Secret{},
|
||||
@ -336,12 +339,20 @@ func TestExampleObjectSchemas(t *testing.T) {
|
||||
t.Logf("skipping : %s/%s\n", path, name)
|
||||
return
|
||||
}
|
||||
if err := latest.Codec.DecodeInto(data, expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
if errors := validateObject(expectedType); len(errors) > 0 {
|
||||
t.Errorf("%s did not validate correctly: %v", path, errors)
|
||||
if name == "scheduler-policy-config" {
|
||||
if err := schedulerapilatest.Codec.DecodeInto(data, expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
//TODO: Add validate method for &schedulerapi.Policy
|
||||
} else {
|
||||
if err := latest.Codec.DecodeInto(data, expectedType); err != nil {
|
||||
t.Errorf("%s did not decode correctly: %v\n%s", path, err, string(data))
|
||||
return
|
||||
}
|
||||
if errors := validateObject(expectedType); len(errors) > 0 {
|
||||
t.Errorf("%s did not validate correctly: %v", path, errors)
|
||||
}
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
|
17
examples/scheduler-policy-config.json
Normal file
17
examples/scheduler-policy-config.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"kind" : "Policy",
|
||||
"apiVersion" : "v1",
|
||||
"predicates" : [
|
||||
{"name" : "PodFitsPorts"},
|
||||
{"name" : "PodFitsResources"},
|
||||
{"name" : "NoDiskConflict"},
|
||||
{"name" : "MatchNodeSelector"},
|
||||
{"name" : "HostName"}
|
||||
],
|
||||
"priorities" : [
|
||||
{"name" : "LeastRequestedPriority", "weight" : 1},
|
||||
{"name" : "BalancedResourceAllocation", "weight" : 1},
|
||||
{"name" : "ServiceSpreadingPriority", "weight" : 1},
|
||||
{"name" : "EqualPriority", "weight" : 1}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user