From 22054ad939a9ee1cf982aff89f4d87bc1774b2ef Mon Sep 17 00:00:00 2001 From: KTCyber Date: Wed, 6 Sep 2023 23:24:03 +0800 Subject: [PATCH] init power manager --- scripts/power_manager/README.md | 21 +++++++ scripts/power_manager/powerconfig.yaml | 11 ++++ scripts/power_manager/setup_power_manager.sh | 58 ++++++++++++++++++++ scripts/power_manager/shared-profile.yaml | 11 ++++ scripts/power_manager/shared-workload.yaml | 19 +++++++ 5 files changed, 120 insertions(+) create mode 100644 scripts/power_manager/README.md create mode 100644 scripts/power_manager/powerconfig.yaml create mode 100644 scripts/power_manager/setup_power_manager.sh create mode 100644 scripts/power_manager/shared-profile.yaml create mode 100644 scripts/power_manager/shared-workload.yaml diff --git a/scripts/power_manager/README.md b/scripts/power_manager/README.md new file mode 100644 index 000000000..69d8f33ea --- /dev/null +++ b/scripts/power_manager/README.md @@ -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; + \ No newline at end of file diff --git a/scripts/power_manager/powerconfig.yaml b/scripts/power_manager/powerconfig.yaml new file mode 100644 index 000000000..ec4194ab0 --- /dev/null +++ b/scripts/power_manager/powerconfig.yaml @@ -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" \ No newline at end of file diff --git a/scripts/power_manager/setup_power_manager.sh b/scripts/power_manager/setup_power_manager.sh new file mode 100644 index 000000000..1e4568620 --- /dev/null +++ b/scripts/power_manager/setup_power_manager.sh @@ -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 + + + + diff --git a/scripts/power_manager/shared-profile.yaml b/scripts/power_manager/shared-profile.yaml new file mode 100644 index 000000000..ac1d597f0 --- /dev/null +++ b/scripts/power_manager/shared-profile.yaml @@ -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" \ No newline at end of file diff --git a/scripts/power_manager/shared-workload.yaml b/scripts/power_manager/shared-workload.yaml new file mode 100644 index 000000000..4ce1c83d8 --- /dev/null +++ b/scripts/power_manager/shared-workload.yaml @@ -0,0 +1,19 @@ +apiVersion: "power.intel.com/v1" +kind: PowerWorkload +metadata: + # Replace with the Node you intend this PowerWorkload to be associated with + name: shared--workload + namespace: intel-power +spec: + # Replace with the Node you intend this PowerWorkload to be associated with + name: "shared--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: + # Replace this value with the intended shared PowerProfile + powerProfile: "shared" \ No newline at end of file