-
Notifications
You must be signed in to change notification settings - Fork 6
Add lgalloc support #36
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
Changes from 2 commits
f04c0eb
310b34f
8f767b2
fd5a74e
662187a
1ba2b5e
40043b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,23 @@ locals { | |
| managed_by = "terraform" | ||
| module = "materialize" | ||
| }) | ||
|
|
||
| # Disk support configuration | ||
| disk_config = { | ||
| install_openebs = var.enable_disk_support ? lookup(var.disk_support_config, "install_openebs", true) : false | ||
| run_disk_setup_script = var.enable_disk_support ? lookup(var.disk_support_config, "run_disk_setup_script", true) : false | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we just base this one entirely on
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the idea was that users only set
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part of the PR is more or less a copy and paste from the AWS implementation.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok.... let's just keep this |
||
| local_ssd_count = lookup(var.disk_support_config, "local_ssd_count", 1) | ||
| create_storage_class = var.enable_disk_support ? lookup(var.disk_support_config, "create_storage_class", true) : false | ||
|
bobbyiliev marked this conversation as resolved.
|
||
| openebs_version = lookup(var.disk_support_config, "openebs_version", "4.2.0") | ||
| openebs_namespace = lookup(var.disk_support_config, "openebs_namespace", "openebs") | ||
| storage_class_name = lookup(var.disk_support_config, "storage_class_name", "openebs-lvm-instance-store-ext4") | ||
| storage_class_provisioner = lookup(var.disk_support_config, "storage_class_provisioner", "local.csi.openebs.io") | ||
| storage_class_parameters = { | ||
| storage = try(var.disk_support_config.storage_class_parameters.storage, "lvm") | ||
| fsType = try(var.disk_support_config.storage_class_parameters.fsType, "ext4") | ||
|
bobbyiliev marked this conversation as resolved.
Outdated
|
||
| volgroup = try(var.disk_support_config.storage_class_parameters.volgroup, "instance-store-vg") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| module "networking" { | ||
|
|
@@ -33,6 +50,13 @@ module "gke" { | |
| min_nodes = var.gke_config.min_nodes | ||
| max_nodes = var.gke_config.max_nodes | ||
|
|
||
| # Disk support configuration | ||
| enable_disk_setup = local.disk_config.run_disk_setup_script | ||
| local_ssd_count = local.disk_config.local_ssd_count | ||
| install_openebs = local.disk_config.install_openebs | ||
| openebs_namespace = local.disk_config.openebs_namespace | ||
| openebs_version = local.disk_config.openebs_version | ||
|
|
||
| namespace = var.namespace | ||
| labels = local.common_labels | ||
| } | ||
|
|
@@ -158,6 +182,14 @@ locals { | |
| } | ||
| } | ||
| } | ||
| storage = var.enable_disk_support ? { | ||
| storageClass = { | ||
| create = local.disk_config.create_storage_class | ||
| name = local.disk_config.storage_class_name | ||
| provisioner = local.disk_config.storage_class_provisioner | ||
| parameters = local.disk_config.storage_class_parameters | ||
| } | ||
| } : {} | ||
| tls = (var.use_self_signed_cluster_issuer && length(var.materialize_instances) > 0) ? { | ||
| defaultCertificateSpecs = { | ||
| balancerdExternal = { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/bin/bash | ||
| set -xeuo pipefail | ||
|
|
||
| echo "Starting GCP NVMe SSD setup" | ||
|
|
||
| # Install required tools | ||
| if command -v apt-get >/dev/null 2>&1; then | ||
| apt-get update | ||
| apt-get install -y lvm2 | ||
| elif command -v yum >/dev/null 2>&1; then | ||
| yum install -y lvm2 | ||
| else | ||
| echo "No package manager found. Please install required tools manually." | ||
| exit 1 | ||
| fi | ||
|
Comment on lines
+6
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should definitely version lock this, or if there aren't dependencies, install from a binary.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just pinned this to a specific version. Regarding the dependencies:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is extremely unlikely to work long-term. If you want to pin it, you need to bake it into an image. The upstream repos will likely not contain that specific version for long.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but I thought that we did not want to maintain our own image because of security concerns?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, we can't pin the version this way, and the security concerns don't go away just because you're using someone else's image. We can either:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just removed the version pin. When I was originally working on that custom container, I got pushback because of concerns that a lot of vulnerability scanner noise could come from bootstrap containers. But if we are all fine with this, I am happy to work on that bootstrap Docker image. |
||
|
|
||
| # Find NVMe devices | ||
| SSD_DEVICE_LIST=() | ||
|
|
||
| # Try the standard GCP pattern first | ||
| devices=$(find /dev/disk/by-id/ -name "google-local-nvme-ssd-*" 2>/dev/null || true) | ||
| if [ -n "$devices" ]; then | ||
| while read -r device; do | ||
| SSD_DEVICE_LIST+=("$device") | ||
| done <<<"$devices" | ||
| fi | ||
|
|
||
| # If no devices found via standard pattern, look for NVMe devices directly | ||
| if [ ${#SSD_DEVICE_LIST[@]} -eq 0 ]; then | ||
| echo "No Local NVMe SSD devices found via standard pattern. Checking direct NVMe devices..." | ||
|
|
||
| for device in /dev/nvme*n*; do | ||
| # Skip if not a block device or if it's a partition | ||
| if [[ -b "$device" && ! "$device" =~ "p"[0-9]+ ]]; then | ||
| # Check if size is approximately 375GB | ||
| size_bytes=$(blockdev --getsize64 $device 2>/dev/null || echo 0) | ||
| # 375GB = approximately 402653184000 bytes | ||
| if ((size_bytes > 400000000000 && size_bytes < 405000000000)); then | ||
| echo "Found potential NVMe local SSD: $device ($((size_bytes / (1024 * 1024 * 1024))) GB)" | ||
| SSD_DEVICE_LIST+=("$device") | ||
| fi | ||
| fi | ||
| done | ||
| fi | ||
|
bobbyiliev marked this conversation as resolved.
Outdated
bobbyiliev marked this conversation as resolved.
Outdated
|
||
|
|
||
| echo "Found ${#SSD_DEVICE_LIST[@]} NVMe SSD devices: ${SSD_DEVICE_LIST[*]:-none}" | ||
|
|
||
| if [ ${#SSD_DEVICE_LIST[@]} -eq 0 ]; then | ||
| echo "No usable NVMe SSD devices found" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Check if any of the devices are already in use by LVM | ||
| for device in "${SSD_DEVICE_LIST[@]}"; do | ||
| if pvdisplay "$device" &>/dev/null; then | ||
| echo "$device is already part of LVM, skipping setup" | ||
| exit 0 | ||
| fi | ||
| done | ||
|
|
||
| # Create physical volumes | ||
| for device in "${SSD_DEVICE_LIST[@]}"; do | ||
| echo "Creating physical volume on $device" | ||
| pvcreate -f "$device" | ||
| done | ||
|
|
||
| # Create volume group named 'instance-store-vg' | ||
| echo "Creating volume group instance-store-vg" | ||
| vgcreate instance-store-vg "${SSD_DEVICE_LIST[@]}" | ||
|
bobbyiliev marked this conversation as resolved.
|
||
|
|
||
| # Create a logical volume using 100% of the space | ||
| echo "Creating logical volume local-nvme-lv" | ||
| lvcreate -l 100%FREE -n local-nvme-lv instance-store-vg | ||
|
bobbyiliev marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Format the logical volume | ||
| echo "Formatting logical volume with ext4" | ||
| mkfs.ext4 -F /dev/instance-store-vg/local-nvme-lv | ||
|
bobbyiliev marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Mount the logical volume | ||
| mkdir -p /var/openebs || true | ||
| echo "Mounting logical volume to /var/openebs" | ||
| if ! grep -q "/dev/instance-store-vg/local-nvme-lv" /etc/fstab; then | ||
| echo "/dev/instance-store-vg/local-nvme-lv /var/openebs ext4 discard,defaults,nofail 0 2" >>/etc/fstab | ||
| fi | ||
|
|
||
| if ! mount | grep -q "/var/openebs"; then | ||
| mount /var/openebs | ||
| fi | ||
|
|
||
| # Display results | ||
| echo "LVM setup completed:" | ||
| pvs | ||
| vgs | ||
| lvs | ||
| df -h /var/openebs | ||
|
|
||
| echo "NVMe SSD setup completed successfully" | ||
| echo "OpenEBS can use: /var/openebs" | ||
Uh oh!
There was an error while loading. Please reload this page.