Skip to content

Commit 9efa3fa

Browse files
committed
Add lgalloc support
1 parent 788ec31 commit 9efa3fa

File tree

7 files changed

+159
-1
lines changed

7 files changed

+159
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export AWS_PROFILE=your-profile-name
123123
| <a name="input_install_aws_load_balancer_controller"></a> [install\_aws\_load\_balancer\_controller](#input\_install\_aws\_load\_balancer\_controller) | Whether to install the AWS Load Balancer Controller | `bool` | `true` | no |
124124
| <a name="input_install_materialize_operator"></a> [install\_materialize\_operator](#input\_install\_materialize\_operator) | Whether to install the Materialize operator | `bool` | `true` | no |
125125
| <a name="input_install_metrics_server"></a> [install\_metrics\_server](#input\_install\_metrics\_server) | Whether to install the metrics-server for the Materialize Console | `bool` | `true` | no |
126+
| <a name="input_install_openebs"></a> [install\_openebs](#input\_install\_openebs) | Whether to install OpenEBS for lgalloc support | `bool` | `true` | no |
126127
| <a name="input_kubernetes_namespace"></a> [kubernetes\_namespace](#input\_kubernetes\_namespace) | The Kubernetes namespace for the Materialize resources | `string` | `"materialize-environment"` | no |
127128
| <a name="input_log_group_name_prefix"></a> [log\_group\_name\_prefix](#input\_log\_group\_name\_prefix) | Prefix for the CloudWatch log group name (will be combined with environment name) | `string` | `"materialize"` | no |
128129
| <a name="input_materialize_instances"></a> [materialize\_instances](#input\_materialize\_instances) | Configuration for Materialize instances. Due to limitations in Terraform, `materialize_instances` cannot be defined on the first `terraform apply`. | <pre>list(object({<br/> name = string<br/> namespace = optional(string)<br/> database_name = string<br/> environmentd_version = optional(string, "v0.130.4")<br/> cpu_request = optional(string, "1")<br/> memory_request = optional(string, "1Gi")<br/> memory_limit = optional(string, "1Gi")<br/> create_database = optional(bool, true)<br/> create_nlb = optional(bool, true)<br/> internal_nlb = optional(bool, true)<br/> enable_cross_zone_load_balancing = optional(bool, true)<br/> in_place_rollout = optional(bool, false)<br/> request_rollout = optional(string)<br/> force_rollout = optional(string)<br/> balancer_memory_request = optional(string, "256Mi")<br/> balancer_memory_limit = optional(string, "256Mi")<br/> balancer_cpu_request = optional(string, "100m")<br/> }))</pre> | `[]` | no |
@@ -145,6 +146,10 @@ export AWS_PROFILE=your-profile-name
145146
| <a name="input_public_subnet_cidrs"></a> [public\_subnet\_cidrs](#input\_public\_subnet\_cidrs) | CIDR blocks for public subnets | `list(string)` | <pre>[<br/> "10.0.101.0/24",<br/> "10.0.102.0/24",<br/> "10.0.103.0/24"<br/>]</pre> | no |
146147
| <a name="input_service_account_name"></a> [service\_account\_name](#input\_service\_account\_name) | Name of the service account | `string` | `"12345678-1234-1234-1234-123456789012"` | no |
147148
| <a name="input_single_nat_gateway"></a> [single\_nat\_gateway](#input\_single\_nat\_gateway) | Use a single NAT Gateway for all private subnets | `bool` | `false` | no |
149+
| <a name="input_storage_class_create"></a> [storage\_class\_create](#input\_storage\_class\_create) | Whether to create the storage class | `bool` | `true` | no |
150+
| <a name="input_storage_class_name"></a> [storage\_class\_name](#input\_storage\_class\_name) | Name of the storage class | `string` | `"openebs-lvm-instance-store-ext4"` | no |
151+
| <a name="input_storage_class_parameters"></a> [storage\_class\_parameters](#input\_storage\_class\_parameters) | Parameters for the storage class | <pre>object({<br/> storage = string<br/> fsType = string<br/> volgroup = string<br/> })</pre> | <pre>{<br/> "fsType": "ext4",<br/> "storage": "lvm",<br/> "volgroup": "instance-store-vg"<br/>}</pre> | no |
152+
| <a name="input_storage_class_provisioner"></a> [storage\_class\_provisioner](#input\_storage\_class\_provisioner) | Storage class provisioner | `string` | `"local.csi.openebs.io"` | no |
148153
| <a name="input_tags"></a> [tags](#input\_tags) | Default tags to apply to all resources | `map(string)` | <pre>{<br/> "Environment": "dev",<br/> "Project": "materialize",<br/> "Terraform": "true"<br/>}</pre> | no |
149154
| <a name="input_use_local_chart"></a> [use\_local\_chart](#input\_use\_local\_chart) | Whether to use a local chart instead of one from a repository | `bool` | `false` | no |
150155
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | CIDR block for VPC | `string` | `"10.0.0.0/16"` | no |

examples/simple/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ module "materialize_infrastructure" {
5151

5252
# EKS Configuration
5353
cluster_version = "1.32"
54-
node_group_instance_types = ["r8g.2xlarge"]
54+
node_group_instance_types = ["r7gd.2xlarge"]
5555
node_group_desired_size = 1
5656
node_group_min_size = 1
5757
node_group_max_size = 2
5858
node_group_capacity_type = "ON_DEMAND"
59+
node_group_ami_type = "BOTTLEROCKET_ARM_64"
5960
enable_cluster_creator_admin_permissions = true
6061

6162
# Storage Configuration

main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module "eks" {
3434
cluster_enabled_log_types = var.cluster_enabled_log_types
3535
node_group_capacity_type = var.node_group_capacity_type
3636
enable_cluster_creator_admin_permissions = var.enable_cluster_creator_admin_permissions
37+
install_openebs = var.install_openebs
3738

3839
tags = local.common_tags
3940

@@ -185,6 +186,14 @@ locals {
185186
}
186187
}
187188
}
189+
storage = {
190+
storageClass = {
191+
create = var.storage_class_create
192+
name = var.storage_class_name
193+
provisioner = var.storage_class_provisioner
194+
parameters = var.storage_class_parameters
195+
}
196+
}
188197
}
189198

190199
merged_helm_values = merge(local.default_helm_values, var.helm_values)

modules/eks/main.tf

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
locals {
22
name_prefix = "${var.namespace}-${var.environment}"
3+
4+
disk_setup_user_data = base64encode(<<-EOT
5+
#!/bin/bash
6+
set -xeuo pipefail
7+
8+
yum update -y
9+
yum install -y lvm2 util-linux jq e2fsprogs
10+
11+
BOTTLEROCKET_ROOT="/.bottlerocket/rootfs"
12+
DRIVE_PATHS=()
13+
14+
mapfile -t SSD_NVME_DEVICE_LIST < <(lsblk --json --output-all | jq -r '.blockdevices[] | select(.model // empty | contains("Amazon EC2 NVMe Instance Storage")) | .path')
15+
16+
echo "Found NVMe devices: $${SSD_NVME_DEVICE_LIST[@]}"
17+
18+
if [ $${#SSD_NVME_DEVICE_LIST[@]} -eq 0 ]; then
19+
echo "No NVMe instance storage devices found. Exiting."
20+
exit 0
21+
fi
22+
23+
for device in "$${SSD_NVME_DEVICE_LIST[@]}"; do
24+
DRIVE_PATHS+=("$${BOTTLEROCKET_ROOT}$${device}")
25+
done
26+
27+
echo "Configuring drives: $${DRIVE_PATHS[@]}"
28+
29+
for device_path in "$${DRIVE_PATHS[@]}"; do
30+
echo "Creating PV on $${device_path}"
31+
pvcreate "$${device_path}"
32+
done
33+
34+
echo "Creating VG instance-store-vg"
35+
vgcreate instance-store-vg "$${DRIVE_PATHS[@]}"
36+
37+
echo "PV Status:"
38+
pvs
39+
echo "VG Status:"
40+
vgs
41+
42+
echo "Completed LVM setup successfully"
43+
EOT
44+
)
345
}
446

547
module "eks" {
@@ -36,6 +78,15 @@ module "eks" {
3678
"materialize.cloud/disk" = "true"
3779
"workload" = "materialize-instance"
3880
}
81+
82+
bootstrap_extra_args = <<-TOML
83+
[settings.bootstrap-containers.disk-setup]
84+
source = "public.ecr.aws/amazonlinux/amazonlinux:2"
85+
mode = "once"
86+
essential = true
87+
user-data = "${local.disk_setup_user_data}"
88+
TOML
89+
3990
}
4091
}
4192

@@ -75,3 +126,29 @@ module "eks" {
75126

76127
tags = var.tags
77128
}
129+
130+
# Install OpenEBS for lgalloc support
131+
resource "kubernetes_namespace" "openebs" {
132+
count = var.install_openebs ? 1 : 0
133+
134+
metadata {
135+
name = var.openebs_namespace
136+
}
137+
}
138+
139+
resource "helm_release" "openebs" {
140+
count = var.install_openebs ? 1 : 0
141+
142+
name = "openebs"
143+
namespace = kubernetes_namespace.openebs[0].metadata[0].name
144+
repository = "https://openebs.github.io/openebs"
145+
chart = "openebs"
146+
version = var.openebs_version
147+
148+
set {
149+
name = "engines.replicated.mayastor.enabled"
150+
value = "false"
151+
}
152+
153+
depends_on = [kubernetes_namespace.openebs]
154+
}

modules/eks/variables.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,22 @@ variable "enable_cluster_creator_admin_permissions" {
7272
type = bool
7373
default = true
7474
}
75+
76+
# OpenEBS configuration
77+
variable "install_openebs" {
78+
description = "Whether to install OpenEBS for NVMe storage"
79+
type = bool
80+
default = true
81+
}
82+
83+
variable "openebs_namespace" {
84+
description = "Namespace for OpenEBS components"
85+
type = string
86+
default = "openebs"
87+
}
88+
89+
variable "openebs_version" {
90+
description = "Version of OpenEBS Helm chart to install"
91+
type = string
92+
default = "4.2.0"
93+
}

modules/eks/versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,13 @@ terraform {
66
source = "hashicorp/aws"
77
version = "~> 5.0"
88
}
9+
kubernetes = {
10+
source = "hashicorp/kubernetes"
11+
version = "~> 2.0"
12+
}
13+
helm = {
14+
source = "hashicorp/helm"
15+
version = "~> 2.0"
16+
}
917
}
1018
}

variables.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,42 @@ variable "install_metrics_server" {
363363
type = bool
364364
default = true
365365
}
366+
367+
variable "install_openebs" {
368+
description = "Whether to install OpenEBS for lgalloc support"
369+
type = bool
370+
default = true
371+
}
372+
373+
variable "storage_class_create" {
374+
description = "Whether to create the storage class"
375+
type = bool
376+
default = true
377+
}
378+
379+
variable "storage_class_name" {
380+
description = "Name of the storage class"
381+
type = string
382+
default = "openebs-lvm-instance-store-ext4"
383+
}
384+
385+
variable "storage_class_provisioner" {
386+
description = "Storage class provisioner"
387+
type = string
388+
default = "local.csi.openebs.io"
389+
}
390+
391+
variable "storage_class_parameters" {
392+
description = "Parameters for the storage class"
393+
type = object({
394+
storage = string
395+
fsType = string
396+
volgroup = string
397+
})
398+
399+
default = {
400+
storage = "lvm"
401+
fsType = "ext4"
402+
volgroup = "instance-store-vg"
403+
}
404+
}

0 commit comments

Comments
 (0)