Skip to content

Commit ff276c8

Browse files
committed
Prometheus integration for kubernetes
1 parent 896feec commit ff276c8

File tree

4 files changed

+153
-20
lines changed

4 files changed

+153
-20
lines changed

.idea/workspace.xml

+15-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tiltfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
k8s_yaml([
33
"kubernetes/infrastructure/keycloak/keycloak.yml",
44
"kubernetes/infrastructure/postgres/postgres.yml",
5-
"kubernetes/infrastructure/mongodb/mongodb.yml"
5+
"kubernetes/infrastructure/mongodb/mongodb.yml",
6+
"kubernetes/infrastructure/prometheus/prometheus.yml",
7+
"kubernetes/infrastructure/grafana/grafana.yml"
8+
69
])
710

811
# Define infrastructure resources
912
k8s_resource("keycloak", labels=["infra"], auto_init=True)
13+
k8s_resource("prometheus", labels=["infra"], auto_init=True)
14+
k8s_resource("grafana", labels=["infra"], auto_init=True)
1015
k8s_resource("course-postgres", labels=["infra"], auto_init=True)
1116
k8s_resource("review-mongodb", labels=["infra"], auto_init=True)
1217

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: grafana
5+
labels:
6+
app: grafana
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: grafana
12+
template:
13+
metadata:
14+
labels:
15+
app: grafana
16+
spec:
17+
containers:
18+
- name: grafana
19+
image: grafana/grafana:latest
20+
ports:
21+
- containerPort: 3000
22+
env:
23+
- name: GF_SECURITY_ADMIN_PASSWORD
24+
value: "admin"
25+
---
26+
apiVersion: v1
27+
kind: Service
28+
metadata:
29+
name: grafana
30+
labels:
31+
app: grafana
32+
spec:
33+
selector:
34+
app: grafana
35+
ports:
36+
- protocol: TCP
37+
port: 3000
38+
targetPort: 3000
39+
type: ClusterIP
40+
---
41+
apiVersion: networking.k8s.io/v1
42+
kind: Ingress
43+
metadata:
44+
name: grafana-ingress
45+
spec:
46+
rules:
47+
- host: grafana.local
48+
http:
49+
paths:
50+
- path: /
51+
pathType: Prefix
52+
backend:
53+
service:
54+
name: grafana
55+
port:
56+
number: 3000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: prometheus-config
5+
data:
6+
prometheus.yml: |
7+
global:
8+
scrape_interval: 15s
9+
scrape_configs:
10+
- job_name: 'spring-boot-app'
11+
metrics_path: '/actuator/prometheus'
12+
static_configs:
13+
- targets:
14+
- 'course-composite-service:80'
15+
- 'course-service:80'
16+
- 'review-service:80'
17+
- 'gateway-service:80'
18+
---
19+
apiVersion: apps/v1
20+
kind: Deployment
21+
metadata:
22+
name: prometheus
23+
spec:
24+
replicas: 1
25+
selector:
26+
matchLabels:
27+
app: prometheus
28+
template:
29+
metadata:
30+
labels:
31+
app: prometheus
32+
spec:
33+
containers:
34+
- name: prometheus
35+
image: prom/prometheus:latest
36+
args:
37+
- "--config.file=/etc/prometheus/prometheus.yml"
38+
ports:
39+
- containerPort: 9090
40+
volumeMounts:
41+
- name: config-volume
42+
mountPath: "/etc/prometheus/"
43+
volumes:
44+
- name: config-volume
45+
configMap:
46+
name: prometheus-config
47+
---
48+
apiVersion: v1
49+
kind: Service
50+
metadata:
51+
name: prometheus
52+
spec:
53+
selector:
54+
app: prometheus
55+
ports:
56+
- port: 9090
57+
targetPort: 9090
58+
protocol: TCP
59+
type: ClusterIP
60+
---
61+
apiVersion: networking.k8s.io/v1
62+
kind: Ingress
63+
metadata:
64+
name: prometheus-ingress
65+
spec:
66+
rules:
67+
- host: prometheus.local
68+
http:
69+
paths:
70+
- path: /
71+
pathType: Prefix
72+
backend:
73+
service:
74+
name: prometheus
75+
port:
76+
number: 9090

0 commit comments

Comments
 (0)