Add instruction for running cAdvisor with perf support on k8s
Signed-off-by: Katarzyna Kujawa <katarzyna.kujawa@intel.com>
This commit is contained in:
parent
430d7cf7fc
commit
df60562b39
27
deploy/Dockerfile_perf
Normal file
27
deploy/Dockerfile_perf
Normal file
@ -0,0 +1,27 @@
|
||||
FROM alpine:3.10
|
||||
|
||||
RUN apk --no-cache add libc6-compat=1.1.22-r3 device-mapper=2.02.184-r0 findutils=4.6.0-r1 zfs=0.8.2-r0 build-base=0.5-r1 linux-headers=4.19.36-r0 && \
|
||||
apk --no-cache add thin-provisioning-tools=0.7.1-r3 --repository http://dl-3.alpinelinux.org/alpine/edge/main/ && \
|
||||
echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
|
||||
RUN wget https://sourceforge.net/projects/perfmon2/files/libpfm4/libpfm-4.10.1.tar.gz && \
|
||||
tar -xzf libpfm-4.10.1.tar.gz && \
|
||||
rm libpfm-4.10.1.tar.gz
|
||||
|
||||
RUN export DBG="-g -Wall" && \
|
||||
make -e -C libpfm-4.10.1 && \
|
||||
make install -C libpfm-4.10.1
|
||||
|
||||
# Grab cadvisor from the staging directory.
|
||||
COPY cadvisor /usr/bin/cadvisor
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENV CADVISOR_HEALTHCHECK_URL=http://localhost:8080/healthz
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s \
|
||||
CMD wget --quiet --tries=1 --spider $CADVISOR_HEALTHCHECK_URL || exit 1
|
||||
|
||||
ENTRYPOINT ["/usr/bin/cadvisor", "-logtostderr"]
|
@ -24,6 +24,36 @@ To apply the daemonset to your cluster with example patches applied:
|
||||
kustomize build deploy/kubernetes/overlays/examples | kubectl apply -f -
|
||||
```
|
||||
|
||||
### cAdvisor with perf support on Kubernetes
|
||||
|
||||
Example of modifications needed to deploy cAdvisor with perf support is provided in [overlays/examples_perf](overlays/examples_perf) directory (modification to daemonset and configmap with perf events configuration).
|
||||
|
||||
To test example deployment from the cadvisor/ directory build binary with perf support
|
||||
```
|
||||
GO_FLAGS="-tags=libpfm,netgo" make build
|
||||
```
|
||||
|
||||
Build cAdvisor docker image with perf support
|
||||
```
|
||||
docker build --no-cache --pull -t cadvisor:$(git rev-parse --short HEAD) -f deploy/Dockerfile_perf .
|
||||
```
|
||||
|
||||
Add tag and push to registry:
|
||||
```
|
||||
docker tag cadvisor:$(git rev-parse --short HEAD) <your_docker_registry_address>/cadvisor:$(git rev-parse --short HEAD)
|
||||
docker push <your_docker_registry_address>/cadvisor:$(git rev-parse --short HEAD)
|
||||
```
|
||||
|
||||
Modify image name in [cadvisor-perf.yaml](overlays/examples_perf/cadvisor-perf.yaml), change this line:
|
||||
```
|
||||
image: "<cadvisor_image>"
|
||||
```
|
||||
|
||||
Generate and apply the daemonset with patches:
|
||||
```
|
||||
kustomize build deploy/kubernetes/overlays/examples_perf | kubectl apply -f -
|
||||
```
|
||||
|
||||
## Kustomization
|
||||
|
||||
On your own fork of cAdvisor, create your own overlay directoy with your patches. Copy patches from the example folder if you intend to use them, but don't modify the originals. Commit your changes in your local branch, and use git to manage them the same way you would any other piece of code.
|
||||
|
23
deploy/kubernetes/overlays/examples_perf/cadvisor-perf.yaml
Normal file
23
deploy/kubernetes/overlays/examples_perf/cadvisor-perf.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
# This patch is an example of setting arguments for the cAdvisor container to collect perf metrics
|
||||
apiVersion: apps/v1 # for Kubernetes versions before 1.9.0 use apps/v1beta2
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: cadvisor
|
||||
namespace: cadvisor
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: cadvisor
|
||||
image: "<cadvisor_image>"
|
||||
args:
|
||||
- --perf_events_config=/etc/config/perf-non-hardware.json
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- name: perf-volume
|
||||
mountPath: /etc/config/
|
||||
volumes:
|
||||
- name: perf-volume
|
||||
configMap:
|
||||
name: perf-config
|
22
deploy/kubernetes/overlays/examples_perf/configmap.yaml
Normal file
22
deploy/kubernetes/overlays/examples_perf/configmap.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: perf-config
|
||||
namespace: cadvisor
|
||||
data:
|
||||
perf-non-hardware.json: |
|
||||
{
|
||||
"events": [
|
||||
["context-switches"],
|
||||
["cpu-migrations-custom"]
|
||||
],
|
||||
"custom_events": [
|
||||
{
|
||||
"type": 1,
|
||||
"config": [
|
||||
"0x4"
|
||||
],
|
||||
"name": "cpu-migrations-custom"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
bases:
|
||||
- ../../base
|
||||
resources:
|
||||
- configmap.yaml
|
||||
patches:
|
||||
- cadvisor-perf.yaml
|
Loading…
Reference in New Issue
Block a user