emberstack/docker-sftp

how to add a volume in kubernetes

londonanthonyoleary opened this issue · 2 comments

Hi,
unfortunately there is no default persistence i discovered for when a pod is restarted,

i created a new pvc in kubernetes called sftp-pvc. in the same namespace as the sftp service is deployed,

to use this for persistence storage, would i just add this to the values.yaml

storage:
volumeMounts: ["/data"]
volumes: ["sftp-pvc"]

Thanks

Hi. I have spent half of the day understanding how everything works and what parameters to use.

You could use my terraform as a baseline:

resource "kubernetes_persistent_volume_claim_v1" "sftp_storage" {
  metadata {
    name      = "sftp-storage-pvc"
    namespace = "staging"
  }
  spec {
    access_modes = ["ReadWriteOnce"]
    resources {
      requests = {
        storage = "5Gi"
      }
    }
  }
}

resource "helm_release" "sftp_server" {
  name             = "sftp"
  namespace        = "staging"
  chart            = "sftp"
  repository       = "https://emberstack.github.io/helm-charts"
  create_namespace = false

  values = [yamlencode(
    {
      configuration = {
        Global = {
          Chroot = {
            Directory = "%h"
            StartPath = "sftp"
          }
          Directories = ["sftp"]
        }
        Users = [
          {
            Username : data.sops_file.this.data["sftp_username"]
            Password : data.sops_file.this.data["sftp_password"]
          }
        ]
      }
      storage = {
        volumes = [
          {
            name = "sftp-storage"
            persistentVolumeClaim = {
              claimName = "sftp-storage-pvc" # should be static, due to we use dynamic PVC
            }
          }
        ]
        volumeMounts = [
          {
            name      = "sftp-storage"
            mountPath = "/home/${data.sops_file.this.data["sftp_username"]}/sftp"
          }
        ]
      }
    }
  )]

}

@romikoops thanks a lot for your work!

sftp:
  configuration:
    Global:
      Chroot:
        Directory: "%h"
        StartPath: sftp
      Directories:
        - sftp
    Users:
      - Username: "user"
        Password: "password"
        PublicKeys:
          - "key"
        Chroot:
          Directories: "sftp"
  storage:
    volumes:
      - name: "sftp-storage"
        persistentVolumeClaim:
          claimName: "sftp-storage-pvc"
    volumeMounts:
      - name: "sftp-storage"
        mountPath: "/home/user/sftp"

In case anyone wants to copy straight into a values.yaml
Dont forget the corresponding pvc ;)