Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit cbbe430

Browse files
author
Alessandro Puccetti
committed
doc: kubernetes example
This patch adds an example on how to run the plugin on a kubernetes cluster.
1 parent 3e05621 commit cbbe430

File tree

2 files changed

+87
-3
lines changed

2 files changed

+87
-3
lines changed

README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,49 @@ You need `/sys/kernel/debug/` in order to be able to build the eBPF program gene
1111

1212
## How to Run Scope HTTP Statistics Plugin
1313

14+
This plugin requires:
15+
16+
* kernel version [>=4.1](https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md) running on the host to be able to attach eBPF to kprobes.
17+
* Kernel build directory to be available in `/lib/modules/<kernel-version>/build`. Depending on your distribution you might need to add this symlink: `ln -s /lib/modules/<kernel-version>/build /lib/modules/<kernel-version>/source`.
18+
19+
The Scope HTTP Statistics plugin works with `Weave Scope`, you need to have Scope up and running before you can use it. If the running plugin has been registered by Scope, you will see it in the list of `PLUGINS` in the bottom right of the UI (see the rectangle in the above figure).
20+
21+
### Using a pre-built Docker image
22+
23+
If you want to make sure of running the latest available version of the plugin, you can pull the image from docker hub.
24+
25+
```
26+
docker pull weaveworksplugins/scope-http-statistics:latest
27+
```
28+
29+
To run the Scope HTTP Statistics plugin you just need to run the following command.
30+
31+
```
32+
sudo docker run --rm -it \
33+
--privileged --net=host --pid=host \
34+
-v /lib/modules:/lib/modules \
35+
-v /usr/src:/usr/src \
36+
-v /sys/kernel/debug/:/sys/kernel/debug/ \
37+
-v /var/run/scope/plugins:/var/run/scope/plugins \
38+
--name weaveworksplugins-scope-http-statistics weaveworksplugins/scope-http-statistics
39+
```
40+
41+
### Kubernetes
42+
43+
If you want to use the Scope HTTP Statistics plugin in an already set up Kubernetes cluster with Weave Scope running on it, you just need to run:
44+
45+
```
46+
kubectl create -f https://github.com/weaveworks-plugins/scope-http-statistics/tree/master/deployments/k8s-http-statistics.yaml
47+
```
48+
49+
### Recompiling
1450
* Run the HTTP Statistics plugin
1551
* `git clone git@github.com:weaveworks-plugins/scope-http-statistics.git`
16-
* `cd scope-http-statistics.sh; make`
52+
* `cd scope-http-statistics; make`
1753

18-
**Note** If Scope HTTP Statistics plugin has been registered by Scope, you will see it in the list of `PLUGINS` in the bottom right of the UI (see the rectangle in the above figure).
54+
## Testing
1955

20-
* In another terminal, run an `nginx` instance `docker run --rm --name http-statistics-nginx -p 8080:80 nginx`
56+
* Run an `nginx` instance `docker run --rm --name http-statistics-nginx -p 8080:80 nginx`
2157
* Run `sh test-http-statistics.sh`, press Ctrl+c to terminate the test.
2258
* Go to the Weave Scope UI [http://localhost:4040](http://localhost:4040).
2359
* Open the `http-statistics-nginx` container.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
apiVersion: extensions/v1beta1
2+
kind: DaemonSet
3+
metadata:
4+
labels:
5+
app: weavescope
6+
weavescope-component: weavescope-http-statistics-plugin
7+
name: weavescope-http-statistics-plugin
8+
spec:
9+
template:
10+
metadata:
11+
labels:
12+
app: weavescope
13+
weavescope-component: weavescope-http-statistics-plugin
14+
spec:
15+
hostPID: true
16+
hostNetwork: true
17+
containers:
18+
- name: weavescope-http-statistics-plugin
19+
image: weaveworksplugins/scope-http-statistics:latest
20+
securityContext:
21+
privileged: true
22+
volumeMounts:
23+
- name: docker-sock
24+
mountPath: /var/run/docker.sock
25+
- name: scope-plugins
26+
mountPath: /var/run/scope/plugins
27+
- name: lib-modules
28+
mountPath: /lib/modules
29+
- name: usr-src
30+
mountPath: /usr/src
31+
- name: sys-kernel-debug
32+
mountPath: /sys/kernel/debug
33+
volumes:
34+
- name: docker-sock
35+
hostPath:
36+
path: /var/run/docker.sock
37+
- name: scope-plugins
38+
hostPath:
39+
path: /var/run/scope/plugins
40+
- name: lib-modules
41+
hostPath:
42+
path: /lib/modules
43+
- name: usr-src
44+
hostPath:
45+
path: /usr/src
46+
- name: sys-kernel-debug
47+
hostPath:
48+
path: /sys/kernel/debug

0 commit comments

Comments
 (0)