Skip to content

Conversation

tasdomas
Copy link
Contributor

@tasdomas tasdomas commented Sep 8, 2022

No description provided.

@tasdomas tasdomas temporarily deployed to automatic September 8, 2022 16:11 Inactive
@tasdomas tasdomas changed the title K8s support for specifying an existant persistent volume claim. K8s support for specifying an existing persistent volume claim. Sep 9, 2022
@tasdomas tasdomas temporarily deployed to automatic September 9, 2022 10:05 Inactive
@tasdomas tasdomas temporarily deployed to automatic September 9, 2022 10:05 Inactive
@tasdomas tasdomas temporarily deployed to automatic September 9, 2022 10:05 Inactive
@tasdomas tasdomas temporarily deployed to automatic September 12, 2022 11:37 Inactive
@tasdomas tasdomas requested a deployment to automatic September 12, 2022 11:37 Abandoned
@tasdomas tasdomas requested a deployment to automatic September 12, 2022 11:37 Abandoned
@tasdomas tasdomas temporarily deployed to automatic September 14, 2022 16:16 Inactive
@tasdomas tasdomas temporarily deployed to automatic September 19, 2022 12:49 Inactive
@tasdomas tasdomas temporarily deployed to automatic September 19, 2022 12:49 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to automatic September 19, 2022 17:06 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to automatic September 19, 2022 17:07 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to automatic September 19, 2022 17:07 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to automatic September 19, 2022 17:07 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to automatic September 20, 2022 04:21 Inactive
@0x2b3bfa0 0x2b3bfa0 requested a deployment to automatic September 20, 2022 04:21 Abandoned
@0x2b3bfa0 0x2b3bfa0 requested a deployment to automatic September 20, 2022 04:21 Abandoned
@0x2b3bfa0 0x2b3bfa0 requested a deployment to automatic September 20, 2022 04:21 Abandoned
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to automatic September 20, 2022 08:40 Inactive
@0x2b3bfa0 0x2b3bfa0 requested a deployment to automatic September 20, 2022 08:40 Abandoned
@0x2b3bfa0 0x2b3bfa0 requested a deployment to automatic September 20, 2022 08:40 Abandoned
@0x2b3bfa0 0x2b3bfa0 requested a deployment to automatic September 20, 2022 08:40 Abandoned
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to automatic September 20, 2022 08:40 Inactive
@tasdomas tasdomas requested a review from 0x2b3bfa0 September 21, 2022 09:35
@tasdomas
Copy link
Contributor Author

This can be tested with the following terraform config (main.tf):

terraform {
  required_providers { iterative = { source = "github.com/iterative/iterative" } }
}

provider "kubernetes" {
  config_path    = "~/.kube/config"
  config_context = "minikube"
}

# A pre-allocated PVC.
resource "kubernetes_persistent_volume_claim" "example" {
  metadata {
    name = "pvc"
  }
  spec {
    access_modes = ["ReadWriteMany"]
    resources {
      requests = {
        storage = "1Gi"
      }
    }
  }
}

# A busybox pod to let us inspect the contents of the PVC.
resource "kubernetes_pod" "pvsee" {
  metadata {
    name = "pvsee"
  }

  spec {
    container {
      image = "busybox"
      name  = "bb"
      command = ["tail", "-f", "/dev/null"]
      volume_mount {
        name = "data"
        mount_path = "/data"
      }
    }
    volume {
      name = "data"
      persistent_volume_claim {
        claim_name = "${kubernetes_persistent_volume_claim.example.metadata.0.name}"
      }
    }
  }
}

provider "iterative" {}

resource "iterative_task" "example" {
  cloud      = "k8s" # or any of: gcp, az, k8s
  region     = "us-east"
  machine    = "m"   # medium. Or any of: l, xl, m+k80, xl+v100, ...
  spot       = -1     # auto-price. Default -1 to disable, or >0 for hourly USD limit
  disk_size  = -1    # GB. Default -1 for automatic
  storage {
    workdir = "./"       # default blank (don't upload)
    output  = "results" # default blank (don't download). Relative to workdir
    container = "${kubernetes_persistent_volume_claim.example.metadata.0.name}"
    container_path = "tpi-run"
  }
  script = <<-END
    #!/bin/bash

    # create output directory if needed
    mkdir -p results
    # read last result (in case of spot/preemptible instance recovery)
    if test -f results/epoch.txt; then EPOCH="$(cat results/epoch.txt)"; fi
    EPOCH=$${EPOCH:-1}  # start from 1 if last result not found

    echo "(re)starting training loop from $EPOCH up to 1337 epochs"
    for epoch in $(seq $EPOCH 1337); do
      sleep 1
      echo "$epoch" | tee results/epoch.txt
    done
  END
}

Once the config is applied, run kubectl exec -it pvsee -- sh and then ls /data to inspect the contents of the PVC.

@tasdomas tasdomas requested a review from dacbd September 29, 2022 12:16
@casperdcl casperdcl added the cloud-k8s Kubernetes label Oct 3, 2022
@casperdcl casperdcl changed the title K8s support for specifying an existing persistent volume claim. K8s support for specifying an existing persistent volume claim Oct 4, 2022
@casperdcl casperdcl changed the title K8s support for specifying an existing persistent volume claim K8s support for specifying an existing persistent volume claim. Oct 4, 2022
@casperdcl casperdcl changed the title K8s support for specifying an existing persistent volume claim. K8s support for specifying an existing persistent volume claim Oct 4, 2022
Copy link
Member

@0x2b3bfa0 0x2b3bfa0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for letting this pull request “breathe” for too long. 🙈 I believe it'll be more practical to merge it and submit a global review once you open a pull request for the feature branch-

@tasdomas tasdomas merged commit ce0b92e into feature-bucket-reuse Oct 5, 2022
@tasdomas tasdomas deleted the d014-pvc-reuse-k8s branch October 5, 2022 13:39
tasdomas pushed a commit that referenced this pull request Oct 21, 2022
* Support for existing storage containers in aws and gcp. (#651)

* Update config schema.

* AWS support for existing S3 buckets.

* Existing bucket support for gcp.

* Add mocks and tests to existing bucket resource in aws.

* Update docs with new pre-allocated container fields.

* Support using pre-allocated blob containers in azure. (#660)

* AWS support for existing S3 buckets.

* Existing bucket support for gcp.

* Fix subdirectory in rclone remote.

* Blob container generates the rclone connection string.

* Introduce a type for generating rclone connection strings.

* Azure support for reusable blob containers.

* Update docs.

* Fix path prefix.

* Initialize s3 existing bucket with RemoteStorage struct.

* Update gcp and aws existing bucket data sources to align with the azure data source.

Use common.RemoteStorage to initialize the data sources.
Using rclone to verify storage during Read.
Remove aws s3 client mocks and tests that rely on them.

* Fix comment.

* K8s support for specifying an existing persistent volume claim (#661)

* K8s support for specifying an existing persistent volume claim.

Co-authored-by: Helio Machado <[email protected]>

* Update use of Identifier struct.

* Combine container and container_path config keys.

* Update docs.

* Use split function from rclone.

Co-authored-by: Helio Machado <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloud-k8s Kubernetes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants