I'm trying to figure out how to launch a web application in a Kubernetes cluster on AWS. Right now I'm not certain about a database. I can see that one can use raw block volumes, which are supposedly faster:
This mode is useful to provide a Pod the fastest possible way to access a volume, without any filesystem layer between the Pod and the volume.
And they seem to be recommended particularly for databases:
There are some specialized applications that require direct access to a block device because, for example, the file system layer introduces unneeded overhead. The most common case is databases, which prefer to organize their data directly on the underlying storage.
By databases they supposedly mean PostgreSQL, MariaDB, Redis, whatever.
As such, I wonder if I should use raw block volumes for databases. Because on one hand they recommend it, but I didn't see an example. If so, should I create a custom database image to mount the device into the directory? Interestingly, Kubegres doesn't seem to be using block volumes:
My test yaml file:
apiVersion: apps/v1 kind: Deployment metadata: name: mydeployment namespace: myns spec: replicas: 1 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: app image: mariadb env: - name: MARIADB_ALLOW_EMPTY_ROOT_PASSWORD value: '1' volumeDevices: - name: persistent-storage devicePath: /dev/xvda volumes: - name: persistent-storage persistentVolumeClaim: claimName: ebs-claim --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: ebs-claim namespace: myns spec: accessModes: - ReadWriteOnce storageClassName: gp2 volumeMode: Block resources: requests: storage: 1Gi