diff --git a/kubernetes-addons/memory-bandwidth-exporter/README.md b/kubernetes-addons/memory-bandwidth-exporter/README.md index c8c5320dc..f2507ed33 100644 --- a/kubernetes-addons/memory-bandwidth-exporter/README.md +++ b/kubernetes-addons/memory-bandwidth-exporter/README.md @@ -1,12 +1,13 @@ # memory bandwidth exporter -Pod/container grained memory bandwidth exporter provides users memory bandwidth metrics of their running containers. The metrics include llc_occupancy, mbm_local_bytes, mbm_total_bytes, cpu utilization and memory usage, and the metrics have been processed. In addition to container-level metrics, it also provides class-level and socket-level metrics. Users can configure the list of metrics to be collected. It serves as an exporter which can be connected to Promethus-like obserbility tools. And it also can be used as a telementry provider. +Pod/container grained memory bandwidth exporter provides users memory bandwidth metrics of their running containers. The metrics include llc_occupancy, mbm_local_bytes, mbm_total_bytes, cpu utilization and memory usage, and the metrics have been processed. In addition to container-level metrics, it also provides class-level and socket-level metrics. Users can configure the list of metrics to be collected. It serves as an exporter which can be connected to Promethus-like obserbility tools. And it also can be used as a telementry provider. Memory bandwidth exporter makes use of state-of-the-art technologies like NRI to build a resource-efficient and well-maintained solution. This solution provides observability to memory bandwidth to OPEA micro-services. It lays the groundwork of better scaling and auto scaling of OPEA. It can also be deployed separately on end user environments, supporting any cases that memory bandwidth metrics are required. ## Setup ### Enable NRI in Containerd + ```sh # download containerd binary, containerd version v1.7.0 or higher is required $ wget https://github.com/containerd/containerd/releases/download/v1.7.0/containerd-1.7.0-linux-amd64.tar.gz @@ -41,6 +42,7 @@ $ ./build/bin/logger -idx 00 ### Enable RDT Mount resctrl to the directory `/sys/fs/resctrl`: + ```sh $ sudo mount -t resctrl resctrl /sys/fs/resctrl ``` @@ -48,6 +50,7 @@ $ sudo mount -t resctrl resctrl /sys/fs/resctrl ### Setup memory bandwidth exporter Before setup, you need to configure the runc hook: + ```sh $ ./config/config.sh ``` @@ -57,7 +60,7 @@ $ ./config/config.sh ```sh $ make build $ sudo ./bin/memory-bandwidth-exporter -# e.g., sudo ./bin/memory-bandwidth-exporter --collector.node.name= --collector.container.namespaceWhiteList="calico-apiserver,calico-system,kube-system,tigera-operator" +# e.g., sudo ./bin/memory-bandwidth-exporter --collector.node.name= --collector.container.namespaceWhiteList="calico-apiserver,calico-system,kube-system,tigera-operator" # get memory bandwidth metrics $ curl http://localhost:9100/metrics @@ -105,6 +108,7 @@ memory-bandwidth-exporter-zxhdl 1/1 Running 0 3m ``` get memory bandwidth metrics + ```sh $ curl http://:9100/metrics ``` @@ -118,6 +122,7 @@ $ make clean ## More flags about memory bandwidth exporter There are some flags to help users better use memory bandwidth exporter: + ```sh -h, --[no-]help Show context-sensitive help (also try --help-long and --help-man). --collector.node.name="" Give node name. @@ -140,4 +145,4 @@ There are some flags to help users better use memory bandwidth exporter: --log.level=info Only log messages with the given severity or above. One of: [debug, info, warn, error] --log.format=logfmt Output format of log messages. One of: [logfmt, json] --[no-]version Show application version. -``` \ No newline at end of file +``` diff --git a/kubernetes-addons/memory-bandwidth-exporter/config/config.sh b/kubernetes-addons/memory-bandwidth-exporter/config/config.sh index 0bee9dd54..69b80a36d 100755 --- a/kubernetes-addons/memory-bandwidth-exporter/config/config.sh +++ b/kubernetes-addons/memory-bandwidth-exporter/config/config.sh @@ -1,6 +1,9 @@ #!/bin/bash +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + sudo apt install jq sudo mkdir -p /etc/containers/oci/hooks.d/ sudo cp plugin/etc/containers/oci/hooks.d/* /etc/containers/oci/hooks.d/ -sudo cp plugin/usr/local/sbin/* /usr/local/sbin/ \ No newline at end of file +sudo cp plugin/usr/local/sbin/* /usr/local/sbin/ diff --git a/kubernetes-addons/memory-bandwidth-exporter/config/manifests/memory-bandwidth-exporter.yaml b/kubernetes-addons/memory-bandwidth-exporter/config/manifests/memory-bandwidth-exporter.yaml index 1e27d8938..de7b77069 100644 --- a/kubernetes-addons/memory-bandwidth-exporter/config/manifests/memory-bandwidth-exporter.yaml +++ b/kubernetes-addons/memory-bandwidth-exporter/config/manifests/memory-bandwidth-exporter.yaml @@ -1,3 +1,6 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + apiVersion: apps/v1 kind: DaemonSet metadata: @@ -53,4 +56,4 @@ spec: - name: nri hostPath: path: /var/run/nri/ - hostPID: true \ No newline at end of file + hostPID: true diff --git a/kubernetes-addons/memory-bandwidth-exporter/config/prometheus/prometheus.yml b/kubernetes-addons/memory-bandwidth-exporter/config/prometheus/prometheus.yml index cf9f5e655..e25329314 100644 --- a/kubernetes-addons/memory-bandwidth-exporter/config/prometheus/prometheus.yml +++ b/kubernetes-addons/memory-bandwidth-exporter/config/prometheus/prometheus.yml @@ -1,7 +1,10 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + global: scrape_interval: 15s scrape_configs: - job_name: memory-bandwidth-exporter static_configs: - - targets: ['localhost:9100'] \ No newline at end of file + - targets: ['localhost:9100'] diff --git a/kubernetes-addons/memory-bandwidth-exporter/plugin/etc/containers/oci/hooks.d/create-runtime.json b/kubernetes-addons/memory-bandwidth-exporter/plugin/etc/containers/oci/hooks.d/create-runtime.json index f9a2b7b69..9e3a6b7d5 100644 --- a/kubernetes-addons/memory-bandwidth-exporter/plugin/etc/containers/oci/hooks.d/create-runtime.json +++ b/kubernetes-addons/memory-bandwidth-exporter/plugin/etc/containers/oci/hooks.d/create-runtime.json @@ -1,10 +1,10 @@ { - "version": "1.0.0", - "hook": { - "path": "/usr/local/sbin/create-runtime.sh" - }, - "when": { - "always": true - }, - "stages": ["createRuntime"] + "version": "1.0.0", + "hook": { + "path": "/usr/local/sbin/create-runtime.sh" + }, + "when": { + "always": true + }, + "stages": ["createRuntime"] } diff --git a/kubernetes-addons/memory-bandwidth-exporter/plugin/etc/containers/oci/hooks.d/post-stop.json b/kubernetes-addons/memory-bandwidth-exporter/plugin/etc/containers/oci/hooks.d/post-stop.json index 44b742317..7f295cc93 100644 --- a/kubernetes-addons/memory-bandwidth-exporter/plugin/etc/containers/oci/hooks.d/post-stop.json +++ b/kubernetes-addons/memory-bandwidth-exporter/plugin/etc/containers/oci/hooks.d/post-stop.json @@ -1,10 +1,10 @@ { - "version": "1.0.0", - "hook": { - "path": "/usr/local/sbin/post-stop.sh" - }, - "when": { - "always": true - }, - "stages": ["poststop"] -} \ No newline at end of file + "version": "1.0.0", + "hook": { + "path": "/usr/local/sbin/post-stop.sh" + }, + "when": { + "always": true + }, + "stages": ["poststop"] +} diff --git a/kubernetes-addons/memory-bandwidth-exporter/plugin/usr/local/sbin/create-runtime.sh b/kubernetes-addons/memory-bandwidth-exporter/plugin/usr/local/sbin/create-runtime.sh index 22567664b..880bfd290 100755 --- a/kubernetes-addons/memory-bandwidth-exporter/plugin/usr/local/sbin/create-runtime.sh +++ b/kubernetes-addons/memory-bandwidth-exporter/plugin/usr/local/sbin/create-runtime.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + container_state=$(cat) container_pid=$(echo "$container_state" | jq -r '.pid') @@ -11,4 +14,4 @@ fi tasks_file="$mon_group_dir/tasks" echo "$container_pid" | sudo tee -a $tasks_file > /dev/null -echo "CREATE Container: $container_id, Container State: $container_state, Container PID: $container_pid" | sudo tee -a /var/log/container_pids.log > /dev/null \ No newline at end of file +echo "CREATE Container: $container_id, Container State: $container_state, Container PID: $container_pid" | sudo tee -a /var/log/container_pids.log > /dev/null diff --git a/kubernetes-addons/memory-bandwidth-exporter/plugin/usr/local/sbin/post-stop.sh b/kubernetes-addons/memory-bandwidth-exporter/plugin/usr/local/sbin/post-stop.sh index 8d686dc4b..f10b0b97e 100755 --- a/kubernetes-addons/memory-bandwidth-exporter/plugin/usr/local/sbin/post-stop.sh +++ b/kubernetes-addons/memory-bandwidth-exporter/plugin/usr/local/sbin/post-stop.sh @@ -1,7 +1,10 @@ #!/bin/bash +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + container_state=$(cat) container_id=$(echo "$container_state" | jq -r '.id') mon_group_dir="/sys/fs/resctrl/mon_groups/container-$container_id" echo "DELETE Container: $container_id" >> /var/log/container_pids.log -sudo rmdir $mon_group_dir \ No newline at end of file +sudo rmdir $mon_group_dir