24.06.2025

How to Deploy GnuCash in Kubernetes A Step-by-Step Guide for Developers

GnuCash is a powerful open-source application for managing personal and business finances, supporting double-entry accounting, multi-currency, and tax reporting. However, its traditional use on local machines limits accessibility and collaboration. For distributed teams and remote work, a centralized, scalable platform is essential. Kubernetes enables deploying GnuCash in the cloud, providing browser-based access, automatic scaling, and centralized data storage. This guide will walk you through setting up GnuCash in Kubernetes, transforming it into a modern financial accounting tool.

Creating or Downloading Containers

Option 1 - Pre-built Image

The image includes VNC for browser-based access.

# Pull official image with web access support

docker pull jlesage/gnucash

# Test run to verify

docker run -d --name gnucash-test -p 5800:5800 jlesage/gnucash

Option 2 - Custom Image

A custom image allows environment customization.

Create `Dockerfile`:

FROM alpine:3.17

# Install GnuCash and dependencies for web access

RUN apk add --no-cache gnucash dbus-x11 xvfb-run websockify x11vnc fluxbox

# Set up user

RUN adduser -D -u 1000 gnucash

# Startup script

COPY startapp.sh /startapp.sh

RUN chmod +x /startapp.sh

USER gnucash

WORKDIR /data

EXPOSE 5800

ENTRYPOINT ["/startapp.sh"]

Create `startapp.sh`:

#!/bin/sh

xvfb-run --server-args="-screen 0 1920x1080x24" \

dbus-launch --exit-with-session \

fluxbox &

websockify --web /usr/share/novnc 6080 localhost:5900 &

x11vnc -display :99 -forever -passwd "${X11VNC_PASSWORD:-secret}" &

gnucash "$@"

3. Build the image:

docker build -t my-gnucash:latest .

Deployment in Kubernetes

Architecture:

Picture 1 - GnuChash

Step 1 - Persistent Volume Claim

PVC stores GnuCash data.

`gnucash-pvc.yaml`:

apiVersion: v1

kind: PersistentVolumeClaim

metadata:

name: gnucash-data

namespace: finance

spec:

accessModes:

- ReadWriteOnce

storageClassName: ssd

resources:

requests:

storage: 20Gi

Step 2 - Deployment

Deploys GnuCash with persistent storage.

gnucash-deployment.yaml:

apiVersion: apps/v1

kind: Deployment

metadata:

name: gnucash

namespace: finance

spec:

replicas: 1

selector:

matchLabels:

app: gnucash

template:

metadata:

labels:

app: gnucash

spec:

securityContext:

runAsUser: 1000

fsGroup: 1000

containers:

- name: gnucash

image: jlesage/gnucash:latest

env:

- name: VNC_PASSWORD

valueFrom:

secretKeyRef:

name: gnucash-secrets

key: vnc-password

ports:

- containerPort: 5800

volumeMounts:

- name: gnucash-data

mountPath: /config

subPath: config

- name: gnucash-data

mountPath: /data

subPath: data

volumes:

- name: gnucash-data

persistentVolumeClaim:

claimName: gnucash-data

Step 3 - Service and Ingress

Enables access via a domain.

gnucash-service.yaml:

apiVersion: v1

kind: Service

metadata:

name: gnucash-service

namespace: finance

spec:

selector:

app: gnucash

ports:

- protocol: TCP

port: 5800

targetPort: 5800

apiVersion: networking.k8s.io/v1

kind: Ingress

metadata:

name: gnucash-ingress

namespace: finance

spec:

tls:

- hosts:

- finances.example.com

secretName: gnucash-tls

rules:

- host: finances.example.com

http:

paths:

- path: /

pathType: Prefix

backend:

service:

name: gnucash-service

port:

number: 5800

Step 4 - PostgreSQL (Optional)

PostgreSQL for multi-user mode.

apiVersion: v1

kind: Service

metadata:

name: gnucash-db

namespace: finance

spec:

selector:

app: gnucash-db

ports:

- port: 5432

apiVersion: apps/v1

kind: Deployment

metadata:

name: gnucash-db

namespace: finance

spec:

selector:

matchLabels:

app: gnucash-db

template:

metadata:

labels:

app: gnucash-db

spec:

containers:

- name: postgres

image: postgres:15

env:

- name: POSTGRES_USER

value: gnucash

- name: POSTGRES_PASSWORD

valueFrom:

secretKeyRef:

name: gnucash-secrets

key: db-password

- name: POSTGRES_DB

value: gnucash_data

volumeMounts:

- name: db-data

mountPath: /var/lib/postgresql/data

volumes:

- name: db-data

persistentVolumeClaim:

claimName: gnucash-data

Step 5 - Secrets

kubectl create secret generic gnucash-secrets -n finance \

--from-literal=vnc-password='YourStrongPassword!' \

--from-literal=db-password='DBSecret123!'

Final Setup

Initial Access:

  1. Open `https://finances.example.com`.
  2. Enter the VNC password from Secrets.
  3. Create a new file: File → New File → SQLite3/PostgreSQL.

Automatic Backup:

Daily data backup

apiVersion: batch/v1

kind: CronJob

metadata:

name: gnucash-backup

namespace: finance

spec:

schedule: "0 3 * * *"

jobTemplate:

spec:

template:

spec:

containers:

- name: backup

image: alpine:3.18

command:

- /bin/sh

- -c

- |

apk add postgresql-client

PGPASSWORD=$DB_PASSWORD pg_dump -h gnucash-db -U gnucash gnucash_data > /backup/gnucash-$(date +%F).sql

gzip /backup/gnucash-*.sql

env:

- name: DB_PASSWORD

valueFrom:

secretKeyRef:

name: gnucash-secrets

key: db-password
volumeMounts:

- name: backup-volume

mountPath: /backup

volumes:

- name: backup-volume

persistentVolumeClaim:

claimName: gnucash-data

Deploying GnuCash in Kubernetes ensures accessibility, scalability, and security for financial management. This guide enables you to create a robust system for your team or business.