Documentation ¶
Index ¶
- Constants
- Variables
- func GetAppName(podLabels map[string]string, labelList []string) string
- func MergeInt32(a, b int32) int64
- func MergeScores(scoresPC, scoresRT framework.NodeScoreList, weightPC, weightRT int) framework.NodeScoreList
- func New(_ context.Context, obj runtime.Object, fh framework.Handle) (framework.Plugin, error)
- func NormalizeValues2Scores(scores framework.NodeScoreList, baseScore int64, replaceMap map[int64]int64)
- func PodCPURequestOrLimit(pod *corev1.Pod) (v float64)
- func SplitInt64(v int64) (int32, int32)
- type MinimizePower
- func (*MinimizePower) Name() string
- func (pl *MinimizePower) NormalizeScore(_ context.Context, _ *framework.CycleState, pod *corev1.Pod, ...) *framework.Status
- func (pl *MinimizePower) PreFilter(ctx context.Context, state *framework.CycleState, pod *corev1.Pod) (*framework.PreFilterResult, *framework.Status)
- func (pl *MinimizePower) PreFilterExtensions() framework.PreFilterExtensions
- func (pl *MinimizePower) Score(ctx context.Context, state *framework.CycleState, pod *corev1.Pod, ...) (int64, *framework.Status)
- func (pl *MinimizePower) ScoreExtensions() framework.ScoreExtensions
- func (pl *MinimizePower) ScorePowerConsumption(ctx context.Context, _ *framework.CycleState, pod *corev1.Pod, nodeName string) (int64, *framework.Status)
- func (pl *MinimizePower) ScoreResponseTime(ctx context.Context, _ *framework.CycleState, pod *corev1.Pod, nodeName string) (int64, *framework.Status)
- type MinimizePowerArgs
Constants ¶
const ( AnnotationWeightPowerConsumption = "wao.bitmedia.co.jp/weight-power-consumption" AnnotationWeightResponseTime = "wao.bitmedia.co.jp/weight-response-time" LabelAppName = "wao.bitmedia.co.jp/app" )
const ( DefaultMetricsCacheTTL = 30 * time.Second DefaultPredictorCacheTTL = 30 * time.Minute DefaultPodUsageAssumption float64 = 0.5 DefaultCPUUsageFormat = CPUUsageFormatRaw )
const ( CPUUsageFormatRaw string = "Raw" CPUUsageFormatPercent string = "Percent" )
Variables ¶
var ( Name = "MinimizePower" ReasonResourceRequest = "at least one container in the pod must have a requests.cpu or limits.cpu set" )
var ( SchemeGroupVersionV1Internal = schema.GroupVersion{Group: schedconfig.GroupName, Version: runtime.APIVersionInternal} SchemeGroupVersionV1B2 = schema.GroupVersion{Group: schedconfig.GroupName, Version: "v1beta2"} SchemeGroupVersionV1B3 = schema.GroupVersion{Group: schedconfig.GroupName, Version: "v1beta3"} SchemeGroupVersionV1 = schema.GroupVersion{Group: schedconfig.GroupName, Version: "v1"} )
register all kubescheduler.config.k8s.io APIs
var (
AddToScheme = localSchemeBuilder.AddToScheme
)
var ( // LabelsAppName is the list of labels that are used to identify the application name, // in order of preference (LabelsAppName[0] has the highest preference). LabelsAppName = []string{ LabelAppName, "app.kubernetes.io/name", "app", } )
var ( // ScoreBase is the base score for all nodes. // This is the lowest score except for special scores (will be replaced to 0,1,...,<ScoreBase) ScoreBase int64 = 20 )
var ( // ScoreReplaceMap are scores that have special meanings. // NormalizeScore will replace them with the mapped values (should be less than ScoreBase). ScoreReplaceMap = map[int64]int64{ ScoreError: 0, ScoreMax: 1, } )
Functions ¶
func GetAppName ¶
GetAppName returns the application name from the pod labels, using the list of labels in order of preference. If no label is found, an empty string is returned.
func MergeInt32 ¶
func MergeScores ¶
func MergeScores(scoresPC, scoresRT framework.NodeScoreList, weightPC, weightRT int) framework.NodeScoreList
func NormalizeValues2Scores ¶
func NormalizeValues2Scores(scores framework.NodeScoreList, baseScore int64, replaceMap map[int64]int64)
func PodCPURequestOrLimit ¶
func SplitInt64 ¶
Types ¶
type MinimizePower ¶
type MinimizePower struct {
// contains filtered or unexported fields
}
func (*MinimizePower) Name ¶
func (*MinimizePower) Name() string
Name returns name of the plugin. It is used in logs, etc.
func (*MinimizePower) NormalizeScore ¶
func (pl *MinimizePower) NormalizeScore(_ context.Context, _ *framework.CycleState, pod *corev1.Pod, scores framework.NodeScoreList) *framework.Status
func (*MinimizePower) PreFilter ¶
func (pl *MinimizePower) PreFilter(ctx context.Context, state *framework.CycleState, pod *corev1.Pod) (*framework.PreFilterResult, *framework.Status)
PreFilter rejects a pod if it does not have at least one container that has a CPU request or limit set.
func (*MinimizePower) PreFilterExtensions ¶
func (pl *MinimizePower) PreFilterExtensions() framework.PreFilterExtensions
PreFilterExtensions returns nil as this plugin does not have PreFilterExtensions.
func (*MinimizePower) Score ¶
func (pl *MinimizePower) Score(ctx context.Context, state *framework.CycleState, pod *corev1.Pod, nodeName string) (int64, *framework.Status)
Score runs two predictors (power consumption and response time) and returns the combined score.
This function never returns an error (as errors cause the pod to be rejected). If an error occurs, it is logged and the score is set to ScoreError.
Q. Why not two separated Score Plugins? A. To allow the user to set the weights per pod, we cannot use `weight` in KubeSchedulerConfiguration as it is static. So we merge the scores and split them in NormalizeScore, then apply the weights. Also, there are many duplicated processes in the two Score functions, combine them into one Plugin helps caching, etc. Downside: timeout handling, code complexity.
func (*MinimizePower) ScoreExtensions ¶
func (pl *MinimizePower) ScoreExtensions() framework.ScoreExtensions
ScoreExtensions returns a ScoreExtensions interface.
func (*MinimizePower) ScorePowerConsumption ¶
func (pl *MinimizePower) ScorePowerConsumption(ctx context.Context, _ *framework.CycleState, pod *corev1.Pod, nodeName string) (int64, *framework.Status)
ScorePowerConsumption returns how many watts will be increased by the given pod (lower is better).
This function never returns an error (as errors cause the pod to be rejected). If an error occurs, it is logged and the score is set to ScoreError.
func (*MinimizePower) ScoreResponseTime ¶
func (pl *MinimizePower) ScoreResponseTime(ctx context.Context, _ *framework.CycleState, pod *corev1.Pod, nodeName string) (int64, *framework.Status)
ScoreResponseTime returns how many milliseconds will be increased by the given pod (lower is better).
This function never returns an error (as errors cause the pod to be rejected). If an error occurs, it is logged and the score is set to ScoreError.
type MinimizePowerArgs ¶
type MinimizePowerArgs struct { metav1.TypeMeta `json:",inline"` MetricsCacheTTL metav1.Duration `json:"metricsCacheTTL,omitempty"` PredictorCacheTTL metav1.Duration `json:"predictorCacheTTL,omitempty"` // PodUsageAssumption is the assumed fraction of CPU usage that a pod uses, must be [0.0, 1.0] PodUsageAssumption float64 `json:"podUsageAssumption,omitempty"` // CPUUsageFormat is the format of the CPU usage to use for predictions, // options are `Raw` [0.0, NumLogicalCores] or `Percent` [0, 100]. CPUUsageFormat string `json:"cpuUsageFormat,omitempty"` // WeightPowerConsumption is the weight to give to power consumption in the score, must be >= 0. WeightPowerConsumption int `json:"weightPowerConsumption,omitempty"` // WeightResponseTime is the weight to give to response time in the score, must be >= 0. WeightResponseTime int `json:"weightResponseTime,omitempty"` }
func (*MinimizePowerArgs) DeepCopy ¶
func (in *MinimizePowerArgs) DeepCopy() *MinimizePowerArgs
func (*MinimizePowerArgs) DeepCopyInto ¶
func (in *MinimizePowerArgs) DeepCopyInto(out *MinimizePowerArgs)
func (*MinimizePowerArgs) DeepCopyObject ¶
func (in *MinimizePowerArgs) DeepCopyObject() runtime.Object
func (*MinimizePowerArgs) Default ¶
func (args *MinimizePowerArgs) Default()
func (*MinimizePowerArgs) Validate ¶
func (args *MinimizePowerArgs) Validate() error