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 app: gitea-act-runner
spec: spec:
restartPolicy: Always restartPolicy: Always
hostNetwork: true
volumes: volumes:
- name: docker-certs - name: docker-certs
emptyDir: {} emptyDir: {}
- name: runner-data - name: runner-data
persistentVolumeClaim: persistentVolumeClaim:
claimName: gitea-act-runner-longhorn 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: containers:
- name: runner - name: runner
image: gitea/act_runner@sha256:8477d5b61b655caad4449888bae39f1f34bebd27db56cb15a62dccb3dcf3a944 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"] 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: env:
- name: DOCKER_HOST - name: DOCKER_HOST
value: tcp://localhost:2376 value: tcp://localhost:2376

View File

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

View File

@@ -12,18 +12,3 @@ spec:
requests: requests:
storage: 2Gi storage: 2Gi
storageClassName: longhorn 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 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: gitea-db-service name: gitea-db
namespace: git-ops namespace: git-ops
spec: spec:
ports:
- port: 5432
targetPort: 5432
selector: selector:
app: gitea-db app: gitea-db
ports: clusterIP: None
- protocol: TCP
port: 5432
targetPort: 5432

View File

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