docker-sftp icon indicating copy to clipboard operation
docker-sftp copied to clipboard

how to add a volume in kubernetes

Open londonanthonyoleary opened this issue 2 years ago • 1 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

londonanthonyoleary avatar Jul 05 '22 10:07 londonanthonyoleary

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 avatar Jul 18 '22 19:07 romikoops