Install FerretDB in a cluster
Products: FastReport Corporate Server
MongoDB as data storage
This page describes the installation variant using FerretDB - open-source data storage, that uses PostgreSQL as database engine. Alternatively you can install MongoDB. You can read installation instruction using MongoDB here.
Difference with MongoDB
You won't feel any significant changes and will be able to communicate with the database in a similar way to MongoDB (including using MongoDB Compass and the mongosh utility). The only significant difference is that FerretDB does not support roles, so the creation of new database users should be done as follows:
db.createUser({
user: 'newuser',
pwd: 'newpassword',
roles: []
})
Start of installation
Prepare the namespaces:
FERRET_USER=any_name
FERRET_PASS=ferret_password
FERRET_SERVICE_NAME=fr-ferret
NAMESPACE=ferret
kubectl create namespace $NAMESPACE
Note of the FERRET_SERVICE_NAME variable¾this name will be used to access MongoDB from the report server in the future.
Deployment creation
cat <<EOF | kubectl apply -n $NAMESPACE -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: $FERRET_SERVICE_NAME
spec:
replicas: 1
selector:
matchLabels:
app: $FERRET_SERVICE_NAME
template:
metadata:
labels:
app: $FERRET_SERVICE_NAME
spec:
containers:
- name: $FERRET_SERVICE_NAME
image: ghcr.io/ferretdb/ferretdb-eval:2
ports:
- containerPort: 27017
env:
- name: POSTGRES_USER
value: $FERRET_USER
- name: POSTGRES_PASSWORD
value: $FERRET_PASS
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: volume
volumes:
- name: volume
persistentVolumeClaim:
claimName: fr-ferret-pvc
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ferret-storageclass
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: ferret-storage
namespace: $NAMESPACE
labels:
type: local
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
storageClassName: ferret-storageclass
local:
path: /devkube/ferretdb
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node1
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: fr-ferret-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: ferret-storageclass
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: Service
metadata:
name: $FERRET_SERVICE_NAME
labels:
app: $FERRET_SERVICE_NAME
spec:
selector:
app: $FERRET_SERVICE_NAME
ports:
- port: 27017
targetPort: 27017
EOF
The easiest way to verify the correctness of FerretDB installation is to use Kubernetes Dashboard, the installation of which was described earlier.
Attention
Check if the /devkube/ferretdb folder has been created on the node, if not, create it by yourself