openvidu-deployment: GCP - Added ARM64 support

master
Piwccle 2025-12-10 18:11:56 +01:00
parent 41dc440ef8
commit 05697f7ab3
4 changed files with 30 additions and 11 deletions

View File

@ -84,16 +84,25 @@ resource "google_compute_address" "public_ip_address" {
region = var.region
}
#Check if ARM
locals {
is_arm_instance = startswith(var.instanceType, "c4a-") || startswith(var.instanceType, "t2a-") || startswith(var.instanceType, "n4a-") || startswith(var.instanceType, "a4x-")
yq_arch = local.is_arm_instance ? "arm64" : "amd64"
ubuntu_image = local.is_arm_instance ? "ubuntu-os-cloud/ubuntu-2404-noble-arm64-v20241219" : "ubuntu-os-cloud/ubuntu-2404-noble-amd64-v20241219"
}
# Compute instance for OpenVidu
resource "google_compute_instance" "openvidu_server" {
name = lower("${var.stackName}-vm-ce")
machine_type = var.instanceType
zone = var.zone
tags = [lower("${var.stackName}-vm-ce")]
boot_disk {
initialize_params {
image = "projects/ubuntu-os-cloud/global/images/family/ubuntu-2204-lts"
image = local.ubuntu_image
size = 100
type = "pd-standard"
}
@ -155,8 +164,8 @@ apt-get update && apt-get install -y \
lsb-release \
openssl
wget https://github.com/mikefarah/yq/releases/download/$${YQ_VERSION}/yq_linux_amd64.tar.gz -O - |\
tar xz && mv yq_linux_amd64 /usr/bin/yq
wget https://github.com/mikefarah/yq/releases/download/$${YQ_VERSION}/yq_linux_${local.yq_arch}.tar.gz -O - |\
tar xz && mv yq_linux_${local.yq_arch} /usr/bin/yq
# Configure gcloud with instance service account
gcloud auth activate-service-account --key-file=/dev/null 2>/dev/null || true

View File

@ -126,6 +126,7 @@ resource "google_compute_address" "public_ip_address" {
resource "google_compute_instance" "openvidu_master_node" {
name = lower("${var.stackName}-master-node")
machine_type = var.masterNodeInstanceType
zone = var.zone
tags = [lower("${var.stackName}-master-node")]
@ -598,7 +599,10 @@ resource "google_cloud_scheduler_job" "scale_scheduler" {
# ------------------------- local values -------------------------
locals {
isEmpty = var.bucketName == ""
isEmpty = var.bucketName == ""
is_arm_instance = startswith(var.masterNodeInstanceType, "c4a-") || startswith(var.masterNodeInstanceType, "t2a-") || startswith(var.masterNodeInstanceType, "n4a-") || startswith(var.masterNodeInstanceType, "a4x-")
yq_arch = local.is_arm_instance ? "arm64" : "amd64"
install_script_master = <<-EOF
#!/bin/bash -x
set -e
@ -616,8 +620,8 @@ apt-get update && apt-get install -y \
lsb-release \
openssl
wget https://github.com/mikefarah/yq/releases/download/$${YQ_VERSION}/yq_linux_amd64.tar.gz -O - |\
tar xz && mv yq_linux_amd64 /usr/bin/yq
wget https://github.com/mikefarah/yq/releases/download/$${YQ_VERSION}/yq_linux_${local.yq_arch}.tar.gz -O - |\
tar xz && mv yq_linux_${local.yq_arch} /usr/bin/yq
# Configure gcloud with instance service account
gcloud auth activate-service-account --key-file=/dev/null 2>/dev/null || true

View File

@ -933,6 +933,8 @@ resource "google_compute_region_autoscaler" "media_node_autoscaler" {
locals {
isEmptyAppData = var.GCSAppDataBucketName == ""
isEmptyClusterData = var.GCSClusterDataBucketName == ""
is_arm_instance = startswith(var.masterNodesInstanceType, "c4a-") || startswith(var.masterNodesInstanceType, "t2a-") || startswith(var.masterNodesInstanceType, "n4a-") || startswith(var.masterNodesInstanceType, "a4x-")
yq_arch = local.is_arm_instance ? "arm64" : "amd64"
install_script_master = <<-EOF
#!/bin/bash -x
@ -952,8 +954,8 @@ apt-get update && apt-get install -y \
lsb-release \
openssl
wget https://github.com/mikefarah/yq/releases/download/$${YQ_VERSION}/yq_linux_amd64.tar.gz -O - |\
tar xz && mv yq_linux_amd64 /usr/bin/yq
wget https://github.com/mikefarah/yq/releases/download/$${YQ_VERSION}/yq_linux_${local.yq_arch}.tar.gz -O - |\
tar xz && mv yq_linux_${local.yq_arch} /usr/bin/yq
# Configure gcloud with instance service account
gcloud auth activate-service-account --key-file=/dev/null 2>/dev/null || true

View File

@ -88,6 +88,7 @@ resource "google_compute_address" "public_ip_address" {
resource "google_compute_instance" "openvidu_server" {
name = lower("${var.stackName}-vm-pro")
machine_type = var.instanceType
zone = var.zone
tags = [lower("${var.stackName}-vm-pro")]
@ -137,7 +138,10 @@ resource "google_compute_instance" "openvidu_server" {
# ------------------------- local values -------------------------
locals {
isEmpty = var.bucketName == ""
isEmpty = var.bucketName == ""
is_arm_instance = startswith(var.instanceType, "c4a-") || startswith(var.instanceType, "t2a-") || startswith(var.instanceType, "n4a-") || startswith(var.instanceType, "a4x-")
yq_arch = local.is_arm_instance ? "arm64" : "amd64"
install_script = <<-EOF
#!/bin/bash -x
set -e
@ -155,8 +159,8 @@ apt-get update && apt-get install -y \
lsb-release \
openssl
wget https://github.com/mikefarah/yq/releases/download/$${YQ_VERSION}/yq_linux_amd64.tar.gz -O - |\
tar xz && mv yq_linux_amd64 /usr/bin/yq
wget https://github.com/mikefarah/yq/releases/download/$${YQ_VERSION}/yq_linux_${local.yq_arch}.tar.gz -O - |\
tar xz && mv yq_linux_${local.yq_arch} /usr/bin/yq
# Configure gcloud with instance service account
gcloud auth activate-service-account --key-file=/dev/null 2>/dev/null || true