Skip to content

Commit

Permalink
add storage and worker cloud-init data
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdavis-prof committed Sep 19, 2024
1 parent 9273e26 commit 875a964
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions pkg/cli/config/initialize/basecamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type BaseCampGlobals struct {
}

// Basecamp Defaults
// masterBootCMD (cloud-init user-data)
// master bootcmd (cloud-init user-data)
var masterBootCMD = [][]string{
{"cloud-init-per", "once", "create_PART_LABEL", "parted", "/dev/md/AUX", "mklabel", "gpt"},
{"cloud-init-per", "once", "create_PART_LVM", "parted", "--wipesignatures", "-m", "--align=opt", "--ignore-busy", "/dev/md/AUX", "mkpart", "primary", "1MiB", "100GiB"},
Expand All @@ -131,22 +131,61 @@ var masterBootCMD = [][]string{
{"cloud-init-per", "once", "create_PART_K8SLET", "parted", "-m", "--align=opt", "--ignore-busy", "/dev/md/AUX", "mkpart", "extended", "xfs", "176GiB", "200GiB"},
}

// fs_setup (cloud-init user-data)
// master fs_setup (cloud-init user-data)
var masterFileSystems = [][]string{
{"label", "CRAYS3CACHE", "filesystem", "ext4", "device", "/dev/disk/by-id/dm-name-metalvg0-CRAYS3CACHE", "partition", "auto", "overwrite", "true"},
{"label", "CONRUN", "filesystem", "xfs", "device", "/dev/md/AUX2", "partition", "auto", "overwrite", "true"},
{"label", "CONLIB", "filesystem", "xfs", "device", "/dev/md/AUX3", "partition", "auto", "overwrite", "true"},
{"label", "K8SLET", "filesystem", "xfs", "device", "/dev/md/AUX4", "partition", "auto", "overwrite", "true"},
}

// mounts (cloud-init user-data)
// master mounts (cloud-init user-data)
var masterMounts = [][]string{
{"LABEL=CRAYS3CACHE", "/var/lib/s3fs_cache", "ext4", "defaults,nofail"},
{"LABEL=CONRUN", "/run/containerd", "xfs", "defaults,nofail"},
{"LABEL=CONLIB", "/var/lib/containerd", "xfs", "defaults,nofail"},
{"LABEL=K8SLET", "/var/lib/kubelet", "xfs", "defaults,nofail"},
}

// worker bootcmd (cloud-init user-data)
var workerBootCMD = [][]string{
{"cloud-init-per", "once", "create_PV", "pvcreate", "-ff", "-y", "-M", "lvm2", "/dev/md/AUX"},
{"cloud-init-per", "once", "create_VG", "vgcreate", "metalvg0", "/dev/md/AUX"},
{"cloud-init-per", "once", "create_LV_CRAYS3CACHE", "lvcreate", "-L", "200GB", "-n", "CRAYS3CACHE", "-y", "metalvg0"},
}

// worker fs_setup (cloud-init user-data)
var workerFileSystems = [][]string{
{"label", "CRAYS3CACHE", "filesystem", "ext4", "device", "/dev/disk/by-id/dm-name-metalvg0-CRAYS3CACHE", "partition", "auto", "overwrite", "true"}}

// worker mounts (cloud-init user-data)
var workerMounts = [][]string{
{"LABEL=CRAYS3CACHE", "/var/lib/s3fs_cache", "ext4", "defaults,nofail"},
}

// storage bootcmd (cloud-init user-data)
var cephBootCMD = [][]string{
{"cloud-init-per", "once", "create_PV", "pvcreate", "-ff", "-y", "-M", "lvm2", "/dev/md/AUX"},
{"cloud-init-per", "once", "create_VG", "vgcreate", "metalvg0", "/dev/md/AUX"},
{"cloud-init-per", "once", "create_LV_CEPHETC", "lvcreate", "-L", "10GB", "-n", "CEPHETC", "-y", "metalvg0"},
{"cloud-init-per", "once", "create_LV_CEPHVAR", "lvcreate", "-L", "60GB", "-n", "CEPHVAR", "-y", "metalvg0"},
{"cloud-init-per", "once", "create_LV_CONTAIN", "lvcreate", "-L", "60GB", "-n", "CONTAIN", "-y", "metalvg0"},
}

// storage fs_setup (cloud-init user-data)
var cephFileSystems = [][]string{
{"label", "CEPHETC", "filesystem", "ext4", "device", "/dev/disk/by-id/dm-name-metalvg0-CEPHETC", "partition", "auto", "overwrite", "true"},
{"label", "CEPHVAR", "filesystem", "ext4", "device", "/dev/disk/by-id/dm-name-metalvg0-CEPHVAR", "partition", "auto", "overwrite", "true"},
{"label", "CONTAIN", "filesystem", "xfs", "device", "/dev/disk/by-id/dm-name-metalvg0-CONTAIN", "partition", "auto", "overwrite", "true"},
}

// storage mounts (cloud-init user-data)
var cephMounts = [][]string{
{"LABEL=CEPHETC", "/etc/ceph", "auto", "defaults"},
{"LABEL=CEPHVAR", "/var/lib/ceph", "auto", "defaults"},
{"LABEL=CONTAIN", "/var/lib/containers", "auto", "defaults"},
}

// We should try to make these customizable by the user at some point
// k8sRunCMD has the list of scripts to run on NCN boot for
// all members of the kubernetes cluster
Expand Down Expand Up @@ -633,6 +672,10 @@ func MakeBaseCampfromNCNs(
}
userDataMap := make(map[string]interface{})
if ncn.Subrole == "Storage" {
userDataMap["bootcmd"] = cephBootCMD
userDataMap["fs_setup"] = cephFileSystems
userDataMap["mounts"] = cephMounts

if strings.HasSuffix(
ncn.Hostname,
"001",
Expand All @@ -651,6 +694,12 @@ func MakeBaseCampfromNCNs(
userDataMap["mounts"] = masterMounts
}

if ncn.Subrole == "Worker" {
userDataMap["bootcmd"] = workerBootCMD
userDataMap["fs_setup"] = workerFileSystems
userDataMap["mounts"] = workerMounts
}

userDataMap["hostname"] = ncn.Hostname
userDataMap["local_hostname"] = ncn.Hostname
userDataMap["mac0"] = mac0Interface
Expand Down

0 comments on commit 875a964

Please sign in to comment.