Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add a volume in kubernetes #120

Open
londonanthonyoleary opened this issue Jul 5, 2022 · 2 comments
Open

how to add a volume in kubernetes #120

londonanthonyoleary opened this issue Jul 5, 2022 · 2 comments

Comments

@londonanthonyoleary
Copy link

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

@romikoops
Copy link

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"
          }
        ]
      }
    }
  )]

}

@Rohmilchkaese
Copy link

@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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants