use statefulSets and readinessProbes instead of initContainers

This commit is contained in:
2025-12-17 20:43:24 +05:30
parent 239655d713
commit 2bc8629208
5 changed files with 38 additions and 52 deletions

View File

@@ -19,29 +19,26 @@ spec:
app: gitea-act-runner
spec:
restartPolicy: Always
hostNetwork: true
volumes:
- name: docker-certs
emptyDir: {}
- name: runner-data
persistentVolumeClaim:
claimName: gitea-act-runner-longhorn
initContainers:
- name: wait-for-gitea
image: busybox
command:
- sh
- -c
- |
while ! nc -z gitea.akshun-lab.cc 443; do
echo "Waiting for Gitea to be ready..."
sleep 5
done
echo "Gitea is ready!"
containers:
- name: runner
image: gitea/act_runner@sha256:8477d5b61b655caad4449888bae39f1f34bebd27db56cb15a62dccb3dcf3a944
command: ["sh", "-c", "while ! nc -z localhost 2376 </dev/null; do echo 'waiting for docker daemon...'; sleep 5; done; /sbin/tini -- run.sh"]
readinessProbe:
exec:
command:
- sh
- -c
- |
nc -z gitea-int-service.git-ops.svc.cluster.local 3000
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
env:
- name: DOCKER_HOST
value: tcp://localhost:2376

View File

@@ -1,15 +1,15 @@
---
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
name: gitea-db
namespace: git-ops
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: gitea-db
serviceName: gitea-db
replicas: 1
template:
metadata:
labels:
@@ -40,7 +40,12 @@ spec:
volumeMounts:
- name: gitea-db
mountPath: /var/lib/postgresql
volumes:
- name: gitea-db
persistentVolumeClaim:
claimName: gitea-db-new-longhorn
volumeClaimTemplates:
- metadata:
name: gitea-db
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 2Gi
storageClassName: longhorn

View File

@@ -12,18 +12,3 @@ spec:
requests:
storage: 2Gi
storageClassName: longhorn
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitea-db-new-longhorn
namespace: git-ops
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 2Gi
storageClassName: longhorn

View File

@@ -38,12 +38,12 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: gitea-db-service
name: gitea-db
namespace: git-ops
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: gitea-db
ports:
- protocol: TCP
port: 5432
targetPort: 5432
clusterIP: None

View File

@@ -16,20 +16,19 @@ spec:
labels:
app: gitea-app
spec:
initContainers:
- name: wait-for-db
image: busybox
command:
- sh
- -c
- |
until nc -z -v -w30 gitea-db-service 5432; do
echo "Waiting for psql database to be ready"
sleep 2
done
containers:
- name: gitea
image: gitea/gitea:1.25.2
readinessProbe:
exec:
command:
- sh
- -c
- |
nc -z gitea-db.git-ops.svc.cluster.local 5432
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
ports:
- containerPort: 22
name: ssh
@@ -43,7 +42,7 @@ spec:
- name: GITEA__database__DB_TYPE
value: "postgres"
- name: GITEA__database__HOST
value: "gitea-db-service:5432"
value: "gitea-db.git-ops.svc.cluster.local:5432"
- name: GITEA__database__NAME
value: "gitea"
- name: GITEA__database__USER