Search code examples
postgresqlkubernetesdigital-oceandata-storage

Kubernetes postgres setup on digital ocean


it’s been driving me crazy for about a week now. Searched over the “whole” internet with no luck. used rexray, standard config, digital ocean setup etc.

Cannot make it working on digital ocean with block storage. Would be great if anyone could point me to some tutorial (preferable official kubernetes storage driver).

Here is my config for postgres:

          ... 
          volumeMounts:
            - name: postgres-storage
              mountPath: /var/lib/postgresql/data
      volumes:
        - name: postgres-storage
          persistentVolumeClaim:
            claimName: postgres-pv-claim

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-pv-claim 
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

---

apiVersion: v1
kind: PersistentVolume
metadata:
  name: postgres-volume
spec:
  capacity:
    storage: 3Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain

Any help is highly appreciated.


Solution

  • Kubernetes does not support Volume plugin for DigitalOcean.

    But you can use this using FlexVolume plugin as external storage.

    • Digital Ocean Flex Plugin
    • Digital Ocean External Provisioner

    See this comment in a PR for DigitalOcean volume support.

    If you want to use DigitalOcean block storage, see Kubernetes DigitalOcean Provisioner to setup digitalocean-flexplugin.