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

Add a new volume type for ephemeral use between tasks #19530

Closed
hajali-amine opened this issue Dec 19, 2023 · 1 comment
Closed

Add a new volume type for ephemeral use between tasks #19530

hajali-amine opened this issue Dec 19, 2023 · 1 comment

Comments

@hajali-amine
Copy link

hajali-amine commented Dec 19, 2023

Proposal

I feel like there should be type of volume that is ephemeral, the moment the tasks are stopped, it gets removed and wiped.
Something similar to K8S' emptyDir.
For example;

job "job_a" {
  datacenters = ["dc1"]
  type        = "service"

  group "group_a" {
    
   volume "eph" {
      type      = "ephemeral"
    }

    task "task_a_prestart" {
      driver = "docker"

      config {
        image        = "busybox:1.28"
        command      = "sh"
        args         = ["-c", "echo 'hello world' >  path/to/somewhere/text.txt"]
        network_mode = "host"
      }

      resources {
        cpu    = 200
        memory = 128
      }

      volume_mount {
        volume      = "eph"
        destination = "path/to/somewhere"
      }

      lifecycle {
        hook    = "prestart"
        sidecar = false
      }
    }

    task "task_a" {
      driver = "docker"

      config {
        image   = "busybox"
        command = "sh"
        args    = ["-c", "cat path/in/task/text.txt"]
      }

      volume_mount {
        volume      = "eph"
        destination = "path/in/task"
      }

      resources {
        cpu    = 200
        memory = 128
      }
    }
  }
}

This allows two tasks to share a volume and fast without having to create a host volume or having something persistent.

Use-cases

Inter-task communication, especially when it's between prestart, poststart and a main task. It facilitates the choice on where to mount the ephemeral volume instead of having alloc and managing the movement of directories.

Attempted Solutions

None

@tgross
Copy link
Member

tgross commented Jan 2, 2024

Hi @hajali-amine! The allocation directory is intended for this use, and can be referenced inside each task at the path in the $NOMAD_ALLOC_DIR env var. See https://developer.hashicorp.com/nomad/docs/concepts/filesystem for more details on this.

We've also got an open feature request for Dynamic Host Volumes #15489 which will likely be a slightly more powerful version of the same concept.

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

No branches or pull requests

2 participants