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

NFS Server disk mount fixed; #175

Merged
merged 7 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
solution:
- name: k8s-inference
- name: k8s-training
- name: slurm
- name: wireguard

defaults:
Expand Down
68 changes: 55 additions & 13 deletions modules/nfs-server/files/nfs-cloud-init.tftpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#cloud-config
package_update: true
package_upgrade: false
packages:
- nfs-kernel-server

users:
- name: ${ssh_user_name}
groups: sudo
Expand All @@ -7,16 +12,53 @@ users:
ssh-authorized-keys:
- ${ssh_public_key}

runcmd:
- apt-get update
- apt-get install -y nfs-kernel-server
- mkdir -p ${nfs_path}
- mkfs.ext4 /dev/vda
- mount -o rw /dev/vda ${nfs_path}
- echo "/dev/vdb ${nfs_path} ext4 rw,relatime" | tee -a /etc/fstab
- chown nobody:nogroup ${nfs_path}
- chmod 777 ${nfs_path}
- echo "${nfs_path} ${nfs_ip_range}(rw,async,no_subtree_check,no_root_squash)" >> /etc/exports
- netplan set ethernets.eth0.mtu=${mtu_size}
- netplan apply
- systemctl restart nfs-kernel-server
disk_setup:
/dev/disk/by-id/virtio-nfs-disk: # hardcoded device-label: nfs-disk
table_type: gpt
layout: true

fs_setup:
- device: /dev/disk/by-id/virtio-nfs-disk-part1 # hardcoded device-label: nfs-disk
filesystem: ext4

mounts:
- [ /dev/disk/by-id/virtio-nfs-disk, ${nfs_path}, ext4, "defaults,relatime,rw", "0", "0" ] # hardcoded device-label: nfs-disk

write_files:
- path: /etc/exports
content: |
${nfs_path} ${nfs_ip_range}(rw,async,no_subtree_check,no_root_squash)
append: true

runcmd:
# Prepare pnfs mountpoint
- mkdir -p ${nfs_path}

# Configure permissions
- chown nobody:nogroup ${nfs_path}
- chmod 777 ${nfs_path}

# Configure NFS export
- echo "${nfs_path} ${nfs_ip_range}(rw,async,no_subtree_check,no_root_squash)" >> /etc/exports

# Netplan config for MTU
- echo "Writing netplan configuration..."
- |
cat <<EOF > /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
enp:
match:
name: "enp*"
dhcp4: true
mtu: ${mtu_size}
EOF
- chmod 600 /etc/netplan/50-cloud-init.yaml
- echo "Netplan configuration written. Applying it..."
- netplan generate
- netplan apply
- echo "Netplan applied successfully."

# Restart NFS service
- systemctl restart nfs-kernel-server
1 change: 1 addition & 0 deletions modules/nfs-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ resource "nebius_compute_v1_instance" "nfs_server" {

secondary_disks = [
{
device_id = "nfs-disk" # hardcoded device-label
attach_mode = "READ_WRITE"
existing_disk = nebius_compute_v1_disk.nfs-storage-disk
}
Expand Down
8 changes: 7 additions & 1 deletion modules/nfs-server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ variable "nfs_ip_range" {
variable "mtu_size" {
type = string
description = "MTU size to make network fater"
default = "8910"
default = "8800"
}

variable "nfs_size" {
type = string
description = "Size of the NFS in GB, should be divisbile by 93"
}

variable "nfs_device_label" {
type = string
description = "device label to use later as device ID"
default = "nfs-disk"
}
2 changes: 1 addition & 1 deletion nfs-server/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# key = "put your public ssh key here" OR
# path = "put path to ssh key here"
# }
nfs_ip_range = "192.168.0.0/16"
# nfs_ip_range = "192.168.0.0/16"
1 change: 1 addition & 0 deletions nfs-server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ variable "ssh_user_name" {
variable "nfs_ip_range" {
type = string
description = "Ip range from where NFS will be available"
default = "192.168.0.0/16"
}