Skip to content

Commit 0bd6489

Browse files
authored
Setup K8s (minikube) (#7)
* feat: init k8s config * feat: use NodePort type for grafana, prometheus, and nginx to make it accessible from external
1 parent c1c53d9 commit 0bd6489

20 files changed

+453
-0
lines changed

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ services:
2121
postgres:
2222
image: postgres
2323
container_name: postgres
24+
ports:
25+
- 5432:5432
2426
restart: unless-stopped
2527
networks:
2628
- monitor
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
labels:
5+
io.kompose.service: db-data
6+
name: db-data
7+
spec:
8+
accessModes:
9+
- ReadWriteOnce
10+
resources:
11+
requests:
12+
storage: 100Mi

k8s/devtasker-deployment.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
annotations:
5+
kompose.cmd: kompose convert
6+
kompose.version: 1.36.0 (ae2a39403)
7+
labels:
8+
io.kompose.service: devtasker
9+
name: devtasker
10+
spec:
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
io.kompose.service: devtasker
15+
template:
16+
metadata:
17+
annotations:
18+
kompose.cmd: kompose convert
19+
kompose.version: 1.36.0 (ae2a39403)
20+
labels:
21+
io.kompose.service: devtasker
22+
spec:
23+
containers:
24+
- envFrom:
25+
- configMapRef:
26+
name: devtasker-env
27+
image: iqbalpa/go-devtasker:latest
28+
livenessProbe:
29+
exec:
30+
command:
31+
- curl
32+
- -f
33+
- http://localhost:3000/health
34+
failureThreshold: 5
35+
periodSeconds: 10
36+
name: devtasker
37+
ports:
38+
- containerPort: 3000
39+
protocol: TCP
40+
restartPolicy: Always

k8s/devtasker-env-configmap.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
data:
3+
APP_ENV: dev
4+
DB_HOST: postgres
5+
DB_NAME: devtasker
6+
DB_PASSWORD: iqbalpahlevi
7+
DB_PORT: "5432"
8+
DB_USER: postgres
9+
kind: ConfigMap
10+
metadata:
11+
labels:
12+
io.kompose.service: devtasker-devtasker-env
13+
name: devtasker-env

k8s/devtasker-service.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
annotations:
5+
kompose.cmd: kompose convert
6+
kompose.version: 1.36.0 (ae2a39403)
7+
labels:
8+
io.kompose.service: devtasker
9+
name: devtasker
10+
spec:
11+
ports:
12+
- name: "3000"
13+
port: 3000
14+
targetPort: 3000
15+
selector:
16+
io.kompose.service: devtasker

k8s/grafana-cm0-configmap.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
data:
3+
datasource.yml: |
4+
apiVersion: 1
5+
6+
datasources:
7+
- name: Prometheus
8+
type: prometheus
9+
url: http://prometheus:9090
10+
isDefault: true
11+
access: proxy
12+
editable: true
13+
kind: ConfigMap
14+
metadata:
15+
labels:
16+
io.kompose.service: grafana
17+
name: grafana-cm0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
labels:
5+
io.kompose.service: grafana-data
6+
name: grafana-data
7+
spec:
8+
accessModes:
9+
- ReadWriteOnce
10+
resources:
11+
requests:
12+
storage: 100Mi

k8s/grafana-deployment.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
annotations:
5+
kompose.cmd: kompose convert
6+
kompose.version: 1.36.0 (ae2a39403)
7+
labels:
8+
io.kompose.service: grafana
9+
name: grafana
10+
spec:
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
io.kompose.service: grafana
15+
strategy:
16+
type: Recreate
17+
template:
18+
metadata:
19+
annotations:
20+
kompose.cmd: kompose convert
21+
kompose.version: 1.36.0 (ae2a39403)
22+
labels:
23+
io.kompose.service: grafana
24+
spec:
25+
containers:
26+
- envFrom:
27+
- configMapRef:
28+
name: grafana-env
29+
image: grafana/grafana
30+
livenessProbe:
31+
exec:
32+
command:
33+
- wget
34+
- --spider
35+
- -q
36+
- http://localhost:3001
37+
failureThreshold: 5
38+
periodSeconds: 10
39+
name: grafana
40+
ports:
41+
- containerPort: 3001
42+
protocol: TCP
43+
volumeMounts:
44+
- mountPath: /etc/grafana/provisioning/datasources
45+
name: grafana-cm0
46+
- mountPath: /grafana
47+
name: grafana-data
48+
restartPolicy: Always
49+
volumes:
50+
- configMap:
51+
name: grafana-cm0
52+
name: grafana-cm0
53+
- name: grafana-data
54+
persistentVolumeClaim:
55+
claimName: grafana-data

k8s/grafana-env-configmap.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
data:
3+
GF_SECURITY_ADMIN_PASSWORD: grafana
4+
GF_SECURITY_ADMIN_USER: admin
5+
GF_SERVER_HTTP_PORT: "3001"
6+
kind: ConfigMap
7+
metadata:
8+
labels:
9+
io.kompose.service: grafana-grafana-env
10+
name: grafana-env

k8s/grafana-service.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
annotations:
5+
kompose.cmd: kompose convert
6+
kompose.version: 1.36.0 (ae2a39403)
7+
labels:
8+
io.kompose.service: grafana
9+
name: grafana
10+
spec:
11+
type: NodePort
12+
ports:
13+
- name: "3001"
14+
port: 3001
15+
targetPort: 3001
16+
nodePort: 31001
17+
selector:
18+
io.kompose.service: grafana

0 commit comments

Comments
 (0)