2

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.

https://kubernetes.io/docs/concepts/storage/persistent-volumes/

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.

https://kubernetes.io/blog/2019/03/07/raw-block-volume-support-to-beta/

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:

https://github.com/reactive-tech/kubegres/blob/v1.12/controllers/spec/template/yaml/PrimaryStatefulSetTemplate.yaml#L19-L27

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
x-yuri
  • 143
  • 4

0 Answers0