Kubernetes deployment
Prerequisites
- An available StorageClass, or pre-provisioned PVs that match the PVCs.
- PostgreSQL and Redis connection addresses and credentials. The configuration below uses PostgreSQL 17 and Redis 7; the database account must have permission to migrate the schema.
Create the namespace and installation token
Inject the installation token through a Secret so it stays the same if the Pod restarts during installation:
kubectl create namespace sayrud
umask 077
openssl rand -hex 24 > sayrud-setup-token
kubectl -n sayrud create secret generic sayrud-setup --from-file=token=sayrud-setup-tokenKeep the local sayrud-setup-token file for the installation page. When SAYRUD_SETUP_TOKEN is set, the program does not print its value in the logs.
Create the application resources
Save the following as sayrud.yaml. It uses the default StorageClass; if your cluster has none, set the actual storageClassName in the spec of both PVCs.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: sayrud-config
namespace: sayrud
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: sayrud-data
namespace: sayrud
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sayrud
namespace: sayrud
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: sayrud
template:
metadata:
labels:
app: sayrud
spec:
terminationGracePeriodSeconds: 45
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
fsGroupChangePolicy: OnRootMismatch
containers:
- name: sayrud
image: ghcr.io/sayrud/sayrud:latest
imagePullPolicy: IfNotPresent
args: ["web", "--port", "2830", "--config", "/home/app/config/sayrud.yaml"]
env:
- name: SAYRUD_SETUP_TOKEN
valueFrom:
secretKeyRef:
name: sayrud-setup
key: token
ports:
- name: http
containerPort: 2830
volumeMounts:
- name: config
mountPath: /home/app/config
- name: data
mountPath: /home/app/data
startupProbe:
httpGet:
path: /-/healthz
port: http
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 60
readinessProbe:
httpGet:
path: /-/readyz
port: http
periodSeconds: 5
timeoutSeconds: 5
livenessProbe:
httpGet:
path: /-/healthz
port: http
periodSeconds: 10
timeoutSeconds: 3
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: "1"
memory: 1Gi
volumes:
- name: config
persistentVolumeClaim:
claimName: sayrud-config
- name: data
persistentVolumeClaim:
claimName: sayrud-data
---
apiVersion: v1
kind: Service
metadata:
name: sayrud
namespace: sayrud
spec:
selector:
app: sayrud
ports:
- name: http
port: 2830
targetPort: http
type: ClusterIPThe configuration directory is mounted on a writable PVC so the installation wizard can create files there.
Deploy and check the status:
kubectl apply -f sayrud.yaml
kubectl -n sayrud rollout status deployment/sayrud --timeout=300s
kubectl -n sayrud get pods,pvc
kubectl -n sayrud logs deployment/sayrud --tail=100Complete the web installation
Forward the port on your computer and leave the command running:
kubectl -n sayrud port-forward service/sayrud 2830:2830Open http://localhost:2830/setup, enter the token from the local sayrud-setup-token file, and follow the web installation guide to configure connections and create the administrator.
After installation, configuration is stored in the sayrud-config PVC and attachments in the sayrud-data PVC.
To use a domain name, configure your cluster’s Ingress or gateway for sayrud:2830 and enable HTTPS and WebSocket support.
Upgrade
Back up the database, configuration, and uploaded files, then change the image version in the manifest and run:
kubectl apply -f sayrud.yaml
kubectl -n sayrud rollout status deployment/sayrud --timeout=300s
kubectl -n sayrud logs deployment/sayrud --tail=100Multiple replicas
After completing installation once, prepare the shared resources for scaling:
- Connect all replicas to the same PostgreSQL database and Redis instance.
- Distribute the same configuration, especially the same
auth.secret_key. You can mount the generated configuration as a Kubernetes Secret; read-only access is sufficient during normal operation. Restart the Pods after changing it. - Store attachments in shared storage such as S3 or a
ReadWriteManyvolume. Migrate existing local files first.