Skip to content

Commit 7915775

Browse files
UltimateFormUltimateForm
andauthored
Feat/kuberize (#2)
* feat: Add health check endpoint and Kubernetes configuration for gopen-api * feat: more kube stuff * feat: Introduce Neo4j database setup with migrations and secure JWT signing via Docker secrets. * feat: Add fallback to environment variable for JWT sign secret if file is not found. * feat: Add Kubernetes deployment and service configuration for gopen-api * feat: Add Kubernetes configuration files and update environment settings for gopen-api * feat: skaffold for local k8s --------- Co-authored-by: UltimateForm <UltimateForm@github.com>
1 parent 2940d6c commit 7915775

15 files changed

Lines changed: 295 additions & 1 deletion

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.git
2+
kube/
3+
api/bruno/
4+
LICENSE
5+
README.md
6+
# Ignore the other Dockerfile when building one
7+
docker/*.Dockerfile
8+
skaffold.yaml

api/bruno/environments/LOCAL.bru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
vars {
2-
BASE_URL: http://localhost:3000
2+
BASE_URL: http://localhost:30000
33
}
44
vars:secret [
55
USERNAME,
File renamed without changes.

docker/api.Dockerfile.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
kube
2+
.vscode
3+
.secrets
4+
.github
5+
migrations
6+
docker
7+
.env
8+
kube
9+
api

docker/migrator.Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM neo4j:community-trixie
2+
3+
WORKDIR /migrator
4+
5+
RUN mkdir migrations
6+
7+
COPY ./migrations ./migrations
8+
9+
CMD [ "cypher-shell", "--help" ]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
kube
2+
docker
3+
internal
4+
cmd
5+
.backups
6+
.github
7+
.secrets
8+
api

kube/api/api.configmap.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: dotpen-api.cfg
5+
data:
6+
NEO4J_URI: bolt://gopen-db
7+
NEO4J_USERNAME: neo4j
8+
NEO4J_PASSWORD: testpassword
9+
JWT_SIGN: 74JkywUHV3tmT9Yj7r4gsH22Md5Df45n

kube/api/api.deployment.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
annotations:
5+
deployment.kubernetes.io/revision: "1"
6+
labels:
7+
app: gopen
8+
name: gopen-api
9+
spec:
10+
progressDeadlineSeconds: 30
11+
replicas: 3
12+
revisionHistoryLimit: 6
13+
selector:
14+
matchLabels:
15+
app: gopen-api
16+
strategy:
17+
rollingUpdate:
18+
maxSurge: 2
19+
maxUnavailable: 1
20+
type: RollingUpdate
21+
template:
22+
metadata:
23+
labels:
24+
app: gopen-api
25+
spec:
26+
containers:
27+
- image: gopen-api:latest
28+
imagePullPolicy: IfNotPresent
29+
name: gopen-api
30+
envFrom:
31+
- configMapRef:
32+
name: dotpen-api.cfg
33+
ports:
34+
- containerPort: 3000
35+
protocol: TCP
36+
livenessProbe:
37+
httpGet:
38+
path: health
39+
port: 3000
40+
initialDelaySeconds: 2
41+
failureThreshold: 1
42+
successThreshold: 1
43+
resources:
44+
requests:
45+
cpu: 100m
46+
memory: 128Mi
47+
limits:
48+
cpu: 500m
49+
memory: 512Mi
50+
restartPolicy: Always

kube/api/api.service.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app: gopen
6+
name: gopen-api
7+
spec:
8+
ports:
9+
- nodePort: 30000
10+
port: 3000
11+
protocol: TCP
12+
targetPort: 3000
13+
selector:
14+
app: gopen-api
15+
type: NodePort

kube/db/data.pvc.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: gopen-data.pvc
5+
spec:
6+
accessModes:
7+
- ReadWriteOnce
8+
resources:
9+
requests:
10+
storage: 500Mi

0 commit comments

Comments
 (0)