Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 289c3c2

Browse files
authored
Merge pull request #54 from intel/v2.3.0
Kubernetes Power Manager v2.3.0 release
2 parents 638a3ac + d8a8f02 commit 289c3c2

File tree

87 files changed

+7787
-1357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+7787
-1357
lines changed

Makefile

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,37 @@ build: generate manifests install
3737

3838
# Build the Manager and Node Agent images
3939
images: generate manifests install
40-
docker build -f build/Dockerfile -t intel/power-operator:v2.2.0 .
41-
docker build -f build/Dockerfile.nodeagent -t intel/power-node-agent:v2.2.0 .
40+
docker build -f build/Dockerfile -t intel/power-operator:v2.3.0 .
41+
docker build -f build/Dockerfile.nodeagent -t intel/power-node-agent:v2.3.0 .
4242

4343
# Run against the configured Kubernetes cluster in ~/.kube/config
4444
run: generate fmt vet manifests
4545
go run ./main.go
4646

47+
helm-install: generate manifests install
48+
helm install kubernetes-power-manager-v2.3.0 ./helm/kubernetes-power-manager-v2.3.0
49+
50+
helm-uninstall:
51+
helm uninstall kubernetes-power-manager-v2.3.0
52+
53+
helm-install-v2.2.0: generate manifests install
54+
helm install kubernetes-power-manager-v2.2.0 ./helm/kubernetes-power-manager-v2.2.0
55+
56+
helm-uninstall-v2.2.0:
57+
helm uninstall kubernetes-power-manager-v2.2.0
58+
59+
helm-install-v2.1.0: generate manifests install
60+
helm install kubernetes-power-manager-v2.1.0 ./helm/kubernetes-power-manager-v2.1.0
61+
62+
helm-uninstall-v2.1.0:
63+
helm uninstall kubernetes-power-manager-v2.1.0
64+
65+
helm-install-v2.0.0: generate manifests install
66+
helm install kubernetes-power-manager-v2.0.0 ./helm/kubernetes-power-manager-v2.0.0
67+
68+
helm-uninstall-v2.0.0:
69+
helm uninstall kubernetes-power-manager-v2.0.0
70+
4771
# Install CRDs into a cluster
4872
install: manifests kustomize
4973
$(KUSTOMIZE) build config/crd | kubectl apply -f -
@@ -119,3 +143,11 @@ bundle: manifests
119143
.PHONY: bundle-build
120144
bundle-build:
121145
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
146+
147+
coverage:
148+
go test -v -coverprofile=coverage.out ./...
149+
go tool cover -html=coverage.out -o coverage.html
150+
@echo "Average code coverage: $$(go tool cover -func coverage.out | awk 'END {print $$3}' | sed 's/\..*//')%"
151+
@if [ $$(go tool cover -func coverage.out | awk 'END {print $$3}' | sed 's/\..*//') -lt 85 ]; then \
152+
echo "WARNING: Total unit test coverage below 85%"; false; \
153+
fi

README.md

Lines changed: 98 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Kubernetes Power Manager
22

3-
## What is the Kubernetes Power Manager?
3+
## Introduction
44

55
Utilizing a container orchestration engine like Kubernetes, CPU resources are allocated from a pool of platforms
66
entirely based on availability, without taking into account specific features like Intel Speed Select Technology (SST).
@@ -29,16 +29,17 @@ specifically Intel SST.
2929

3030
### Use Cases:
3131

32-
- *High performance workload known at peak times.*
33-
May want to pre-schedule nodes to move to a performance profile during peak times to minimize spin up.
34-
At times not during peak, may want to move to a power saving profile.
32+
- Users may want to pre-schedule nodes to move to a performance profile during peak times to minimize spin up.
33+
At times not during peak, they may want to move to a power saving profile.
3534
- *Unpredictable machine use.*
36-
May use machine learning through monitoring to determine profiles that predict a peak need for a compute, to spin up
35+
Users may use machine learning through monitoring to determine profiles that predict a peak need for compute, to spin up
3736
ahead of time.
3837
- *Power Optimization over Performance.*
39-
A cloud may be interested in fast response time, but not in maximal response time, so may choose to spin up cores on
38+
A user may be interested in fast response time, but not in maximal response time, so may choose to spin up cores on
4039
demand and only those cores used but want to remain in power-saving mode the rest of the time.
4140

41+
### Further Info:
42+
Please see the _diagrams-docs_ directory for diagrams with a visual breakdown of the power manager and its components.
4243
## Functionality of the Kubernetes Power Manager
4344

4445
- **SST-BF - (Speed Select Technology - Base Frequency)**
@@ -76,18 +77,25 @@ specifically Intel SST.
7677
Time of Day is designed to allow the user to select a specific time of day that they can put all their unused CPUs
7778
into “sleep” state and then reverse the process and select another time to return to an “active” state.
7879

79-
- **P-State**
80-
81-
Modern Intel CPUs automatically employ the Intel P_State CPU power scaling driver. This driver is integrated rather
82-
than a module, giving it precedence over other drivers. For Sandy Bridge and newer CPUs, this driver is currently used
83-
automatically. The BIOS P-State settings might be disregarded by Intel P-State.
84-
The Intel P-State driver utilizes the "Performance" and "Powersave" governors.
85-
***Performance***
86-
The CPUfreq governor "performance" sets the CPU statically to the highest frequency within the borders of
87-
scaling_min_freq and scaling_max_freq.
88-
***Powersave***
89-
The CPUfreq governor "powersave" sets the CPU statically to the lowest frequency within the borders of
90-
scaling_min_freq and scaling_max_freq.
80+
- **Scaling Drivers**
81+
* **P-State**
82+
83+
Modern Intel CPUs automatically employ the Intel P_State CPU power scaling driver. This driver is integrated rather
84+
than a module, giving it precedence over other drivers. For Sandy Bridge and newer CPUs, this driver is currently used
85+
automatically. The BIOS P-State settings might be disregarded by Intel P-State.
86+
The Intel P-State driver utilizes the "Performance" and "Powersave" governors.
87+
***Performance***
88+
The CPUfreq governor "performance" sets the CPU statically to the highest frequency within the borders of
89+
scaling_min_freq and scaling_max_freq.
90+
***Powersave***
91+
The CPUfreq governor "powersave" sets the CPU statically to the lowest frequency within the borders of
92+
scaling_min_freq and scaling_max_freq.
93+
* **acpi-cpufreq**
94+
95+
The acpi-cpufreq driver setting operates much like the P-state driver but has a different set of available governors. For more information see [here](https://www.kernel.org/doc/html/v4.12/admin-guide/pm/cpufreq.html).
96+
One thing to note is that acpi-cpufreq reports the base clock as the frequency hardware limits however the P-state driver uses turbo frequency limits.
97+
Both drivers can make use of turbo frequency; however, acpi-cpufreq can exceed hardware frequency limits when using turbo frequency.
98+
This is important to take into account when setting frequencies for profiles.
9199

92100
- **Uncore**
93101
The largest part of modern CPUs is outside the actual cores. On Intel CPUs this is part is called the "Uncore" and has
@@ -121,7 +129,7 @@ specifically Intel SST.
121129
Note: NFD is recommended, but not essential. Node labels can also be applied manually. See
122130
the [NFD repo](https://github.com/kubernetes-sigs/node-feature-discovery#feature-labels) for a full list of features
123131
labels.
124-
* In the kubelet configuration file the cpuManagerPolicy has to set to "static", and the reservedSystemCPUs are set to
132+
* **Important**: In the kubelet configuration file the cpuManagerPolicy has to set to "static", and the reservedSystemCPUs must be set to
125133
the desired value:
126134

127135
````yaml
@@ -173,6 +181,44 @@ syncFrequency: 0s
173181
volumeStatsAggPeriod: 0s
174182
````
175183

184+
## Deploying the Kubernetes Power Manager using Helm
185+
186+
The Kubernetes Power Manager includes a helm chart for the latest releases, allowing the user to easily deploy
187+
everything that is needed for the overarching operator and the node agent to run. The following versions are
188+
supported with helm charts:
189+
190+
* v2.0.0
191+
* v2.1.0
192+
* v2.2.0
193+
* v2.3.0
194+
195+
When set up using the provided helm charts, the following will be deployed:
196+
197+
* The intel-power namespace
198+
* The RBAC rules for the operator and node agent
199+
* The operator deployment itself
200+
* The operator's power config
201+
* A shared power profile
202+
203+
To change any of the values the above are deployed with, edit the values.yaml file of the relevant helm chart.
204+
205+
To deploy the Kubernetes Power Manager using Helm, you must have Helm installed. For more information on installing
206+
Helm, see the installation guide here https://helm.sh/docs/intro/install/.
207+
208+
The Kubernetes Power Manager has make targets for each version available. To deploy the latest version, use the following command:
209+
210+
`make helm-install`
211+
212+
To uninstall the latest version, use the following command:
213+
214+
`make helm-uninstall`
215+
216+
Or you can use the following commands to deploy a specific version of the Kubernetes Power Manager:
217+
218+
`make helm-install-v2.2.0`
219+
`make helm-install-v2.1.0`
220+
`make helm-install-v2.0.0`
221+
176222
## Working environments
177223

178224
The Kubernetes Power Manager has been tested in different environments.
@@ -538,49 +584,6 @@ spec:
538584
C1: true
539585
C6: false
540586
````
541-
### Time Of Day
542-
The TIme Of Day feature allows users to change the configuration of their system at a given time each day. This is done through the use of a `timeofdaycronjob`
543-
which schedules itself for a specific time each day and gives users the option of tuning cstates, the shared pool profile as well as the profile used by individual pods.
544-
#### Example
545-
````yaml
546-
apiVersion: power.intel.com/v1
547-
kind: TimeOfDay
548-
metadata:
549-
name: timeofday-sample
550-
namespace: intel-power
551-
spec:
552-
timeZone: "Eire"
553-
schedule:
554-
- time: "14:24"
555-
# this sets the profile for the shared pool
556-
powerProfile: balance-performance
557-
# this transitions a pod with the given name from one profile to another
558-
pods:
559-
four-pod-v2:
560-
performance: balance-performance
561-
four-pod-v4:
562-
balance-power: performance
563-
# this field simply takes a cstate spec
564-
cState:
565-
sharedPoolCStates:
566-
C1: false
567-
C6: true
568-
- time: "14:26"
569-
powerProfile: performance
570-
cState:
571-
sharedPoolCStates:
572-
C1: true
573-
C6: false
574-
- time: "14:28"
575-
powerProfile: balance-power
576-
reservedCPUs: [0,1]
577-
````
578-
When applying changes to the shared pool, users must specify the CPUs reserved by the system. Additionally the user must specify a timezone to schedule with.
579-
The configuration for Time Of Day consists of a schedule list. Each item in the list consists of a time and any desired changes to the system.
580-
The `profile` field specifies the desired profile for the shared pool.
581-
The `pods` field is used to change the profile associated with a specific pod.
582-
It should be noted that when changing the profile of an individual pod, the user must specify its name and current profile at the time as well as the desired new profile.
583-
Finally the `cState` field accepts the spec values from a CStates configuration and applies them to the system.
584587

585588
### intel-pstate CPU Performance Scaling Driver
586589
The intel_pstate is a part of the CPU performance scaling subsystem in the Linux kernel (CPUFreq).
@@ -597,6 +600,11 @@ Finally the `cState` field accepts the spec values from a CStates configuration
597600
##### Performance Governor
598601
The CPUfreq governor "performance" sets the CPU statically to the highest frequency within the borders of scaling_min_freq and scaling_max_freq.
599602

603+
### acpi-cpufreq scaling driver
604+
An alternative to the P-state driver is the acpi-cpufreq driver.
605+
It operates in a similar fashion to the P-state driver but offers a different set of governors which can be seen [here](https://www.kernel.org/doc/html/v4.12/admin-guide/pm/cpufreq.html).
606+
One notable difference between the P-state and acpi-cpufreq driver is that the afformentioned scaling_max_freq value is limited to base clock frequencies rather than turbo frequencies.
607+
When turbo is enabled the core frequency will still be capable of exceeding base clock frequencies and the value of scaling_max_freq.
600608

601609
### Time Of Day
602610

@@ -616,29 +624,44 @@ metadata:
616624
spec:
617625
timeZone: "Eire"
618626
schedule:
619-
- time: "14:24"
627+
- time: "14:56"
620628
# this sets the profile for the shared pool
621-
powerProfile: balance-performance
622-
# this transitions a pod with the given name from one profile to another
629+
powerProfile: balance-power
630+
# this transitions exclusive pods matching a given label from one profile to another
631+
# please ensure that only pods to be used by power manager have this label
623632
pods:
624-
four-pod-v2:
625-
performance: balance-performance
626-
four-pod-v4:
627-
balance-power: performance
633+
- labels:
634+
matchLabels:
635+
power: "true"
636+
target: balance-performance
637+
- labels:
638+
matchLabels:
639+
special: "false"
640+
target: balance-performance
628641
# this field simply takes a cstate spec
629642
cState:
630643
sharedPoolCStates:
631644
C1: false
632645
C6: true
633-
- time: "14:26"
634-
powerProfile: performance
646+
- time: "23:57"
647+
powerProfile: shared
635648
cState:
636649
sharedPoolCStates:
637650
C1: true
638651
C6: false
639-
- time: "14:28"
652+
pods:
653+
- labels:
654+
matchLabels:
655+
power: "true"
656+
target: performance
657+
- labels:
658+
matchLabels:
659+
special: "false"
660+
target: balance-power
661+
- time: "14:35"
640662
powerProfile: balance-power
641663
reservedCPUs: [ 0,1 ]
664+
642665
```
643666

644667
When applying changes to the shared pool, users must specify the CPUs reserved by the system. Additionally the user must
@@ -647,8 +670,8 @@ The configuration for Time Of Day consists of a schedule list. Each item in the
647670
changes to the system.
648671
The `profile` field specifies the desired profile for the shared pool.
649672
The `pods` field is used to change the profile associated with a specific pod.
650-
It should be noted that when changing the profile of an individual pod, the user must specify its name and current
651-
profile at the time as well as the desired new profile.
673+
To change the profile of specific pods users must provide a set of labels and profiles. When a pod matching a label is found it will be placed in a workload that matches the requested profile.
674+
Please note that all pods matching a provided label must be configured for use with the power manager by requesting an intial profile and dedicated cores.
652675
Finally the `cState` field accepts the spec values from a CStates configuration and applies them to the system.
653676

654677
### Uncore Frequency
@@ -675,37 +698,6 @@ spec:
675698
max: 2400000
676699
````
677700

678-
### intel-pstate CPU Performance Scaling Driver
679-
680-
The intel_pstate is a part of the CPU performance scaling subsystem in the Linux kernel (CPUFreq).
681-
682-
In some situations it is desirable or even necessary to run the program as fast as possible and then there is no reason
683-
to use any P-states different from the highest one (i.e. the highest-performance frequency/voltage configuration
684-
available). In some other cases, however, it may not be necessary to execute instructions so quickly and maintaining the
685-
highest available CPU capacity for a relatively long time without utilizing it entirely may be regarded as wasteful. It
686-
also may not be physically possible to maintain maximum CPU capacity for too long for thermal or power supply capacity
687-
reasons or similar. To cover those cases, there are hardware interfaces allowing CPUs to be switched between different
688-
frequency/voltage configurations or (in the ACPI terminology) to be put into different P-states.
689-
690-
#### P-State Governors
691-
692-
In order to offer dynamic frequency scaling, the cpufreq core must be able to tell these drivers of a "target
693-
frequency". So these specific drivers will be transformed to offer a "->target/target_index/fast_switch()" call instead
694-
of the "->setpolicy()" call. For set_policy drivers, all stays the same, though.
695-
696-
The cpufreq governors decide what frequency within the CPUfreq policy should be used. The P-state driver utilizes the "
697-
powersave" and "performance" governors.
698-
699-
##### Powersave Governor
700-
701-
The CPUfreq governor "powersave" sets the CPU statically to the lowest frequency within the borders of scaling_min_freq
702-
and scaling_max_freq.
703-
704-
##### Performance Governor
705-
706-
The CPUfreq governor "performance" sets the CPU statically to the highest frequency within the borders of
707-
scaling_min_freq and scaling_max_freq.
708-
709701
### In the Kubernetes API
710702

711703
- PowerConfig CRD
@@ -802,7 +794,7 @@ spec:
802794
args:
803795
- --enable-leader-election
804796
imagePullPolicy: IfNotPresent
805-
image: power-operator:v2.2.0
797+
image: power-operator:v2.3.0
806798
securityContext:
807799
allowPrivilegeEscalation: false
808800
capabilities:

api/v1/powernode_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ type GuaranteedPod struct {
7979
// The name of the Pod
8080
Name string `json:"name,omitempty"`
8181

82+
Namespace string `json:"namespace,omitempty"`
83+
8284
// The UID of the Pod
8385
UID string `json:"uid,omitempty"`
8486

api/v1/powerprofile_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ type PowerProfileSpec struct {
2727
// The name of the PowerProfile
2828
Name string `json:"name"`
2929

30+
Shared bool `json:"shared,omitempty"`
3031
// Max frequency cores can run at
3132
Max int `json:"max,omitempty"`
3233

3334
// Min frequency cores can run at
3435
Min int `json:"min,omitempty"`
3536

3637
// The priority value associated with this Power Profile
37-
Epp string `json:"epp"`
38+
Epp string `json:"epp,omitempty"`
3839

3940
// Governor to be used
4041
//+kubebuilder:default=powersave

api/v1/timeofday_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import (
2626
type ScheduleInfo struct {
2727
Time string `json:"time"`
2828

29-
PowerProfile *string `json:"powerProfile,omitempty"`
30-
Pods *map[string]map[string]string `json:"pods,omitempty"`
31-
CState *CStatesSpec `json:"cState,omitempty"`
29+
PowerProfile *string `json:"powerProfile,omitempty"`
30+
Pods *[]PodInfo `json:"pods,omitempty"`
31+
CState *CStatesSpec `json:"cState,omitempty"`
3232
}
3333

3434
// TimeOfDaySpec defines the desired state of TimeOfDay

0 commit comments

Comments
 (0)