terraform-provider-iterative icon indicating copy to clipboard operation
terraform-provider-iterative copied to clipboard

Support volume mounts (e.g. nfs) for Kubernetes

Open sjawhar opened this issue 1 year ago • 3 comments

Requested Functionality

If you're using k8s as your compute environment and you're operating on-prem, it's quite likely that you also have some kind of shared storage system (e.g. NFS). The user should be able to specify such volume mounts for their TPI task.

Candidate Implementation

See https://github.com/iterative/terraform-provider-iterative/compare/master...sjawhar:terraform-provider-iterative:feature/nfs-volume#diff-0fe990bc324a7948aa5a28972474908770afb9f012a7d0586ee0b4af8f808d8eR200-R216

Relevant section in TF would look like this:

resource "iterative_task" "task_with_nfs_volume" {
  cloud = "k8s"
  nfs_volume {
    server      = "10.0.20.3"
    server_path = "/data/projects"
    mount_path  = "/projects"
  }
}

sjawhar avatar Sep 05 '22 23:09 sjawhar

Isn't a StorageClass the traditional approach to solve this use case? 🤔

0x2b3bfa0 avatar Sep 06 '22 02:09 0x2b3bfa0

Isn't a StorageClass the traditional approach to solve this use case? thinking

I don't think so? I based my implementation on the Kubernetes plugin for Jenkins, which generates pod specs that look like this:

apiVersion: "v1"
kind: "Pod"
spec:
  containers:
  - command:
    - "/bin/bash"
    image: "python3.9"
    volumeMounts:
    - mountPath: "/mount/path/here"
      name: "volume-0"
      readOnly: false
    workingDir: "/home/jenkins/agent"
  nodeSelector:
    nodetype: "cpu"
  restartPolicy: "Never"
  volumes:
  - name: "volume-0"
    nfs:
      path: "/server/path/here"
      readOnly: true
      server: "10.0.20.3"

sjawhar avatar Sep 19 '22 16:09 sjawhar