Merge ~sergiodj/ubuntu-docker-images/+git/loki:examples into ~ubuntu-docker-images/ubuntu-docker-images/+git/loki:2.4-22.04

Proposed by Sergio Durigan Junior
Status: Merged
Merged at revision: cb98f9a9efba1aefea0c3cec53dc73f7e19a8af1
Proposed branch: ~sergiodj/ubuntu-docker-images/+git/loki:examples
Merge into: ~ubuntu-docker-images/ubuntu-docker-images/+git/loki:2.4-22.04
Diff against target: 211 lines (+181/-0)
5 files modified
examples/README.md (+54/-0)
examples/config/promtail-local-config-k8s.yaml (+18/-0)
examples/config/promtail-local-config.yaml (+18/-0)
examples/docker-compose.yml (+14/-0)
examples/loki-deployment.yml (+77/-0)
Reviewer Review Type Date Requested Status
Bryce Harrington Approve
Athos Ribeiro Pending
Canonical Server Pending
Review via email: mp+419244@code.launchpad.net

Description of the change

This MP adds the docker-compose and microk8s examples to the Loki ROCK.

There's not much to say here; the docker-compose.yaml should be pretty straightforward, and the microk8s deployment file, albeit a bit more involved, also follows what we've already been doing for our other images.

Tested locally, everything is working as expected.

To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

Just a code review, didn't test the commands, but no obvious typos or logic issues. LGTM, +1.

review: Approve
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thanks, Bryce. Merged.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/examples/README.md b/examples/README.md
2new file mode 100644
3index 0000000..f36e8a3
4--- /dev/null
5+++ b/examples/README.md
6@@ -0,0 +1,54 @@
7+# Running the examples
8+
9+## docker-compose
10+
11+Install `docker-compose` from the Ubuntu archive:
12+
13+```
14+$ sudo apt install -y docker-compose
15+```
16+
17+Call `docker-compose` from the examples directory:
18+
19+```
20+$ docker-compose up -d
21+```
22+
23+Access `http://localhost:3100` and Loki will be running in the
24+background. The `docker-compose` configuration file will start a
25+`promtail` container as well, which will connect to the `loki`
26+service.
27+
28+To stop these services, run:
29+
30+```
31+$ docker-compose down
32+```
33+
34+# Microk8s
35+
36+With microk8s running, enable the `dns` add-on:
37+
38+```
39+$ microk8s enable dns
40+```
41+
42+Create a configmap for the configuration files:
43+
44+```
45+$ microk8s kubectl create configmap promtail-config \
46+ --from-file=promtail=config/promtail-local-config-k8s.yaml
47+```
48+
49+Apply the `loki-deployment.yml`:
50+
51+```
52+$ microk8s kubectl apply -f loki-deployment.yml
53+```
54+
55+Access `http://localhost:31000` and Loki will be running. For
56+example, you can:
57+
58+```
59+$ curl -s http://localhost:31000/loki/api/v1/label/job/values
60+```
61diff --git a/examples/config/promtail-local-config-k8s.yaml b/examples/config/promtail-local-config-k8s.yaml
62new file mode 100644
63index 0000000..20dec1b
64--- /dev/null
65+++ b/examples/config/promtail-local-config-k8s.yaml
66@@ -0,0 +1,18 @@
67+server:
68+ http_listen_port: 9080
69+ grpc_listen_port: 0
70+
71+positions:
72+ filename: /tmp/positions.yaml
73+
74+clients:
75+ - url: http://loki-service:3100/loki/api/v1/push
76+
77+scrape_configs:
78+- job_name: system
79+ static_configs:
80+ - targets:
81+ - localhost
82+ labels:
83+ job: varlogs
84+ __path__: /var/log/*log
85diff --git a/examples/config/promtail-local-config.yaml b/examples/config/promtail-local-config.yaml
86new file mode 100644
87index 0000000..ed06e8c
88--- /dev/null
89+++ b/examples/config/promtail-local-config.yaml
90@@ -0,0 +1,18 @@
91+server:
92+ http_listen_port: 9080
93+ grpc_listen_port: 0
94+
95+positions:
96+ filename: /tmp/positions.yaml
97+
98+clients:
99+ - url: http://loki:3100/loki/api/v1/push
100+
101+scrape_configs:
102+- job_name: system
103+ static_configs:
104+ - targets:
105+ - localhost
106+ labels:
107+ job: varlogs
108+ __path__: /var/log/*log
109diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml
110new file mode 100644
111index 0000000..22401a7
112--- /dev/null
113+++ b/examples/docker-compose.yml
114@@ -0,0 +1,14 @@
115+version: '2'
116+
117+services:
118+ loki:
119+ image: ubuntu/loki:edge
120+ ports:
121+ - 3100:3100
122+ promtail:
123+ image: ubuntu/loki:edge
124+ entrypoint: ""
125+ command: /usr/bin/promtail -config.file=/etc/loki/promtail-local-config.yaml
126+ volumes:
127+ - ./config/promtail-local-config.yaml:/etc/loki/promtail-local-config.yaml
128+ depends_on: [ loki ]
129diff --git a/examples/loki-deployment.yml b/examples/loki-deployment.yml
130new file mode 100644
131index 0000000..cb14b05
132--- /dev/null
133+++ b/examples/loki-deployment.yml
134@@ -0,0 +1,77 @@
135+apiVersion: v1
136+kind: Service
137+metadata:
138+ name: loki-service
139+spec:
140+ type: NodePort
141+ selector:
142+ app: loki
143+ ports:
144+ - protocol: TCP
145+ port: 3100
146+ targetPort: 3100
147+ nodePort: 31000
148+ name: loki
149+---
150+apiVersion: apps/v1
151+kind: Deployment
152+metadata:
153+ name: loki-deployment
154+spec:
155+ replicas: 1
156+ selector:
157+ matchLabels:
158+ app: loki
159+ template:
160+ metadata:
161+ labels:
162+ app: loki
163+ spec:
164+ containers:
165+ - name: loki
166+ image: ubuntu/loki:edge
167+ ports:
168+ - containerPort: 3100
169+ name: loki
170+ protocol: TCP
171+---
172+apiVersion: v1
173+kind: Service
174+metadata:
175+ name: promtail-service
176+spec:
177+ selector:
178+ app: promtail
179+ ports:
180+ - port: 9080
181+---
182+apiVersion: apps/v1
183+kind: Deployment
184+metadata:
185+ name: promtail-deployment
186+spec:
187+ replicas: 1
188+ selector:
189+ matchLabels:
190+ app: promtail
191+ template:
192+ metadata:
193+ labels:
194+ app: promtail
195+ spec:
196+ containers:
197+ - name: promtail
198+ image: ubuntu/loki:edge
199+ command: [ "/usr/bin/promtail" ]
200+ args: [ "-config.file=/etc/loki/promtail-local-config-k8s.yaml" ]
201+ volumeMounts:
202+ - name: promtail-config-volume
203+ mountPath: /etc/loki/promtail-local-config-k8s.yaml
204+ subPath: promtail-local-config-k8s.yaml
205+ volumes:
206+ - name: promtail-config-volume
207+ configMap:
208+ name: promtail-config
209+ items:
210+ - key: promtail
211+ path: promtail-local-config-k8s.yaml

Subscribers

People subscribed via source and target branches