--- apiVersion: v1 kind: Namespace metadata: name: fava --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: fava-data namespace: fava spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi --- apiVersion: v1 kind: ConfigMap metadata: name: fava-init-script namespace: fava data: init.sh: | #!/bin/sh set -e # Configure git git config --global credential.helper store git config --global http.sslVerify false # Clone or update the repository if [ ! -d "/data/contabilitat/.git" ]; then echo "Cloning repository..." git clone https://${GITEA_USERNAME}:${GITEA_PASSWORD}@git.rogi.casa/roger/contabilitat.git /data/contabilitat else echo "Repository exists, pulling latest changes..." cd /data/contabilitat git config --global --add safe.directory /data/contabilitat git pull fi echo "Repository ready at /data/contabilitat" --- apiVersion: apps/v1 kind: Deployment metadata: name: fava namespace: fava labels: app: fava spec: replicas: 1 selector: matchLabels: app: fava template: metadata: labels: app: fava spec: initContainers: - name: git-sync image: alpine/git:latest command: ["/bin/sh", "/scripts/init.sh"] env: - name: GITEA_USERNAME valueFrom: secretKeyRef: name: gitea-credentials key: username - name: GITEA_PASSWORD valueFrom: secretKeyRef: name: gitea-credentials key: password volumeMounts: - name: data mountPath: /data - name: init-script mountPath: /scripts containers: - name: fava image: yegle/fava:latest args: - "/data/contabilitat/ledger/main.beancount" - "-H" - "0.0.0.0" - "-p" - "5000" ports: - containerPort: 5000 name: http volumeMounts: - name: data mountPath: /data resources: requests: cpu: 100m memory: 128Mi limits: cpu: 500m memory: 512Mi livenessProbe: httpGet: path: / port: 5000 initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: httpGet: path: / port: 5000 initialDelaySeconds: 5 periodSeconds: 5 - name: git-sync-hourly image: alpine/git:latest command: - /bin/sh - -c - | while true; do echo "Syncing repository at $(date)" cd /data/contabilitat git config --global --add safe.directory /data/contabilitat git pull || echo "Failed to pull, will retry in 1 hour" echo "Next sync in 1 hour" sleep 3600 done env: - name: GITEA_USERNAME valueFrom: secretKeyRef: name: gitea-credentials key: username - name: GITEA_PASSWORD valueFrom: secretKeyRef: name: gitea-credentials key: password volumeMounts: - name: data mountPath: /data resources: requests: cpu: 10m memory: 32Mi limits: cpu: 100m memory: 128Mi volumes: - name: data persistentVolumeClaim: claimName: fava-data - name: init-script configMap: name: fava-init-script defaultMode: 0755 --- apiVersion: v1 kind: Service metadata: name: fava-service namespace: fava spec: type: ClusterIP selector: app: fava ports: - name: http port: 80 targetPort: 5000