Skip to content

Commit 8d8b802

Browse files
committed
promtail for logs collection from student-api application only
1 parent 8fa2651 commit 8d8b802

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

k8s/promtail.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
apiVersion: v1
2+
kind: ServiceAccount
3+
metadata:
4+
name: promtail-serviceaccount
5+
namespace: observability
6+
---
7+
apiVersion: rbac.authorization.k8s.io/v1
8+
kind: ClusterRole
9+
metadata:
10+
name: promtail-clusterrole
11+
rules:
12+
- apiGroups: [""]
13+
resources:
14+
- nodes
15+
- services
16+
- pods
17+
verbs:
18+
- get
19+
- watch
20+
- list
21+
---
22+
apiVersion: rbac.authorization.k8s.io/v1
23+
kind: ClusterRoleBinding
24+
metadata:
25+
name: promtail-clusterrolebinding
26+
subjects:
27+
- kind: ServiceAccount
28+
name: promtail-serviceaccount
29+
namespace: observability
30+
roleRef:
31+
kind: ClusterRole
32+
name: promtail-clusterrole
33+
apiGroup: rbac.authorization.k8s.io
34+
---
35+
apiVersion: v1
36+
kind: ConfigMap
37+
metadata:
38+
name: promtail-config
39+
namespace: observability
40+
data:
41+
promtail.yaml: |
42+
server:
43+
http_listen_port: 9080
44+
grpc_listen_port: 0
45+
46+
positions:
47+
filename: /tmp/positions.yaml
48+
49+
clients:
50+
- url: http://loki.observability.svc.cluster.local:3100/loki/api/v1/push
51+
52+
scrape_configs:
53+
# VERY SPECIFIC - Only Flask API logs
54+
- job_name: flask-api-only
55+
static_configs:
56+
- targets:
57+
- localhost
58+
labels:
59+
job: flask-api
60+
__path__: /var/log/pods/*student-api*flask-api*/*.log
61+
---
62+
apiVersion: apps/v1
63+
kind: DaemonSet
64+
metadata:
65+
name: promtail
66+
namespace: observability
67+
labels:
68+
app: promtail
69+
spec:
70+
selector:
71+
matchLabels:
72+
app: promtail
73+
template:
74+
metadata:
75+
labels:
76+
app: promtail
77+
spec:
78+
serviceAccountName: promtail-serviceaccount
79+
hostNetwork: true
80+
containers:
81+
- name: promtail
82+
image: grafana/promtail:2.8.0
83+
args:
84+
- -config.file=/etc/promtail/promtail.yaml
85+
- -log.level=info
86+
volumeMounts:
87+
- name: config
88+
mountPath: /etc/promtail
89+
- name: positions
90+
mountPath: /tmp
91+
- name: logs
92+
mountPath: /var/log
93+
resources:
94+
requests:
95+
memory: "64Mi"
96+
cpu: "50m"
97+
limits:
98+
memory: "128Mi"
99+
cpu: "100m"
100+
securityContext:
101+
runAsUser: 0
102+
runAsGroup: 0
103+
volumes:
104+
- name: config
105+
configMap:
106+
name: promtail-config
107+
- name: positions
108+
emptyDir: {}
109+
- name: logs
110+
hostPath:
111+
path: /var/log
112+
tolerations:
113+
- operator: Exists

0 commit comments

Comments
 (0)