coder/examples/templates/nomad-docker
Cian Johnston 1cc51b009a
chore(examples): remove deprecated startup_script_timeout and shutdown_script_timeout (#12104)
Removes deprecated startup_script_timeout and shutdown_script_timeout from our example templates.

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
2024-02-12 14:29:41 +00:00
..
README.md docs: fix example template README 404s and semantics (#11903) 2024-01-29 21:34:12 +00:00
main.tf chore(examples): remove deprecated startup_script_timeout and shutdown_script_timeout (#12104) 2024-02-12 14:29:41 +00:00
workspace.nomad.tpl feat: add nomad template (#9786) 2023-09-21 08:54:56 +00:00

README.md

display_name description icon maintainer_github verified tags
Nomad Provision Nomad Jobs as Coder workspaces ../../../site/static/icon/nomad.svg coder true
nomad
container

Remote Development on Nomad

Provision Nomad Jobs as Coder workspaces with this example template. This example shows how to use Nomad service tasks to be used as a development environment using docker and host csi volumes.

Note This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.

Prerequisites

Setup

1. Start the CSI Host Volume Plugin

The CSI Host Volume plugin is used to mount host volumes into Nomad tasks. This is useful for development environments where you want to mount persistent volumes into your container workspace.

  1. Login to the Nomad server using SSH.

  2. Append the following stanza to your Nomad server configuration file and restart the nomad service.

    plugin "docker" {
      config {
        allow_privileged = true
      }
    }
    
    sudo systemctl restart nomad
    
  3. Create a file hostpath.nomad with following content:

    job "hostpath-csi-plugin" {
      datacenters = ["dc1"]
      type = "system"
    
      group "csi" {
        task "plugin" {
          driver = "docker"
    
          config {
            image = "registry.k8s.io/sig-storage/hostpathplugin:v1.10.0"
    
            args = [
              "--drivername=csi-hostpath",
              "--v=5",
              "--endpoint=${CSI_ENDPOINT}",
              "--nodeid=node-${NOMAD_ALLOC_INDEX}",
            ]
    
            privileged = true
          }
    
          csi_plugin {
            id   = "hostpath"
            type = "monolith"
            mount_dir = "/csi"
          }
    
          resources {
            cpu    = 256
            memory = 128
          }
        }
      }
    }
    
  4. Run the job:

    nomad job run hostpath.nomad
    

2. Setup the Nomad Template

  1. Create the template by running the following command:

    coder template init nomad-docker
    cd nomad-docker
    coder template push
    
  2. Set up Nomad server address and optional authentication:

  3. Create a new workspace and start developing.