Skip to content

Commit

Permalink
ci: setup test environment for v2 engine
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Chiu <[email protected]>
  • Loading branch information
yangchiu authored and khushboo-rancher committed May 8, 2024
1 parent 192300a commit 5253543
Show file tree
Hide file tree
Showing 42 changed files with 499 additions and 88 deletions.
2 changes: 2 additions & 0 deletions test_framework/terraform/aws/oracle/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ data "template_file" "provision_k3s_agent" {
k3s_cluster_secret = random_password.cluster_secret.result
k3s_version = var.k8s_distro_version
custom_ssh_public_key = var.custom_ssh_public_key
extra_block_device = var.extra_block_device
}
}

Expand All @@ -61,5 +62,6 @@ data "template_file" "provision_rke2_agent" {
rke2_cluster_secret = random_password.cluster_secret.result
rke2_version = var.k8s_distro_version
custom_ssh_public_key = var.custom_ssh_public_key
extra_block_device = var.extra_block_device
}
}
9 changes: 9 additions & 0 deletions test_framework/terraform/aws/oracle/k3s_instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ resource "aws_volume_attachment" "lh_aws_hdd_volume_att_k3s" {
force_detach = true
}

resource "aws_volume_attachment" "lh_aws_ssd_volume_att_k3s" {

count = var.extra_block_device && var.k8s_distro_name == "k3s" ? var.lh_aws_instance_count_worker : 0

device_name = "/dev/xvdh"
volume_id = aws_ebs_volume.lh_aws_ssd_volume[count.index].id
instance_id = aws_instance.lh_aws_instance_worker_k3s[count.index].id
force_detach = true
}

resource "aws_lb_target_group_attachment" "lh_aws_lb_tg_443_attachment_k3s" {

Expand Down
14 changes: 14 additions & 0 deletions test_framework/terraform/aws/oracle/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ resource "aws_ebs_volume" "lh_aws_hdd_volume" {
}
}

resource "aws_ebs_volume" "lh_aws_ssd_volume" {

count = var.extra_block_device ? var.lh_aws_instance_count_worker : 0

availability_zone = var.aws_availability_zone
size = var.lh_aws_instance_root_block_device_size_worker
type = "gp2"

tags = {
Name = "lh-aws-ssd-volume-${count.index}-${random_string.random_suffix.id}"
Owner = "longhorn-infra"
}
}

# Create load balancer for rancher
resource "aws_lb_target_group" "lh_aws_lb_tg_443" {

Expand Down
10 changes: 10 additions & 0 deletions test_framework/terraform/aws/oracle/rke2_instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ resource "aws_volume_attachment" "lh_aws_hdd_volume_att_rke2" {
force_detach = true
}

resource "aws_volume_attachment" "lh_aws_ssd_volume_att_rke2" {

count = var.extra_block_device && var.k8s_distro_name == "rke2" ? var.lh_aws_instance_count_worker : 0

device_name = "/dev/xvdh"
volume_id = aws_ebs_volume.lh_aws_ssd_volume[count.index].id
instance_id = aws_instance.lh_aws_instance_worker_rke2[count.index].id
force_detach = true
}

resource "aws_lb_target_group_attachment" "lh_aws_lb_tg_443_attachment_rke2" {

depends_on = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ sudo yum install -y iscsi-initiator-utils nfs-utils nfs4-acl-tools
sudo systemctl -q enable iscsid
sudo systemctl start iscsid

if [ -b "/dev/xvdh" ]; then
modprobe uio
modprobe uio_pci_generic
modprobe nvme-tcp
touch /etc/modules-load.d/modules.conf
cat > /etc/modules-load.d/modules.conf <<EOF
uio
uio_pci_generic
nvme-tcp
EOF

echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
echo "vm.nr_hugepages=1024" >> /etc/sysctl.conf

if [[ "${extra_block_device}" != true ]] && [[ -b "/dev/xvdh" ]]; then
mkfs.ext4 -E nodiscard /dev/xvdh
mkdir /var/lib/longhorn
mount /dev/xvdh /var/lib/longhorn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@ sudo yum install -y iscsi-initiator-utils nfs-utils nfs4-acl-tools nc
sudo systemctl -q enable iscsid
sudo systemctl start iscsid

if [ -b "/dev/xvdh" ]; then
modprobe uio
modprobe uio_pci_generic
modprobe nvme-tcp
touch /etc/modules-load.d/modules.conf
cat > /etc/modules-load.d/modules.conf <<EOF
uio
uio_pci_generic
nvme-tcp
EOF

echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
echo "vm.nr_hugepages=1024" >> /etc/sysctl.conf

if [[ "${extra_block_device}" != true ]] && [[ -b "/dev/xvdh" ]]; then
mkfs.ext4 -E nodiscard /dev/xvdh
mkdir /var/lib/longhorn
mount /dev/xvdh /var/lib/longhorn
Expand Down
5 changes: 5 additions & 0 deletions test_framework/terraform/aws/oracle/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,8 @@ variable "custom_ssh_public_key" {
default = ""
sensitive = true
}

variable "extra_block_device" {
type = bool
default = false
}
2 changes: 2 additions & 0 deletions test_framework/terraform/aws/rhel/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ data "template_file" "provision_k3s_agent" {
selinux_mode = var.selinux_mode
enable_selinux = var.selinux_mode == "permissive" ? "false" : "true"
custom_ssh_public_key = var.custom_ssh_public_key
extra_block_device = var.extra_block_device
}
}

Expand All @@ -69,5 +70,6 @@ data "template_file" "provision_rke2_agent" {
rke2_version = var.k8s_distro_version
selinux_mode = var.selinux_mode
custom_ssh_public_key = var.custom_ssh_public_key
extra_block_device = var.extra_block_device
}
}
10 changes: 10 additions & 0 deletions test_framework/terraform/aws/rhel/k3s_instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ resource "aws_volume_attachment" "lh_aws_hdd_volume_att_k3s" {
force_detach = true
}

resource "aws_volume_attachment" "lh_aws_ssd_volume_att_k3s" {

count = var.extra_block_device && var.k8s_distro_name == "k3s" ? var.lh_aws_instance_count_worker : 0

device_name = "/dev/xvdh"
volume_id = aws_ebs_volume.lh_aws_ssd_volume[count.index].id
instance_id = aws_instance.lh_aws_instance_worker_k3s[count.index].id
force_detach = true
}

resource "aws_lb_target_group_attachment" "lh_aws_lb_tg_443_attachment_k3s" {

depends_on = [
Expand Down
14 changes: 14 additions & 0 deletions test_framework/terraform/aws/rhel/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ resource "aws_ebs_volume" "lh_aws_hdd_volume" {
}
}

resource "aws_ebs_volume" "lh_aws_ssd_volume" {

count = var.extra_block_device ? var.lh_aws_instance_count_worker : 0

availability_zone = var.aws_availability_zone
size = var.lh_aws_instance_root_block_device_size_worker
type = "gp2"

tags = {
Name = "lh-aws-ssd-volume-${count.index}-${random_string.random_suffix.id}"
Owner = "longhorn-infra"
}
}

# Create load balancer for rancher
resource "aws_lb_target_group" "lh_aws_lb_tg_443" {

Expand Down
10 changes: 10 additions & 0 deletions test_framework/terraform/aws/rhel/rke2_instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ resource "aws_volume_attachment" "lh_aws_hdd_volume_att_rke2" {
force_detach = true
}

resource "aws_volume_attachment" "lh_aws_ssd_volume_att_rke2" {

count = var.extra_block_device && var.k8s_distro_name == "rke2" ? var.lh_aws_instance_count_worker : 0

device_name = "/dev/xvdh"
volume_id = aws_ebs_volume.lh_aws_ssd_volume[count.index].id
instance_id = aws_instance.lh_aws_instance_worker_rke2[count.index].id
force_detach = true
}

resource "aws_lb_target_group_attachment" "lh_aws_lb_tg_443_attachment_rke2" {

depends_on = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,20 @@ sudo systemctl -q enable iscsid
sudo systemctl start iscsid
sudo systemctl disable nm-cloud-setup.service nm-cloud-setup.timer

if [ -b "/dev/xvdh" ]; then
modprobe uio
modprobe uio_pci_generic
modprobe nvme-tcp
touch /etc/modules-load.d/modules.conf
cat > /etc/modules-load.d/modules.conf <<EOF
uio
uio_pci_generic
nvme-tcp
EOF

echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
echo "vm.nr_hugepages=1024" >> /etc/sysctl.conf

if [[ "${extra_block_device}" != true ]] && [[ -b "/dev/xvdh" ]]; then
sudo mkfs.ext4 -E nodiscard /dev/xvdh
sudo mkdir /var/lib/longhorn
sudo mount /dev/xvdh /var/lib/longhorn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,20 @@ sudo systemctl -q enable iscsid
sudo systemctl start iscsid
sudo systemctl disable nm-cloud-setup.service nm-cloud-setup.timer

if [ -b "/dev/xvdh" ]; then
modprobe uio
modprobe uio_pci_generic
modprobe nvme-tcp
touch /etc/modules-load.d/modules.conf
cat > /etc/modules-load.d/modules.conf <<EOF
uio
uio_pci_generic
nvme-tcp
EOF

echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
echo "vm.nr_hugepages=1024" >> /etc/sysctl.conf

if [[ "${extra_block_device}" != true ]] && [[ -b "/dev/xvdh" ]]; then
sudo mkfs.ext4 -E nodiscard /dev/xvdh
sudo mkdir /var/lib/longhorn
sudo mount /dev/xvdh /var/lib/longhorn
Expand Down
5 changes: 5 additions & 0 deletions test_framework/terraform/aws/rhel/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ variable "custom_ssh_public_key" {
default = ""
sensitive = true
}

variable "extra_block_device" {
type = bool
default = false
}
2 changes: 2 additions & 0 deletions test_framework/terraform/aws/rockylinux/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ data "template_file" "provision_k3s_agent" {
selinux_mode = var.selinux_mode
enable_selinux = var.selinux_mode == "permissive" ? "false" : "true"
custom_ssh_public_key = var.custom_ssh_public_key
extra_block_device = var.extra_block_device
}
}

Expand All @@ -74,5 +75,6 @@ data "template_file" "provision_rke2_agent" {
rke2_version = var.k8s_distro_version
selinux_mode = var.selinux_mode
custom_ssh_public_key = var.custom_ssh_public_key
extra_block_device = var.extra_block_device
}
}
10 changes: 10 additions & 0 deletions test_framework/terraform/aws/rockylinux/k3s_instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ resource "aws_volume_attachment" "lh_aws_hdd_volume_att_k3s" {
force_detach = true
}

resource "aws_volume_attachment" "lh_aws_ssd_volume_att_k3s" {

count = var.extra_block_device && var.k8s_distro_name == "k3s" ? var.lh_aws_instance_count_worker : 0

device_name = "/dev/xvdh"
volume_id = aws_ebs_volume.lh_aws_ssd_volume[count.index].id
instance_id = aws_instance.lh_aws_instance_worker_k3s[count.index].id
force_detach = true
}

resource "aws_lb_target_group_attachment" "lh_aws_lb_tg_443_attachment_k3s" {

depends_on = [
Expand Down
14 changes: 14 additions & 0 deletions test_framework/terraform/aws/rockylinux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,20 @@ resource "aws_ebs_volume" "lh_aws_hdd_volume" {
}
}

resource "aws_ebs_volume" "lh_aws_ssd_volume" {

count = var.extra_block_device ? var.lh_aws_instance_count_worker : 0

availability_zone = var.aws_availability_zone
size = var.lh_aws_instance_root_block_device_size_worker
type = "gp2"

tags = {
Name = "lh-aws-ssd-volume-${count.index}-${random_string.random_suffix.id}"
Owner = "longhorn-infra"
}
}

# Create load balancer for rancher
resource "aws_lb_target_group" "lh_aws_lb_tg_443" {

Expand Down
10 changes: 10 additions & 0 deletions test_framework/terraform/aws/rockylinux/rke2_instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ resource "aws_volume_attachment" "lh_aws_hdd_volume_att_rke2" {
force_detach = true
}

resource "aws_volume_attachment" "lh_aws_ssd_volume_att_rke2" {

count = var.extra_block_device && var.k8s_distro_name == "rke2" ? var.lh_aws_instance_count_worker : 0

device_name = "/dev/xvdh"
volume_id = aws_ebs_volume.lh_aws_ssd_volume[count.index].id
instance_id = aws_instance.lh_aws_instance_worker_rke2[count.index].id
force_detach = true
}

resource "aws_lb_target_group_attachment" "lh_aws_lb_tg_443_attachment_rke2" {

depends_on = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ sudo dnf install -y iscsi-initiator-utils nfs-utils nfs4-acl-tools
sudo systemctl -q enable iscsid
sudo systemctl start iscsid

if [ -b "/dev/xvdh" ]; then
modprobe uio
modprobe uio_pci_generic
modprobe nvme-tcp
touch /etc/modules-load.d/modules.conf
cat > /etc/modules-load.d/modules.conf <<EOF
uio
uio_pci_generic
nvme-tcp
EOF

echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
echo "vm.nr_hugepages=1024" >> /etc/sysctl.conf

if [[ "${extra_block_device}" != true ]] && [[ -b "/dev/xvdh" ]]; then
sudo mkfs.ext4 -E nodiscard /dev/xvdh
sudo mkdir /var/lib/longhorn
sudo mount /dev/xvdh /var/lib/longhorn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ sudo dnf install -y iscsi-initiator-utils nfs-utils nfs4-acl-tools jq nmap-ncat
sudo systemctl -q enable iscsid
sudo systemctl start iscsid

if [ -b "/dev/xvdh" ]; then
modprobe uio
modprobe uio_pci_generic
modprobe nvme-tcp
touch /etc/modules-load.d/modules.conf
cat > /etc/modules-load.d/modules.conf <<EOF
uio
uio_pci_generic
nvme-tcp
EOF

echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
echo "vm.nr_hugepages=1024" >> /etc/sysctl.conf

if [[ "${extra_block_device}" != true ]] && [[ -b "/dev/xvdh" ]]; then
sudo mkfs.ext4 -E nodiscard /dev/xvdh
sudo mkdir /var/lib/longhorn
sudo mount /dev/xvdh /var/lib/longhorn
Expand Down
7 changes: 6 additions & 1 deletion test_framework/terraform/aws/rockylinux/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,9 @@ variable "custom_ssh_public_key" {
type = string
default = ""
sensitive = true
}
}

variable "extra_block_device" {
type = bool
default = false
}
2 changes: 2 additions & 0 deletions test_framework/terraform/aws/sle-micro/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ data "template_file" "provision_k3s_agent" {
k3s_cluster_secret = random_password.cluster_secret.result
k3s_version = var.k8s_distro_version
custom_ssh_public_key = var.custom_ssh_public_key
extra_block_device = var.extra_block_device
}
}

Expand All @@ -54,5 +55,6 @@ data "template_file" "provision_rke2_agent" {
rke2_cluster_secret = random_password.cluster_secret.result
rke2_version = var.k8s_distro_version
custom_ssh_public_key = var.custom_ssh_public_key
extra_block_device = var.extra_block_device
}
}
Loading

0 comments on commit 5253543

Please sign in to comment.