Skip to content

Commit

Permalink
Helm chart for pcm - initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalucki committed Apr 26, 2024
1 parent 17c0bc8 commit 2f3a04d
Show file tree
Hide file tree
Showing 24 changed files with 1,047 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ latex/
.vs/
.idea/
build
src/simdjson
src/simdjson
/deployment/pcm/smarter-device-manager/
/deployment/pcm/nri/
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ FROM fedora:40@sha256:4e007f288dce23966216be81ef62ba05d139b9338f327c1d1c73b7167d

RUN dnf -y install gcc-c++ git findutils make cmake
COPY . /tmp/pcm
RUN cd /tmp/pcm && mkdir build && cd build && cmake .. && make
# TEMPORARY change to be remove before merge, to not conflict with local builds + use cache
# WARNING this approach requires me to build locally before docker build to get updated
RUN --mount=type=cache,target=/tmp/pcm/build2 cd /tmp/pcm && cd build2 && cmake -D CMAKE_BUILD_TYPE=Debug .. && make -j pcm pcm-sensor-server

FROM fedora:40@sha256:4e007f288dce23966216be81ef62ba05d139b9338f327c1d1c73b7167dd47312
RUN yum install -y strace gdb util-linux
COPY --from=builder /tmp/pcm/build/bin/* /usr/local/bin/
ENV PCM_NO_PERF=1

Expand Down
92 changes: 92 additions & 0 deletions KUBERNETES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
##### Create kind based development cluster

```sh
kind create cluster
kind export kubeconfig
```

##### 1) Install Prometheus operator required for PodMonitor CRD

E.g. use prometheus operator helm chart from here: https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack

https://prometheus-operator.dev/docs/operator/design/#podmonitor

```sh
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts

helm repo update
helm repo list

# check prometheus source if needed
helm pull prometheus-community/kube-prometheus-stack
tar -xzvf kube-prometheus-stack-56.6.2.tgz

# show/customize values e.g. pod monitor namespace selector
helm show values prometheus-community/kube-prometheus-stack
helm show values prometheus-community/kube-prometheus-stack | vim - +'set ft=yaml'
helm template prometheus-community/kube-prometheus-stack --set-json prometheus.prometheusSpec.podMonitorNamespaceSelector='{"matchLabels": {"kubernetes.io/metadata.name": "intel-pcm"}}' | vim - +'set ft=yaml'

# Install
helm install prometheus prometheus-community/kube-prometheus-stack --set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false

helm list

kubectl --namespace default get pods -l "release=prometheus"
```

To remove:
```sh
helm uninstall prometheus
helm repo remove prometheus-community
```

##### 2) Deploy PCM daemonset

```sh
kubectl apply -f pcm-kubernetes.yaml

# and verify ...
kubectl -n intel-pcm get daemonset
kubectl -n intel-pcm get pods
podname=`kubectl -n intel-pcm get pods -ojsonpath='{.items[0].metadata.name}'`
```

##### 3) Verirfy PCM metrics are collected by Prometheus

```sh
kubectl proxy &
```

Access PCM metrics directly:
```sh
curl -Ls http://127.0.0.1:8001/api/v1/namespaces/intel-pcm/pods/$podname/proxy/metrics
curl -Ls http://127.0.0.1:8001/api/v1/namespaces/intel-pcm/pods/$podname/proxy/metrics | grep DRAM_Writes
```

or through Prometheus UI:
```
http://127.0.0.1:8001/api/v1/namespaces/default/services/prometheus-kube-prometheus-prometheus:http-web/proxy/graph
promtool query range --step 1m http://127.0.0.1:8001/api/v1/namespaces/default/services/prometheus-kube-prometheus-prometheus:http-web/proxy 'rate(DRAM_Writes{aggregate="system"}[5m])/1e9'
promtool query instant http://127.0.0.1:8001/api/v1/namespaces/default/services/prometheus-kube-prometheus-prometheus:http-web/proxy 'avg by(__name__) ({job="pcm"})'
```

query metrics via promtool
```sh
promtool query range --step 1m http://127.0.0.1:8001/api/v1/namespaces/default/services/prometheus-kube-prometheus-prometheus:http-web/proxy 'rate(DRAM_Writes{aggregate="system"}[5m])/1e9'
promtool query instant http://127.0.0.1:8001/api/v1/namespaces/default/services/prometheus-kube-prometheus-prometheus:http-web/proxy 'avg by(__name__) ({job="pcm"})'
```

run some workloads:
```sh
kubectl run -ti stress --image=alexeiled/stress-ng --restart=Never --rm -- --stream 8
```


##### Uninstall PCM

```sh
kubectl delete -f pcm-kubernetes.yaml
```



25 changes: 25 additions & 0 deletions deployment/pcm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
smarter-device-manager/
nri/
9 changes: 9 additions & 0 deletions deployment/pcm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: pcm
version: 0.1.0
appVersion: "202403"
description: A PCM Helm chart for Kubernetes
home: https://github.com/intel/pcm
maintainers:
- name: Pawel Palucki
email: pawel.palucki@intel.com
30 changes: 30 additions & 0 deletions deployment/pcm/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
BSD 3-Clause License

Copyright (c) 2009-2023, Intel Corporation
Copyright (c) 2016-2020, opcm
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 2f3a04d

Please sign in to comment.