use statefulSets and readinessProbes instead of initContainers

This commit is contained in:
2025-12-17 20:43:59 +05:30
parent 2bc8629208
commit 357099ae9f
5 changed files with 30 additions and 32 deletions

View File

@@ -6,7 +6,7 @@ metadata:
namespace: git-ops namespace: git-ops
data: data:
SEMAPHORE_DB_USER: "semaphore" SEMAPHORE_DB_USER: "semaphore"
SEMAPHORE_DB_HOST: "semaphore-db-service" SEMAPHORE_DB_HOST: "semaphore-db"
SEMAPHORE_DB_PORT: "3306" SEMAPHORE_DB_PORT: "3306"
SEMAPHORE_DB_DIALECT: "mysql" SEMAPHORE_DB_DIALECT: "mysql"
SEMAPHORE_DB: "semaphore" SEMAPHORE_DB: "semaphore"

View File

@@ -1,16 +1,15 @@
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: StatefulSet
metadata: metadata:
name: semaphore-db name: semaphore-db
namespace: git-ops namespace: git-ops
spec: spec:
strategy:
type: Recreate
replicas: 1
selector: selector:
matchLabels: matchLabels:
app: semaphore-db app: semaphore-db
serviceName: semaphore-db
replicas: 1
template: template:
metadata: metadata:
labels: labels:
@@ -34,10 +33,14 @@ spec:
name: semaphore-secrets name: semaphore-secrets
key: mysql_password key: mysql_password
volumeMounts: volumeMounts:
- name: db - name: semaphore-db
mountPath: /var/lib/mysql mountPath: /var/lib/mysql
subPath: db volumeClaimTemplates:
volumes: - metadata:
- name: db name: semaphore-db
persistentVolumeClaim: spec:
claimName: semaphore-longhorn accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 2Gi
storageClassName: longhorn

View File

@@ -1,14 +0,0 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: semaphore-longhorn
namespace: git-ops
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 2Gi
storageClassName: longhorn

View File

@@ -12,14 +12,15 @@ spec:
selector: selector:
app: semaphore app: semaphore
ports: ports:
- port: 3002 - name: http
port: 3002
targetPort: 3000 targetPort: 3000
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: semaphore-db-service name: semaphore-db
namespace: git-ops namespace: git-ops
spec: spec:
selector: selector:
@@ -27,3 +28,4 @@ spec:
ports: ports:
- port: 3306 - port: 3306
targetPort: 3306 targetPort: 3306
clusterIP: None

View File

@@ -16,15 +16,22 @@ spec:
labels: labels:
app: semaphore app: semaphore
spec: spec:
initContainers:
- name: wait-for-db
image: busybox
command: ['sh', '-c', 'until nc -z -v -w30 semaphore-db-service 3306; do echo "Waiting for database connection..."; sleep 5; done;']
containers: containers:
- name: semaphore - name: semaphore
image: public.ecr.aws/semaphore/pro/server:v2.16.46 image: public.ecr.aws/semaphore/pro/server:v2.16.46
readinessProbe:
exec:
command:
- sh
- -c
- |
nc -z semaphore-db.git-ops.svc.cluster.local 3306
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
ports: ports:
- containerPort: 3000 - name: http
containerPort: 3000
envFrom: envFrom:
- configMapRef: - configMapRef:
name: semaphore-config name: semaphore-config