iterative / terraform-provider-iterative

☁️ Terraform plugin for machine learning workloads: spot instance recovery & auto-termination | AWS, GCP, Azure, Kubernetes
https://registry.terraform.io/providers/iterative/iterative/latest/docs
Apache License 2.0
287 stars 27 forks source link

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

Open sjawhar opened 1 year ago

sjawhar commented 1 year ago

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"
  }
}
0x2b3bfa0 commented 1 year ago

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

sjawhar commented 1 year ago

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"
0x2b3bfa0 commented 1 year ago

Would an option to use a ReadWriteMany PVC solve this?