Skip to content

Commit

Permalink
init power manager
Browse files Browse the repository at this point in the history
  • Loading branch information
KTCyber committed Sep 6, 2023
1 parent d08c1d5 commit 22054ad
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/power_manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# K8s Power Manager

## Components
1. **PowerManager Controller**: ensures the actual state matches the desired state of the cluster.
2. **PowerConfig Controller**: sees the powerConfig created by user and deploys Power Node Agents onto each node specified using a DaemonSet.
- powerNodeSelector: A key/value map used to define a list of node labels that a node must satisfy for the operator’s node
agent to be deployed.
- powerProfiles: The list of PowerProfiles that the user wants available on the nodes
3. **Power Node Agent**: containerized applications used to communicate with the node’s Kubelet PodResources endpoint to discover the exact CPUs that
are allocated per container and tune frequency of the cores as requested


## Setup
### 1. Manual

Execute the following below **as a non-root user with sudo rights** using **bash**:
1. Run the node setup script:
```bash
git clone -b power_manager --depth=1 https://github.com/vhive-serverless/vhive.git
./scripts/power_manager/setup_poer_manager.sh;

11 changes: 11 additions & 0 deletions scripts/power_manager/powerconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: "power.intel.com/v1"
kind: PowerConfig
metadata:
name: power-config
spec:
# Add labels here for the Nodes you want the PowerNodeAgent to be applied to
powerNodeSelector:
feature.node.kubernetes.io/power-node: "true"
# Add wanted PowerProfiles here; valid entries are as follows: performance, balance-performance, balance-power
powerProfiles:
- "performance"
58 changes: 58 additions & 0 deletions scripts/power_manager/setup_power_manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# MIT License
#
# Copyright (c) 2020 Dmitrii Ustiugov, Plamen Petrov and EASE lab
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

PWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Install K8 Power Manager
git clone https://github.com/intel/kubernetes-power-manager $HOME/kubernetes-power-manager
cd $HOME/kubernetes-power-manager

# Set up the necessary Namespace, Service Account, and RBAC rules for the Kubernetes Power Manager
kubectl apply -f config/rbac/namespace.yaml
kubectl apply -f config/rbac/rbac.yaml

# Generate the CRD templates, create the Custom Resource Definitions, and install the CRDs
make

# Built Docker images locally
make images

# Apply Power Manager Controller
kubectl apply -f config/manager/manager.yaml

# Apply PowerConfig -> create the power-node-agent DaemonSet that manages the Power Node Agent pods.
kubectl apply -f ${PWD}/powerconfig.yaml

# Apply Profile. U can modify the spec in the shared-profile.yaml file
kubectl apply -f ${PWD}/shared-profile.yaml

# Apply the shared PowerWorkload. All CPUs (except reservedCPUs specified in this yaml file) will be tuned ti the specified frequency in shared-profile.yaml
kubectl apply -f ${PWD}/shared-workload.yaml

kubectl get powerprofiles -n intel-power
kubectl get powerworkloads -n intel-power




11 changes: 11 additions & 0 deletions scripts/power_manager/shared-profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: "power.intel.com/v1"
kind: PowerProfile
metadata:
name: shared
spec:
name: "shared"
max: 1500
min: 1000
# A shared PowerProfile must have the EPP value of 'power'
epp: "power"
governor: "powersave"
19 changes: 19 additions & 0 deletions scripts/power_manager/shared-workload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: "power.intel.com/v1"
kind: PowerWorkload
metadata:
# Replace <NODE_NAME> with the Node you intend this PowerWorkload to be associated with
name: shared-<NODE_NAME>-workload
namespace: intel-power
spec:
# Replace <NODE_NAME> with the Node you intend this PowerWorkload to be associated with
name: "shared-<NODE_NAME>-workload"
allCores: true
reservedCPUs:
# IMPORTANT: The CPUs in reservedCPUs should match the value of the reserved system CPUs in your Kubelet config file
- 0
- 1
powerNodeSelector:
# The label must be as below, as this workload will be specific to the Node
kubernetes.io/hostname: <NODE_NAME>
# Replace this value with the intended shared PowerProfile
powerProfile: "shared"

0 comments on commit 22054ad

Please sign in to comment.