Skip to content

Commit 0c5a8a2

Browse files
add nfs-deployment template (#502)
## Description this PR adds a new template to the registry, which shows how to mount an NFS share to a K8s deployment workspace. ## Type of Change - [ ] New module - [x] New template - [ ] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Template Information <!-- Delete this section if not applicable --> **Path:** `registry/ericpaulsen/templates/nfs-deployment` ## Testing & Validation - [x] Tests pass (`bun test`) - [x] Code formatted (`bun fmt`) - [x] Changes tested locally ## Related Issues None --------- Co-authored-by: DevCats <[email protected]>
1 parent 51ec6e3 commit 0c5a8a2

File tree

3 files changed

+419
-0
lines changed

3 files changed

+419
-0
lines changed

.github/typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ HashiCorp = "HashiCorp"
66
mavrickrishi = "mavrickrishi" # Username
77
mavrick = "mavrick" # Username
88
inh = "inh" # Option in setpriv command
9+
exportfs = "exportfs" # nfs related binary
910

1011
[files]
1112
extend-exclude = ["registry/coder/templates/aws-devcontainer/architecture.svg"] #False positive
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
display_name: "NFS K8s Deployment"
3+
description: "Mount an NFS share to a Coder K8s workspace"
4+
icon: "../../../../.icons/folder.svg"
5+
verified: false
6+
tags: ["kubernetes", "shared-dir", "nfs"]
7+
---
8+
9+
# NFS K8s Deployment
10+
11+
This template provisions a Coder workspace as a Kubernetes Deployment, with an NFS share mounted
12+
as a volume. The NFS share will synchronize the server-side files onto the client (Coder workspace)
13+
When you stop the Coder workspace and rebuild, the NFS share will be re-mounted, and the changes persisted.
14+
15+
Note the `volume` and `volume_mount` blocks in the deployment and container spec,
16+
respectively:
17+
18+
```terraform
19+
resource "kubernetes_deployment" "main" {
20+
spec {
21+
template {
22+
spec {
23+
container {
24+
volume_mount {
25+
mount_path = data.coder_parameter.nfs_mount_path.value # mount path in the container
26+
name = "nfs-share"
27+
}
28+
}
29+
volume {
30+
name = "nfs-share"
31+
nfs {
32+
path = data.coder_parameter.nfs_mount_path.value # path to be exported from the server
33+
server = data.coder_parameter.nfs_server.value # server IP address
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
```
41+
42+
## server-side configuration
43+
44+
1. Create an NFS mount on the server for the clients to access:
45+
46+
```console
47+
export NFS_MNT_PATH=/mnt/nfs_share
48+
# Create directory to shaare
49+
sudo mkdir -p $NFS_MNT_PATH
50+
# Assign UID & GIDs access
51+
sudo chown -R uid:gid $NFS_MNT_PATH
52+
sudo chmod 777 $NFS_MNT_PATH
53+
```
54+
55+
1. Grant access to the client by updating the `/etc/exports` file, which
56+
controls the directories shared with remote clients. See
57+
[Red Hat's docs for more information about the configuration options](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_guide/s1-nfs-server-config-exports).
58+
59+
```console
60+
# Provides read/write access to clients accessing the NFS from any IP address.
61+
/mnt/nfs_share *(rw,sync,no_subtree_check)
62+
```
63+
64+
1. Export the NFS file share directory. You must do this every time you change
65+
`/etc/exports`.
66+
67+
```console
68+
sudo exportfs -a
69+
sudo systemctl restart <nfs-package>
70+
```

0 commit comments

Comments
 (0)