Skip to content

Commit bb09a33

Browse files
committed
include adminer into k8s
1 parent 795c9c9 commit bb09a33

File tree

5 files changed

+123
-16
lines changed

5 files changed

+123
-16
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Adminer Deployment
2+
{{- if .Values.adminer.enabled }}
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: {{ .Release.Name }}-adminer
7+
labels:
8+
app: adminer
9+
spec:
10+
replicas: {{ .Values.adminer.replicaCount }}
11+
selector:
12+
matchLabels:
13+
app: adminer
14+
template:
15+
metadata:
16+
labels:
17+
app: adminer
18+
spec:
19+
containers:
20+
- name: adminer
21+
image: "{{ .Values.adminer.image.repository }}:{{ .Values.adminer.image.tag }}"
22+
imagePullPolicy: {{ .Values.adminer.image.pullPolicy }}
23+
ports:
24+
- containerPort: {{ .Values.adminer.service.port }}
25+
volumeMounts:
26+
{{- range .Values.adminer.volumeMounts }}
27+
- name: {{ .name }}
28+
mountPath: {{ .mountPath }}
29+
{{- end }}
30+
volumes:
31+
{{- range .Values.adminer.volumes }}
32+
- name: {{ .name }}
33+
emptyDir: {}
34+
{{- end }}
35+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Adminer Service
2+
{{- if .Values.adminer.enabled }}
3+
apiVersion: v1
4+
kind: Service
5+
metadata:
6+
name: {{ .Release.Name }}-adminer
7+
labels:
8+
app: adminer
9+
spec:
10+
type: {{ .Values.adminer.service.type }}
11+
ports:
12+
- port: {{ .Values.adminer.service.port }}
13+
targetPort: {{ .Values.adminer.service.port }}
14+
selector:
15+
app: adminer
16+
{{- end }}

kubernetes/charts/SDP/values.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,30 @@ frontend:
5252
type: ClusterIP
5353
port: 80
5454
env:
55-
VITE_API_URL: http://{{ .Release.Name }}-backend.default.svc.cluster.local:8000
55+
VITE_API_URL: http://{{ .Release.Name }}-backend.default.svc.cluster.local:8000
56+
57+
# Adminer configuration
58+
adminer:
59+
enabled: false
60+
image:
61+
repository: dperezsa/adminer
62+
tag: latest
63+
pullPolicy: IfNotPresent
64+
replicaCount: 1
65+
resources:
66+
limits:
67+
cpu: 200m
68+
memory: 256Mi
69+
requests:
70+
cpu: 100m
71+
memory: 128Mi
72+
service:
73+
type: ClusterIP
74+
port: 80
75+
env: {}
76+
volumeMounts:
77+
- name: sqlite-data
78+
mountPath: /var/www/html/data
79+
volumes:
80+
- name: sqlite-data
81+
emptyDir: {}

scripts/deploy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ HELM_CHART_DIR="./kubernetes/charts/sdp"
88
RELEASE_NAME="sdp"
99
BACKEND_PORT=8000
1010
FRONTEND_PORT=5173
11+
ADMINER_PORT=5173
1112
TIMEOUT=300 # 5 minute timeout
1213

1314
# Main deployment

scripts/forward.sh

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,80 @@ HELM_CHART_DIR="./kubernetes/charts/sdp"
88
RELEASE_NAME="SDP"
99
BACKEND_PORT=8000
1010
FRONTEND_PORT=5173
11+
ADMINER_PORT=8080
1112

1213
# Get pod names using go-template
1314
echo "🔍 Getting pod names..."
1415
PODS=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
1516

16-
# Identify backend and frontend pods
17+
# Identify backend, frontend, and adminer pods
1718
BACKEND_POD=""
1819
FRONTEND_POD=""
20+
ADMINER_POD=""
1921

2022
for pod in $PODS; do
2123
if echo "$pod" | grep -q "backend"; then
2224
BACKEND_POD="$pod"
2325
elif echo "$pod" | grep -q "frontend"; then
2426
FRONTEND_POD="$pod"
27+
elif echo "$pod" | grep -q "adminer"; then
28+
ADMINER_POD="$pod"
2529
fi
2630
done
2731

32+
# Report found pods
2833
if [ -z "$BACKEND_POD" ]; then
29-
echo "❌ Could not find backend pod"
30-
exit 1
34+
echo "⚠️ Could not find backend pod, skipping..."
35+
else
36+
echo "✅ Backend pod: $BACKEND_POD"
3137
fi
3238

3339
if [ -z "$FRONTEND_POD" ]; then
34-
echo "❌ Could not find frontend pod"
35-
exit 1
40+
echo "⚠️ Could not find frontend pod, skipping..."
41+
else
42+
echo "✅ Frontend pod: $FRONTEND_POD"
3643
fi
3744

38-
echo "✅ Backend pod: $BACKEND_POD"
39-
echo "✅ Frontend pod: $FRONTEND_POD"
45+
if [ -z "$ADMINER_POD" ]; then
46+
echo "⚠️ Could not find adminer pod, skipping..."
47+
else
48+
echo "✅ Adminer pod: $ADMINER_POD"
49+
fi
4050

41-
# Start port forwarding
51+
# Start port forwarding for available pods
4252
echo "🔌 Starting port forwarding..."
43-
echo "🌐 Backend API: http://localhost:$BACKEND_PORT"
44-
echo "🖥️ Frontend: http://localhost:$FRONTEND_PORT"
4553

46-
kubectl port-forward pod/$BACKEND_POD $BACKEND_PORT:8000 &
47-
BACKEND_PID=$!
54+
if [ -n "$BACKEND_POD" ]; then
55+
echo "🌐 Backend API: http://localhost:$BACKEND_PORT"
56+
kubectl port-forward pod/$BACKEND_POD $BACKEND_PORT:8000 &
57+
BACKEND_PID=$!
58+
else
59+
BACKEND_PID=""
60+
fi
4861

49-
kubectl port-forward pod/$FRONTEND_POD $FRONTEND_PORT:80 &
50-
FRONTEND_PID=$!
62+
if [ -n "$FRONTEND_POD" ]; then
63+
echo "🖥️ Frontend: http://localhost:$FRONTEND_PORT"
64+
kubectl port-forward pod/$FRONTEND_POD $FRONTEND_PORT:80 &
65+
FRONTEND_PID=$!
66+
else
67+
FRONTEND_PID=""
68+
fi
69+
70+
if [ -n "$ADMINER_POD" ]; then
71+
echo "🛠️ Adminer: http://localhost:$ADMINER_PORT"
72+
kubectl port-forward pod/$ADMINER_POD $ADMINER_PORT:80 &
73+
ADMINER_PID=$!
74+
else
75+
ADMINER_PID=""
76+
fi
5177

5278
# Cleanup on exit
5379
cleanup() {
5480
echo "🛑 Stopping port forwarding..."
55-
kill $BACKEND_PID $FRONTEND_PID 2>/dev/null || true
81+
# Only kill PIDs that exist
82+
[ -n "$BACKEND_PID" ] && kill $BACKEND_PID 2>/dev/null || true
83+
[ -n "$FRONTEND_PID" ] && kill $FRONTEND_PID 2>/dev/null || true
84+
[ -n "$ADMINER_PID" ] && kill $ADMINER_PID 2>/dev/null || true
5685
exit 0
5786
}
5887
trap cleanup INT

0 commit comments

Comments
 (0)