...
1
16
17 package v1
18
19 import (
20 "fmt"
21 "k8s.io/api/scheduling/v1"
22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23 "k8s.io/kubernetes/pkg/apis/scheduling"
24 )
25
26
27
28
29 var systemPriorityClasses = []*v1.PriorityClass{
30 {
31 ObjectMeta: metav1.ObjectMeta{
32 Name: scheduling.SystemNodeCritical,
33 },
34 Value: scheduling.SystemCriticalPriority + 1000,
35 Description: "Used for system critical pods that must not be moved from their current node.",
36 },
37 {
38 ObjectMeta: metav1.ObjectMeta{
39 Name: scheduling.SystemClusterCritical,
40 },
41 Value: scheduling.SystemCriticalPriority,
42 Description: "Used for system critical pods that must run in the cluster, but can be moved to another node if necessary.",
43 },
44 }
45
46
47
48 func SystemPriorityClasses() []*v1.PriorityClass {
49 return systemPriorityClasses
50 }
51
52
53
54 func IsKnownSystemPriorityClass(name string, value int32, globalDefault bool) (bool, error) {
55 for _, spc := range SystemPriorityClasses() {
56 if spc.Name == name {
57 if spc.Value != value {
58 return false, fmt.Errorf("value of %v PriorityClass must be %v", spc.Name, spc.Value)
59 }
60 if spc.GlobalDefault != globalDefault {
61 return false, fmt.Errorf("globalDefault of %v PriorityClass must be %v", spc.Name, spc.GlobalDefault)
62 }
63 return true, nil
64 }
65 }
66 return false, fmt.Errorf("%v is not a known system priority class", name)
67 }
68
View as plain text