Merge ~ubuntu-docker-images/ubuntu-docker-images/+git/prometheus:readme-template into ~ubuntu-docker-images/ubuntu-docker-images/+git/prometheus:edge

Proposed by Lucas Kanashiro
Status: Merged
Merged at revision: 050c24c35cfdff4ccb5eb17539d6ada8e90cb58c
Proposed branch: ~ubuntu-docker-images/ubuntu-docker-images/+git/prometheus:readme-template
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/prometheus:edge
Diff against target: 223 lines (+126/-37)
2 files modified
oci/README.md (+124/-35)
oci/examples/README.md (+2/-2)
Reviewer Review Type Date Requested Status
Lucas Kanashiro Approve
Sergio Durigan Junior Needs Fixing
Review via email: mp+393915@code.launchpad.net

Description of the change

Make OCI doc files compliance with the defined template.

To post a comment you must log in.
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks, Lucas. Just needs a few minor adjustments and it'll be good to go.

review: Needs Fixing
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Comments addressed, I am going to merge it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/oci/README.md b/oci/README.md
2index e5d8126..5679e90 100644
3--- a/oci/README.md
4+++ b/oci/README.md
5@@ -1,66 +1,152 @@
6-# Ubuntu Prometheus OCI image
7+# Prometheus | Ubuntu
8
9-This OCI image was built based on the upstream one (prom/prometheus). Prometheus in Ubuntu is supported as a snap package, so both are built from the same source. The Ubuntu Dockerfile differs a bit from upstream, instead of relying on the upstream Makefile to do the build and copy the binaries and needed file into the image, we do the build and test of the code during OCI build time.
10+## About Prometheus
11
12-As an initial attempt to not require Internet access to build the image the following was changed:
13+Prometheus is a systems and service monitoring system. It collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts if some condition is observed to be true. Read more on the [Prometheus website](https://prometheus.io/).
14
15-* Add the promu (tool used to build prometheus) binaries for the supported architectures to this repo to avoid downloading them from Github. Build promu from source was also considerd but it depends on itself (older version) to build, for now the binaries built from upstream are used.
16+## Tags
17
18-There is no change that should impact users.
19-
20-## Versions supported
21-
22-* `edge` = `2.20.1`
23+* `2.20.1`, `2.20`, `2`, `beta` - **/!\ this is a beta release**
24
25 ## Architectures supported
26
27-* amd64
28-* arm64
29-* ppc64el
30-* s390x
31+* `amd64`, `arm64`, `ppc64el`, `s390x`
32
33 ## Usage
34
35-To get this image run:
36+### Docker CLI
37
38-```
39-$ docker pull squeakywheel/prometheus:edge
40+```sh
41+$ docker run --name prometheus -e TZ=UTC -d squeakywheel/prometheus:edge
42 ```
43
44-Prometheus command line can be called like this:
45+Since containers are ephemeral, you may want to use persistent data rather than initializing a new database for each newly launched container. To do this, you can use docker volumes:
46
47+```sh
48+$ docker run --name prometheus -v /path/to/persisted/data:/prometheus -e TZ=UTC -d squeakywheel/prometheus:edge
49 ```
50-$ docker run squeakywheel/prometheus:edge -h
51-```
52
53-The command above will display the output of the `prometheus -h`.
54+**Important note**: the directory you will be using to persist the data needs to belong to `nogroup:nobody`. You can run `chown nogroup:nobody <path_to_persist_data>` before launching your container.
55+
56+#### Parameters
57+
58+| Parameter | Description |
59+|---|---|
60+| `-e TZ=UTC` | Timezone. |
61+| `-v /path/to/persisted/data:/prometheus` | Pass the directory used to persist the data. |
62+| `-v /path/to/prometheus/config/file/prometheus.yml:/etc/prometheus/prometheus.yml` | Pass a custom config file. |
63+| `-v /path/to/prometheus/config/file/alerts.yml:/etc/prometheus/alerts.yml` | Pass a custom alerts config file. |
64+
65+
66+#### Testing/Debugging
67
68-Since containers are ephemeral you might be interested in persist data and not initialize a new TSDB database every time you launch a new container. To do that you can use docker volumes:
69+In case you need to debug what it is happening with the container you can run `docker logs <name_of_the_container>`. To get access to an interactive shell run:
70
71 ```
72-$ docker run --name prometheus \
73- --volume /path/to/persisted/data:/prometheus \
74- squeakywheel/prometheus:edge
75+$ docker exec -it <name_of_the_container> /bin/bash
76 ```
77
78-Important note: the directory you will be using to persist the data needs to belong to `nogroup:nobody`. You can run `chown nogroup:nobody <path_to_persist_data>` before launching your container.
79+### Deploy with Kubernetes
80+
81+You can use your favorite Kubernetes distribution; if you don't have one, consider [installing MicroK8s](https://microk8s.io/).
82
83-You can also pass your own configuration files to the container doing the following:
84+With microk8s running, enable the `dns` and `storage` add-ons:
85+```sh
86+$ microk8s enable dns storage
87+ ```
88
89+Create a configmap for the configuration files (check the upstream documentation [here](https://prometheus.io/docs/prometheus/2.20/getting_started/)):
90+
91+```sh
92+$ microk8s kubectl create configmap prometheus-config --from-file=prometheus=config/prometheus.yml --from-file=prometheus-alerts=config/alerts.yml
93 ```
94-$ docker run --name prometheus \
95- --volume /path/to/prometheus/config/file/prometheus.yml:/etc/prometheus/prometheus.yml
96- --volume /path/to/prometheus/config/file/alerts.yml:/etc/prometheus/alerts.yml
97- squeakywheel/prometheus:edge
98+
99+Use the sample deployment yaml provided [here](https://git.launchpad.net/~canonical-server/ubuntu-server-oci/+git/prometheus/plain/examples/prometheus-deployment.yml).
100+
101+<details>
102+ <summary>Apply the `prometheus-deployment.yml` (click to expand)</summary>
103+
104+```yaml
105+# prometheus-deployment.yml
106+---
107+apiVersion: v1
108+kind: PersistentVolumeClaim
109+metadata:
110+ name: prometheus-volume-claim
111+spec:
112+ accessModes:
113+ - ReadWriteOnce
114+ storageClassName: microk8s-hostpath
115+ resources:
116+ requests:
117+ storage: 500M
118+---
119+apiVersion: apps/v1
120+kind: Deployment
121+metadata:
122+ name: prometheus-deployment
123+spec:
124+ replicas: 1
125+ selector:
126+ matchLabels:
127+ app: prometheus
128+ template:
129+ metadata:
130+ labels:
131+ app: prometheus
132+ spec:
133+ containers:
134+ - name: prometheus
135+ image: squeakywheel/prometheus:edge
136+ volumeMounts:
137+ - name: prometheus-config-volume
138+ mountPath: /etc/prometheus/prometheus.yml
139+ subPath: prometheus.yml
140+ - name: prometheus-config-volume
141+ mountPath: /etc/prometheus/alerts.yml
142+ subPath: alerts.yml
143+ - name: prometheus-data
144+ mountPath: /prometheus
145+ ports:
146+ - containerPort: 9090
147+ name: prometheus
148+ protocol: TCP
149+ volumes:
150+ - name: prometheus-config-volume
151+ configMap:
152+ name: prometheus-config
153+ items:
154+ - key: prometheus
155+ path: prometheus.yml
156+ - key: prometheus-alerts
157+ path: alerts.yml
158+ - name: prometheus-data
159+ persistentVolumeClaim:
160+ claimName: prometheus-volume-claim
161+---
162+apiVersion: v1
163+kind: Service
164+metadata:
165+ name: prometheus-service
166+spec:
167+ type: NodePort
168+ selector:
169+ app: prometheus
170+ ports:
171+ - protocol: TCP
172+ port: 9090
173+ targetPort: 9090
174+ nodePort: 30090
175+ name: prometheus
176 ```
177
178-In case you need to debug what it is happening with the container you can run `docker logs <name_of_the_container>`. But if you want to get access to an interactive shell run:
179+</details>
180
181-```
182-$ docker exec -it <name_of_the_container> /bin/bash
183+```sh
184+$ microk8s kubectl apply -f prometheus-deployment.yml
185 ```
186
187-To see how to use the Prometheus OCI image with `docker-compose` and `microk8s` check the `examples/README.md` file.
188+You will now be able to connect to the Prometheus on `http://localhost:30090`.
189
190 ## Bugs and Features request
191
192@@ -72,6 +158,9 @@ In the title of the bug add `prometheus: <reason>`.
193
194 Make sure to include:
195
196-* The tag of the image you are using
197+* The digest of the image you are using, you can find it using this command replacing `<tag>` with the one you used to run the image:
198+```sh
199+$ docker images --no-trunc --quiet squeakywheel/prometheus:<tag>
200+```
201 * Reproduction steps for the deployment
202 * If it is a feature request, please provide as much detail as possible
203diff --git a/oci/examples/README.md b/oci/examples/README.md
204index 9377185..eed65b5 100644
205--- a/oci/examples/README.md
206+++ b/oci/examples/README.md
207@@ -36,10 +36,10 @@ $ microk8s kubectl create configmap prometheus-config \
208 --from-file=prometheus-alerts=config/alerts.yml
209 ```
210
211-Apply the `microk8s-deployments.yml`:
212+Apply the `prometheus-deployment.yml`:
213
214 ```
215-$ microk8s kubectl apply -f microk8s-deployments.yml
216+$ microk8s kubectl apply -f prometheus-deployment.yml
217 ```
218
219 Access `http://localhost:30090` and Prometheus will be running.
220diff --git a/oci/examples/microk8s-deployments.yml b/oci/examples/prometheus-deployment.yml
221similarity index 100%
222rename from oci/examples/microk8s-deployments.yml
223rename to oci/examples/prometheus-deployment.yml

Subscribers

People subscribed via source and target branches