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
diff --git a/examples/README.md b/examples/README.md
0new file mode 1006440new file mode 100644
index 0000000..f36e8a3
--- /dev/null
+++ b/examples/README.md
@@ -0,0 +1,54 @@
1# Running the examples
2
3## docker-compose
4
5Install `docker-compose` from the Ubuntu archive:
6
7```
8$ sudo apt install -y docker-compose
9```
10
11Call `docker-compose` from the examples directory:
12
13```
14$ docker-compose up -d
15```
16
17Access `http://localhost:3100` and Loki will be running in the
18background. The `docker-compose` configuration file will start a
19`promtail` container as well, which will connect to the `loki`
20service.
21
22To stop these services, run:
23
24```
25$ docker-compose down
26```
27
28# Microk8s
29
30With microk8s running, enable the `dns` add-on:
31
32```
33$ microk8s enable dns
34```
35
36Create a configmap for the configuration files:
37
38```
39$ microk8s kubectl create configmap promtail-config \
40 --from-file=promtail=config/promtail-local-config-k8s.yaml
41```
42
43Apply the `loki-deployment.yml`:
44
45```
46$ microk8s kubectl apply -f loki-deployment.yml
47```
48
49Access `http://localhost:31000` and Loki will be running. For
50example, you can:
51
52```
53$ curl -s http://localhost:31000/loki/api/v1/label/job/values
54```
diff --git a/examples/config/promtail-local-config-k8s.yaml b/examples/config/promtail-local-config-k8s.yaml
0new file mode 10064455new file mode 100644
index 0000000..20dec1b
--- /dev/null
+++ b/examples/config/promtail-local-config-k8s.yaml
@@ -0,0 +1,18 @@
1server:
2 http_listen_port: 9080
3 grpc_listen_port: 0
4
5positions:
6 filename: /tmp/positions.yaml
7
8clients:
9 - url: http://loki-service:3100/loki/api/v1/push
10
11scrape_configs:
12- job_name: system
13 static_configs:
14 - targets:
15 - localhost
16 labels:
17 job: varlogs
18 __path__: /var/log/*log
diff --git a/examples/config/promtail-local-config.yaml b/examples/config/promtail-local-config.yaml
0new file mode 10064419new file mode 100644
index 0000000..ed06e8c
--- /dev/null
+++ b/examples/config/promtail-local-config.yaml
@@ -0,0 +1,18 @@
1server:
2 http_listen_port: 9080
3 grpc_listen_port: 0
4
5positions:
6 filename: /tmp/positions.yaml
7
8clients:
9 - url: http://loki:3100/loki/api/v1/push
10
11scrape_configs:
12- job_name: system
13 static_configs:
14 - targets:
15 - localhost
16 labels:
17 job: varlogs
18 __path__: /var/log/*log
diff --git a/examples/docker-compose.yml b/examples/docker-compose.yml
0new file mode 10064419new file mode 100644
index 0000000..22401a7
--- /dev/null
+++ b/examples/docker-compose.yml
@@ -0,0 +1,14 @@
1version: '2'
2
3services:
4 loki:
5 image: ubuntu/loki:edge
6 ports:
7 - 3100:3100
8 promtail:
9 image: ubuntu/loki:edge
10 entrypoint: ""
11 command: /usr/bin/promtail -config.file=/etc/loki/promtail-local-config.yaml
12 volumes:
13 - ./config/promtail-local-config.yaml:/etc/loki/promtail-local-config.yaml
14 depends_on: [ loki ]
diff --git a/examples/loki-deployment.yml b/examples/loki-deployment.yml
0new file mode 10064415new file mode 100644
index 0000000..cb14b05
--- /dev/null
+++ b/examples/loki-deployment.yml
@@ -0,0 +1,77 @@
1apiVersion: v1
2kind: Service
3metadata:
4 name: loki-service
5spec:
6 type: NodePort
7 selector:
8 app: loki
9 ports:
10 - protocol: TCP
11 port: 3100
12 targetPort: 3100
13 nodePort: 31000
14 name: loki
15---
16apiVersion: apps/v1
17kind: Deployment
18metadata:
19 name: loki-deployment
20spec:
21 replicas: 1
22 selector:
23 matchLabels:
24 app: loki
25 template:
26 metadata:
27 labels:
28 app: loki
29 spec:
30 containers:
31 - name: loki
32 image: ubuntu/loki:edge
33 ports:
34 - containerPort: 3100
35 name: loki
36 protocol: TCP
37---
38apiVersion: v1
39kind: Service
40metadata:
41 name: promtail-service
42spec:
43 selector:
44 app: promtail
45 ports:
46 - port: 9080
47---
48apiVersion: apps/v1
49kind: Deployment
50metadata:
51 name: promtail-deployment
52spec:
53 replicas: 1
54 selector:
55 matchLabels:
56 app: promtail
57 template:
58 metadata:
59 labels:
60 app: promtail
61 spec:
62 containers:
63 - name: promtail
64 image: ubuntu/loki:edge
65 command: [ "/usr/bin/promtail" ]
66 args: [ "-config.file=/etc/loki/promtail-local-config-k8s.yaml" ]
67 volumeMounts:
68 - name: promtail-config-volume
69 mountPath: /etc/loki/promtail-local-config-k8s.yaml
70 subPath: promtail-local-config-k8s.yaml
71 volumes:
72 - name: promtail-config-volume
73 configMap:
74 name: promtail-config
75 items:
76 - key: promtail
77 path: promtail-local-config-k8s.yaml

Subscribers

People subscribed via source and target branches