1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 21:31:18 +01:00

Implement various pods implementation.

This commit is contained in:
Avesh Agarwal
2017-07-31 22:27:46 -04:00
parent 0f3704e8ea
commit 4ad64d2ad4

View File

@@ -20,9 +20,14 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1/helper/qos"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
)
const (
criticalPodAnnotation = "scheduler.alpha.kubernetes.io/critical-pod"
)
func ListPodsOnANode(client clientset.Interface, node *v1.Node) ([]*v1.Pod, error) {
podList, err := client.CoreV1().Pods(v1.NamespaceAll).List(
metav1.ListOptions{FieldSelector: fields.SelectorFromSet(fields.Set{"spec.nodeName": node.Name}).String()})
@@ -37,3 +42,20 @@ func ListPodsOnANode(client clientset.Interface, node *v1.Node) ([]*v1.Pod, erro
return pods, nil
}
func IsCriticalPod(pod *v1.Pod) bool {
_, found := pod.ObjectMeta.Annotations[criticalPodAnnotation]
return found
}
func IsBestEffortPod(pod *v1.Pod) bool {
return qos.GetPodQOS(pod) == v1.PodQOSBestEffort
}
func IsBurstablePod(pod *v1.Pod) bool {
return qos.GetPodQOS(pod) == v1.PodQOSBurstable
}
func IsGuaranteedPod(pod *v1.Pod) bool {
return qos.GetPodQOS(pod) == v1.PodQOSGuaranteed
}