Skip to content

feat: add nomad template #9786

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

Merged
merged 5 commits into from
Sep 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fmt
  • Loading branch information
matifali committed Sep 19, 2023
commit da12b13a4c82558ed9e9815a9fafaadeb9acdc37
109 changes: 55 additions & 54 deletions examples/templates/nomad-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Get started with Nomad Workspaces.
tags: [cloud, nomad]
icon: /icon/nomad.svg
---

# Develop in a Nomad Docker Container

This example shows how to use Nomad service tasks to be used as a development environment using docker and host csi volumes.
Expand All @@ -23,72 +24,72 @@ The CSI Host Volume plugin is used to mount host volumes into Nomad tasks. This

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

```hcl
plugin "docker" {
config {
allow_privileged = true
}
}
```
```hcl
plugin "docker" {
config {
allow_privileged = true
}
}
```

```shell
sudo systemctl restart nomad
```
```shell
sudo systemctl restart nomad
```

3. Create a file `hostpath.nomad` with following content:

```hcl
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
}
}
}
}
```
```hcl
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:

```shell
nomad job run hostpath.nomad
```
```shell
nomad job run hostpath.nomad
```

### 2. Setup the Nomad Template

1. Create the template by running the following command:

```shell
coder template init nomad-docker
cd nomad-docker
coder template create
```
```shell
coder template init nomad-docker
cd nomad-docker
coder template create
```

2. Set up Nomad server address and optional authentication:

Expand Down