From 69c44a87e27b8a04e1a94997f53d69cc79936f2c Mon Sep 17 00:00:00 2001 From: Sreenivasulu Reddy Sura <100401235+sreenivasulureddysura@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:06:49 +0530 Subject: [PATCH] added missing .tf files (#93) Co-authored-by: Pavan Savanoor --- script/terraform/terraform-config.alicloud.tf | 190 +++++++++++++ script/terraform/terraform-config.aws.tf | 192 +++++++++++++ script/terraform/terraform-config.azure.tf | 192 +++++++++++++ script/terraform/terraform-config.eks.tf | 159 +++++++++++ script/terraform/terraform-config.gcp.tf | 196 ++++++++++++++ script/terraform/terraform-config.gke.tf | 149 ++++++++++ script/terraform/terraform-config.hyperv.tf | 145 ++++++++++ script/terraform/terraform-config.kvm.tf | 255 ++++++++++++++++++ script/terraform/terraform-config.oracle.tf | 181 +++++++++++++ script/terraform/terraform-config.static.tf | 153 +++++++++++ script/terraform/terraform-config.tencent.tf | 186 +++++++++++++ 11 files changed, 1998 insertions(+) create mode 100644 script/terraform/terraform-config.alicloud.tf create mode 100644 script/terraform/terraform-config.aws.tf create mode 100644 script/terraform/terraform-config.azure.tf create mode 100644 script/terraform/terraform-config.eks.tf create mode 100644 script/terraform/terraform-config.gcp.tf create mode 100644 script/terraform/terraform-config.gke.tf create mode 100644 script/terraform/terraform-config.hyperv.tf create mode 100644 script/terraform/terraform-config.kvm.tf create mode 100644 script/terraform/terraform-config.oracle.tf create mode 100644 script/terraform/terraform-config.static.tf create mode 100644 script/terraform/terraform-config.tencent.tf diff --git a/script/terraform/terraform-config.alicloud.tf b/script/terraform/terraform-config.alicloud.tf new file mode 100644 index 0000000..7159a3e --- /dev/null +++ b/script/terraform/terraform-config.alicloud.tf @@ -0,0 +1,190 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "cloud_essd" + disk_performance = null + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "cloud_essd" + disk_performance = null + } +} + +variable "region" { + default = null +} + +variable "zone" { + default = "cn-beijing-l" +} + +variable "resource_group_id" { + default = "rg-aekzpvcftlcma5a" +} + +variable "owner" { + default = "" +} + +variable "custom_tags" { + default = {} +} + +variable "spot_instance" { + default = true +} + +variable "wl_name" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + instance_type = "ecs.g6.large" + cpu_model_regex = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "cloud_essd" + os_disk_size = 200 + os_disk_performance = null + + data_disk_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + instance_type = "ecs.g6.large" + cpu_model_regex = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "cloud_essd" + os_disk_size = 200 + os_disk_performance = null + + data_disk_spec = null + } +} + +variable "controller_profile" { + default = { + name = "controller" + instance_type = "ecs.g6.large" + cpu_model_regex = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "cloud_essd" + os_disk_size = 200 + os_disk_performance = null + + data_disk_spec = null + } +} + +module "wsf" { + source = "./template/terraform/alicloud/main" + + region = var.region + zone = var.zone + resource_group_id = var.resource_group_id + job_id = var.wl_namespace + + sg_whitelist_cidr_blocks = compact(split("\n",file("proxy-ip-list.txt"))) + ssh_pub_key = file("ssh_access.key.pub") + + common_tags = { + for k,v in merge(var.custom_tags, { + owner: var.owner, + workload: var.wl_name, + }) : k => substr(replace(lower(v), "/[^a-z0-9_-]/", ""), 0, 63) + } + + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null, + }), + merge(var.controller_profile, { + data_disk_spec: null, + }), + ] + + spot_instance = var.spot_instance +} + +output "options" { + value = { + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + + docker_dist_repo: "https://mirrors.aliyun.com/docker-ce", + containerd_pause_registry: "registry.aliyuncs.com/google_containers", + + k8s_repo_key_url: { + "debian": "http://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg", + "centos": ["http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg","https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg"], + }, + k8s_repo_url: { + "debian": "http://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main", + "centos": "http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-$basearch", + }, + k8s_kubeadm_options: { + "ClusterConfiguration": { + "imageRepository": "registry.aliyuncs.com/google_containers", + }, + }, + k8s_registry_image: "public.ecr.aws/docker/library/registry:2", + k8s_calico_cni_repo: "public.ecr.aws/metakube/calico", + k8s_cni: "calico", + k8s_enable_nfd: false, + } +} + +output "instances" { + value = { + for k,v in module.wsf.instances : k => merge(v, { + csp = "alicloud", + zone = var.zone, + }) + } +} + +output "terraform_replace" { + value = lookup(module.wsf, "terraform_replace", null)==null?null:{ + command = replace(module.wsf.terraform_replace.command, "=", "=module.wsf.") + cpu_model = module.wsf.terraform_replace.cpu_model + } +} diff --git a/script/terraform/terraform-config.aws.tf b/script/terraform/terraform-config.aws.tf new file mode 100644 index 0000000..725c372 --- /dev/null +++ b/script/terraform/terraform-config.aws.tf @@ -0,0 +1,192 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "gp2" + disk_iops = null + disk_throughput = null + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "gp2" + disk_iops = null + disk_throughput = null + } +} + +variable "network_spec_1" { + default = { + network_count = 1 + network_type = null + } +} + +variable "region" { + default = null +} + +variable "zone" { + default = "us-west-2a" +} + +variable "owner" { + default = "" +} + +variable "spot_instance" { + default = true +} + +variable "custom_tags" { + default = {} +} + +variable "wl_name" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + instance_type = "t2.medium" + cpu_model_regex = null + threads_per_core = null + cpu_core_count = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "gp2" + os_disk_size = 200 + os_disk_iops = null + os_disk_throughput = null + + data_disk_spec = null + network_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + instance_type = "t2.medium" + cpu_model_regex = null + threads_per_core = null + cpu_core_count = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "gp2" + os_disk_size = 200 + os_disk_iops = null + os_disk_throughput = null + + data_disk_spec = null + network_spec = null + } +} + +variable "controller_profile" { + default = { + name = "controller" + instance_type = "t2.medium" + cpu_model_regex = null + threads_per_core = null + cpu_core_count = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "gp2" + os_disk_size = 200 + os_disk_iops = null + os_disk_throughput = null + + data_disk_spec = null + network_spec = null + } +} + +module "wsf" { + source = "./template/terraform/aws/main" + + region = var.region + zone = var.zone + job_id = var.wl_namespace + + sg_whitelist_cidr_blocks = compact(split("\n",file("proxy-ip-list.txt"))) + ssh_pub_key = file("ssh_access.key.pub") + + common_tags = { + for k,v in merge(var.custom_tags, { + owner: var.owner, + workload: var.wl_name, + }) : k => substr(replace(lower(v), "/[^a-z0-9_-]/", ""), 0, 63) + } + + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null + network_spec: null, + }), + merge(var.controller_profile, { + data_disk_spec: null, + network_spec: null, + }), + ] + + spot_instance = var.spot_instance +} + +output "options" { + value = { + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + # k8s_registry_storage: "aws", + # k8s_registry_aws_storage_bucket: "registry-content", + # k8s_registry_aws_storage_region: var.region, + } +} + +output "instances" { + sensitive = true + value = { + for k,v in module.wsf.instances : k => merge(v, { + csp = "aws", + zone = var.zone, + }) + } +} + +output "terraform_replace" { + value = lookup(module.wsf, "terraform_replace", null)==null?null:{ + command = replace(module.wsf.terraform_replace.command, "=", "=module.wsf.") + cpu_model = module.wsf.terraform_replace.cpu_model + } +} + diff --git a/script/terraform/terraform-config.azure.tf b/script/terraform/terraform-config.azure.tf new file mode 100644 index 0000000..aa6c304 --- /dev/null +++ b/script/terraform/terraform-config.azure.tf @@ -0,0 +1,192 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "Standard_LRS" + disk_iops = 32000 + disk_throughput = 1024 + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "Standard_LRS" + disk_iops = 32000 + disk_throughput = 1024 + } +} + +variable "network_spec_1" { + default = { + network_count = 1 + } +} + +variable "region" { + default = null +} + +variable "zone" { + default = "eastus-1" +} + +variable "owner" { + default = "" +} + +variable "spot_instance" { + default = true +} + +variable "custom_tags" { + default = {} +} + +variable "wl_name" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "compute_gallery" { + default = { + gallery_name = null + gallery_resource_group_name = null + gallery_image_name = null + gallery_image_version = null + } +} + +variable "worker_profile" { + default = { + name = "worker" + vm_count = 1 + instance_type = "Standard_A2_v2" + cpu_model_regex = null + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "Standard_LRS" + os_disk_size = 200 + + data_disk_spec = null + network_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + vm_count = 1 + instance_type = "Standard_A2_v2" + cpu_model_regex = null + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "Standard_LRS" + os_disk_size = 200 + + data_disk_spec = null + network_spec = null + } +} + +variable "controller_profile" { + default = { + name = "controller" + vm_count = 1 + instance_type = "Standard_A2_v2" + cpu_model_regex = null + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "Standard_LRS" + os_disk_size = 200 + + data_disk_spec = null + network_spec = null + } +} + +module "wsf" { + source = "./template/terraform/azure/main" + + region = var.region + zone = var.zone + job_id = var.wl_namespace + + sg_whitelist_cidr_blocks = compact(split("\n",file("proxy-ip-list.txt"))) + ssh_pub_key = file("ssh_access.key.pub") + + common_tags = { + for k,v in merge(var.custom_tags, { + owner: var.owner, + workload: var.wl_name, + }) : k => substr(replace(lower(v), "/[^a-z0-9_-]/", ""), 0, 63) + } + + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.controller_profile, { + data_disk_spec: null, + network_spec: null, + }), + ] + + spot_instance = var.spot_instance + + #resource_group_name = "custom-resource-name" + #virtual_network_name = "custom-virtual-network-name" + #subnet_name = "custom-subnet-name" + #allocate_public_ip = true + #encrypt_disk = true + #disk_encryption_set_name = "custom-disk-encryption-set-name" +} + +output "options" { + value = { + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + } +} + +output "instances" { + sensitive = true + value = { + for k,v in module.wsf.instances: k => merge(v, { + csp = "azure", + zone = var.zone, + }) + } +} + +output "terraform_replace" { + value = lookup(module.wsf, "terraform_replace", null)==null?null:{ + command = replace(module.wsf.terraform_replace.command, "=", "=module.wsf.") + cpu_model = module.wsf.terraform_replace.cpu_model + } +} diff --git a/script/terraform/terraform-config.eks.tf b/script/terraform/terraform-config.eks.tf new file mode 100644 index 0000000..29df771 --- /dev/null +++ b/script/terraform/terraform-config.eks.tf @@ -0,0 +1,159 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "gp2" + disk_iops = null + disk_throughput = null + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "gp2" + disk_iops = null + disk_throughput = null + } +} + +variable "network_spec_1" { + default = { + network_count = 1 + network_type = null + } +} + +variable "region" { + default = null +} + +variable "zone" { + default = "us-west-2a" +} + +variable "owner" { + default = "" +} + +variable "spot_instance" { + default = true +} + +variable "custom_tags" { + default = {} +} + +variable "wl_name" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + instance_type = "t2.medium" + threads_per_core = null + cpu_core_count = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2004" + os_disk_type = "gp2" + os_disk_size = 200 + os_disk_iops = null + os_disk_throughput = null + + data_disk_spec = null + network_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + instance_type = "t2.medium" + threads_per_core = null + cpu_core_count = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2004" + os_disk_type = "gp2" + os_disk_size = 200 + os_disk_iops = null + os_disk_throughput = null + + data_disk_spec = null + network_spec = null + } +} + +module "wsf" { + source = "./template/terraform/aws/eks" + + region = var.region + zones = [ + var.zone, + format("%s%s", replace(var.zone, "/(.*)[a-z]$/", "$1"), replace(var.zone, "/.*([a-z])$/", "$1")=="a"?"b":"a"), + ] + job_id = var.wl_namespace + + sg_whitelist_cidr_blocks = compact(split("\n",file("proxy-ip-list.txt"))) + ssh_pub_key = file("ssh_access.key.pub") + + common_tags = { + for k,v in merge(var.custom_tags, { + owner: var.owner, + workload: var.wl_name, + }) : k => substr(replace(lower(v), "/[^a-z0-9_-]/", ""), 0, 63) + } + + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null + network_spec: null, + }), + ] + + spot_instance = var.spot_instance +} + +output "options" { + value = merge({ + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + k8s_enable_registry: false, + k8s_remote_registry_url: "", + }, module.wsf.options) +} + +output "instances" { + value = { + for k,v in module.wsf.instances : k => merge(v, { + csp = "aws", + zone = var.zone, + }) + } +} + diff --git a/script/terraform/terraform-config.gcp.tf b/script/terraform/terraform-config.gcp.tf new file mode 100644 index 0000000..539f541 --- /dev/null +++ b/script/terraform/terraform-config.gcp.tf @@ -0,0 +1,196 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "pd-ssd" + disk_iops = null + disk_throughput = null + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "pd-ssd" + disk_iops = null + disk_throughput = null + } +} + +variable "network_spec_1" { + default = { + network_count = 1 + } +} + +variable "region" { + default = null +} + +variable "zone" { + default = "us-west1-a" +} + +variable "owner" { + default = "" +} + +variable "spot_instance" { + default = true +} + +variable "custom_tags" { + default = {} +} + +variable "wl_name" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + instance_type = "e2-small" + cpu_model_regex = null + vm_count = 1 + min_cpu_platform = null + threads_per_core = null + cpu_core_count = null + nic_type = "GVNIC" + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "pd-ssd" + os_disk_size = 200 + os_disk_iops = null + os_disk_throughput = null + + data_disk_spec = null + network_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + instance_type = "e2-small" + cpu_model_regex = null + vm_count = 1 + min_cpu_platform = null + threads_per_core = null + cpu_core_count = null + nic_type = "GVNIC" + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "pd-ssd" + os_disk_size = 200 + os_disk_iops = null + os_disk_throughput = null + + data_disk_spec = null + network_spec = null + } +} + +variable "controller_profile" { + default = { + name = "controller" + instance_type = "e2-small" + cpu_model_regex = null + vm_count = 1 + min_cpu_platform = null + threads_per_core = null + cpu_core_count = null + nic_type = "GVNIC" + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "pd-ssd" + os_disk_size = 200 + os_disk_iops = null + os_disk_throughput = null + + data_disk_spec = null + network_spec = null + } +} + +module "wsf" { + source = "./template/terraform/gcp/main" + + region = var.region + zone = var.zone + job_id = var.wl_namespace + + sg_whitelist_cidr_blocks = compact(split("\n",file("proxy-ip-list.txt"))) + ssh_pub_key = file("ssh_access.key.pub") + + common_tags = { + for k,v in merge(var.custom_tags, { + owner: var.owner, + workload: var.wl_name, + }) : k => substr(replace(lower(v), "/[^a-z0-9_-]/", ""), 0, 63) + } + + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.controller_profile, { + data_disk_spec: null, + network_spec: null, + }), + ] + + spot_instance = var.spot_instance +} + +output "options" { + value = { + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + # k8s_registry_storage: "gcp" + # k8s_registry_gcp_storage_bucket: "registry-cache", + # k8s_registry_gcp_storage_key_file: "service-account-apikey.json", + } +} + +output "instances" { + value = { + for k,v in module.wsf.instances: k => merge(v, { + csp = "gcp", + zone = var.zone, + }) + } +} + +output "terraform_replace" { + value = lookup(module.wsf, "terraform_replace", null)==null?null:{ + command = replace(module.wsf.terraform_replace.command, "=", "=module.wsf.") + cpu_model = module.wsf.terraform_replace.cpu_model + } +} diff --git a/script/terraform/terraform-config.gke.tf b/script/terraform/terraform-config.gke.tf new file mode 100644 index 0000000..373877d --- /dev/null +++ b/script/terraform/terraform-config.gke.tf @@ -0,0 +1,149 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "pd-standard" + disk_iops = null + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "pd-standard" + disk_iops = null + } +} + +variable "network_spec_1" { + default = { + network_count = 1 + } +} + +variable "region" { + default = null +} + +variable "zone" { + default = "us-west1-a" +} + +variable "owner" { + default = "" +} + +variable "spot_instance" { + default = true +} + +variable "custom_tags" { + default = {} +} + +variable "wl_name" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + instance_type = "e2-small" + vm_count = 1 + min_cpu_platform = null + nic_type = "GVNIC" + + os_type = "ubuntu" + os_disk_type = "pd-standard" + os_disk_size = 200 + + data_disk_spec = null + network_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + instance_type = "e2-small" + vm_count = 1 + min_cpu_platform = null + nic_type = "GVNIC" + + os_type = "ubuntu" + os_disk_type = "pd-standard" + os_disk_size = 200 + + data_disk_spec = null + network_spec = null + } +} + +module "wsf" { + source = "./template/terraform/gcp/gke" + + region = var.region + zone = var.zone + job_id = var.wl_namespace + + sg_whitelist_cidr_blocks = compact(split("\n",file("proxy-ip-list.txt"))) + ssh_pub_key = file("ssh_access.key.pub") + ssh_private_key_file = "ssh_access.key" + + common_tags = { + for k,v in merge(var.custom_tags, { + owner: var.owner, + workload: var.wl_name, + }) : lower(k) => substr(replace(lower(v), "/[^a-z0-9_-]/", ""), 0, 63) + } + + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null, + network_spec: null, + }), + ] + + spot_instance = var.spot_instance +} + +output "options" { + value = merge({ + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + k8s_enable_registry: false, + k8s_remote_registry_url: "", + }, module.wsf.options) +} + +output "instances" { + value = { + for k,v in module.wsf.instances: k => merge(v, { + csp = "gcp", + zone = var.zone, + }) + } +} + diff --git a/script/terraform/terraform-config.hyperv.tf b/script/terraform/terraform-config.hyperv.tf new file mode 100644 index 0000000..b8ccb38 --- /dev/null +++ b/script/terraform/terraform-config.hyperv.tf @@ -0,0 +1,145 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 100 + disk_format = "ext4" + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + } +} + +variable "network_spec_1" { + default = { + network_count = 1 + network_type = null + } +} + +variable "owner" { + default = "" +} + +variable "wl_name" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + cpu_core_count = 1 + memory_size = 4 + vm_count = 1 + + os_image = null + os_type = "windows2022" + os_disk_size = 50 + + data_disk_spec = null + network_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + cpu_core_count = 1 + memory_size = 4 + vm_count = 1 + + os_image = null + os_type = "windows2022" + os_disk_size = 50 + + data_disk_spec = null + network_spec = null + } +} + +variable "controller_profile" { + default = { + name = "controller" + cpu_core_count = 1 + memory_size = 4 + vm_count = 1 + + os_image = null + os_type = "windows2022" + os_disk_size = 50 + + data_disk_spec = null + network_spec = null + } +} + +# single HyperV host +variable "hpv_hosts" { + default = [{ + host = "" + port = 5986 + networks = [ "wsfext" ] + }] +} + +locals { + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null + network_spec: null, + }), + merge(var.controller_profile, { + data_disk_spec: null, + network_spec: null, + }), + ] +} + +module "wsf_hyperv" { + source = "./template/terraform/hyperv/local" + + job_id = var.wl_namespace + ssh_pub_key = file("${path.root}/ssh_access.key.pub") + instance_profiles = local.instance_profiles + hpv_host = var.hpv_hosts.0 +} + +output "options" { + value = merge(module.wsf_hyperv.options, { + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + k8s_enable_registry: true, + }) +} + +output "instances" { + sensitive = true + value = { + for k,v in module.wsf_hyperv.instances : k => merge(v, { + csp = "hyperv", + }) + } +} + diff --git a/script/terraform/terraform-config.kvm.tf b/script/terraform/terraform-config.kvm.tf new file mode 100644 index 0000000..7d4a555 --- /dev/null +++ b/script/terraform/terraform-config.kvm.tf @@ -0,0 +1,255 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 100 + disk_format = "ext4" + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + } +} + +variable "network_spec_1" { + default = { + network_count = 1 + network_type = null + } +} + +variable "owner" { + default = "" +} + +variable "wl_name" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + cpu_core_count = 2 + memory_size = 2 + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_size = 50 + + data_disk_spec = null + network_spec = null + + # Specifies which KVM host must be used to host + # different workers. + kvm_hosts = [ 0, 1, 2, 0, 1, 2 ] + } +} + +variable "client_profile" { + default = { + name = "client" + cpu_core_count = 2 + memory_size = 2 + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_size = 50 + + data_disk_spec = null + network_spec = null + + # Specifies which KVM host must be used to host + # different clients. + kvm_hosts = [ 1, 0, 1, 2, 0, 1 ] + } +} + +variable "controller_profile" { + default = { + name = "controller" + cpu_core_count = 2 + memory_size = 2 + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_size = 50 + + data_disk_spec = null + network_spec = null + + # Specifies which KVM host must be used to host + # different controllers. + kvm_hosts = [ 1, 2, 0, 1, 2, 0 ] + } +} + +# single KVM host +variable "kvm_hosts" { + default = [{ + user = "user" + host = "127.0.1.1" + port = 22 + # DHCP must be enabled on the network interface + networks = [ "default" ] + # if specified, os image will reuse the storage pool + # images (with same image names.) + pool = null + }] +} + +# multiple KVM hosts +#variable "kvm_hosts" { +# default = [{ +# user = "user" +# host = "127.0.1.1" +# port = 22 +# # DHCP must be enabled on the network interface +# networks = [ "wsfbr0", "default" ] +# # if specified, os image will reuse the storage pool +# # images (with same image names.) +# pool = "osimages" +# }, { +# user = "user" +# host = "127.0.1.2" +# port = 22 +# # DHCP must be enabled on the network interface +# networks = [ "wsfbr0", "default" ] +# # if specified, os image will reuse the storage pool +# # images (with same image names.) +# pool = "osimages" +# }] +#} + +terraform { + required_providers { + libvirt = { + source = "dmacvicar/libvirt" + } + } +} + +provider "libvirt" { + uri = "qemu+ssh://${var.kvm_hosts.0.user}@${var.kvm_hosts.0.host}:${var.kvm_hosts.0.port}/system" + alias = "kvm0" +} + +provider "libvirt" { + uri = "qemu+ssh://${element(var.kvm_hosts,1).user}@${element(var.kvm_hosts,1).host}:${element(var.kvm_hosts,1).port}/system" + alias = "kvm1" +} + +provider "libvirt" { + uri = "qemu+ssh://${element(var.kvm_hosts,2).user}@${element(var.kvm_hosts,2).host}:${element(var.kvm_hosts,2).port}/system" + alias = "kvm2" +} + +locals { + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null + network_spec: null, + }), + merge(var.controller_profile, { + data_disk_spec: null, + network_spec: null, + }), + ] +} + +module "wsf_kvm0" { + source = "./template/terraform/kvm/local" + + job_id = var.wl_namespace + ssh_pub_key = file("${path.root}/ssh_access.key.pub") + instance_profiles = local.instance_profiles + + kvm_index = 0 + kvm_host = var.kvm_hosts.0 + providers = { + libvirt = libvirt.kvm0 + } +} + +module "wsf_kvm1" { + source = "./template/terraform/kvm/local" + + job_id = var.wl_namespace + ssh_pub_key = file("${path.root}/ssh_access.key.pub") + instance_profiles = local.instance_profiles + + kvm_index = 1 + kvm_host = element(var.kvm_hosts,1) + providers = { + libvirt = libvirt.kvm1 + } +} + +module "wsf_kvm2" { + source = "./template/terraform/kvm/local" + + job_id = var.wl_namespace + ssh_pub_key = file("${path.root}/ssh_access.key.pub") + instance_profiles = local.instance_profiles + + kvm_index = 2 + kvm_host = element(var.kvm_hosts,2) + providers = { + libvirt = libvirt.kvm2 + } +} + +output "options" { + value = merge({ + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + k8s_enable_registry: true, + }, { + for k,v in try(module.wsf_kvm0.options,{}): k => v + }, { + for k,v in try(module.wsf_kvm1.options,{}): k => v + }, { + for k,v in try(module.wsf_kvm2.options,{}): k => v + }) +} + +output "instances" { + sensitive = true + value = merge({ + for k,v in module.wsf_kvm0.instances : k => merge(v, { + csp = "kvm", + }) + }, { + for k,v in module.wsf_kvm1.instances : k => merge(v, { + csp = "kvm", + }) + }, { + for k,v in module.wsf_kvm2.instances : k => merge(v, { + csp = "kvm", + }) + }) +} + diff --git a/script/terraform/terraform-config.oracle.tf b/script/terraform/terraform-config.oracle.tf new file mode 100644 index 0000000..f4c68e3 --- /dev/null +++ b/script/terraform/terraform-config.oracle.tf @@ -0,0 +1,181 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "scsi" + disk_performance = "0" + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "scsi" + disk_performance = "0" + } +} + +variable "network_spec_1" { + default = { + network_count = 1 + network_type = null + } +} + +variable "region" { + default = null +} + +variable "zone" { + default = "Qrha:PHX-AD-1" +} + +variable "compartment" { + default = "ocid1.compartment.oc1..aaaaaaaarx6edbbm7qv6lpivqk6pojsxilp63lqftaid27xkh5kqpd3npcea" +} + +variable "owner" { + default = "" +} + +variable "custom_tags" { + default = {} +} + +variable "wl_name" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + instance_type = "VM.Standard3.Flex" + cpu_model_regex = null + cpu_core_count = 1 + memory_size = 1 + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_size = 200 + os_disk_performance = null + + data_disk_spec = null + network_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + instance_type = "VM.Standard3.Flex" + cpu_model_regex = null + cpu_core_count = 2 + memory_size = 2 + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_size = 200 + os_disk_performance = null + + data_disk_spec = null + network_spec = null + } +} + +variable "controller_profile" { + default = { + name = "controller" + instance_type = "VM.Standard3.Flex" + cpu_model_regex = null + cpu_core_count = 2 + memory_size = 2 + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_size = 200 + os_disk_performance = null + + data_disk_spec = null + network_spec = null + } +} + +module "wsf" { + source = "./template/terraform/oracle/main" + + region = var.region + zone = var.zone + compartment = var.compartment + job_id = var.wl_namespace + + sg_whitelist_cidr_blocks = compact(split("\n",file("${path.module}/proxy-ip-list.txt"))) + ssh_pub_key = file("${path.module}/ssh_access.key.pub") + ssh_private_key_file = "${path.module}/ssh_access.key" + + common_tags = { + for k,v in merge(var.custom_tags, { + owner: var.owner, + workload: var.wl_name, + }) : k => substr(replace(lower(v), "/[^a-z0-9_-]/", ""), 0, 63) + } + + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + network_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null + network_spec: null, + }), + merge(var.controller_profile, { + data_disk_spec: null, + network_spec: null, + }), + ] +} + +output "options" { + value = { + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + } +} + +output "instances" { + sensitive = true + value = { + for k,v in module.wsf.instances : k => merge(v, { + csp = "oracle", + zone = var.zone, + }) + } +} + +output "terraform_replace" { + value = lookup(module.wsf, "terraform_replace", null)==null?null:{ + command = replace(module.wsf.terraform_replace.command, "=", "=module.wsf.") + cpu_model = module.wsf.terraform_replace.cpu_model + } +} + diff --git a/script/terraform/terraform-config.static.tf b/script/terraform/terraform-config.static.tf new file mode 100644 index 0000000..a0e8d86 --- /dev/null +++ b/script/terraform/terraform-config.static.tf @@ -0,0 +1,153 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# +variable "wl_name" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "intel_publisher_sut_machine_type" { + default = "static" +} + +variable "intel_publisher_sut_metadata" { + default = "" +} + +variable "worker_profile" { + default = { + vm_count = 1 + hosts = { + "worker-0": { + # Note: Uncomment and specify your user name + # "user_name": "", + "public_ip": "127.0.0.1", + "private_ip": "127.0.0.1", + "ssh_port": 22, + # Note: Support PDU for power measurement. Leave pdu_password empty. + # "pdu_port": "0", + # "pdu_group": "", + # "pdu_ip": "127.0.1.1", + # "pdu_user": "", + # "pdu_password": "", + # Note: Support BMC for power cycle SUT. Leave bmc_password empty. + # "bmc_ip": "127.0.0.1", + # "bmc_port": 623, + # "bmc_user": "", + # "bmc_password": "" + # Note: Support Windows WINRM. Leave the winrm_password empty. + # "winrm_user": "" + # "winrm_password": "" + # Specify passwords in script/csp/.static/config.json, support both global password or password by host ip + # { + # "winrm_password": "", + # "bmc_password": "", + # "pdu_password": "", + # "hosts": { + # "host_ip": { + # "pdu_password": "", + # "bmc_password": "", + # "winrm_password": "" + # } + # } + # } + }, + } + } +} + +variable "client_profile" { + default = { + vm_count = 1 + hosts = { + "client-0": { + # Note: Uncomment and specify your user name + # "user_name": "", + "public_ip": "127.0.0.1", + "private_ip": "127.0.0.1", + "ssh_port": 22, + # Note: Support PDU for power measurement. Leave pdu_password empty. + # "pdu_port": "0", + # "pdu_group": "", + # "pdu_ip": "127.0.1.1", + # "pdu_user": "", + # "pdu_password": "", + # Note: Support BMC for power cycle SUT. Leave bmc_password empty. + # "bmc_ip": "127.0.0.1", + # "bmc_port": 623, + # "bmc_user": "", + # "bmc_password": "" + # Note: Support Windows WINRM. Leave the winrm_password empty. + # "winrm_user": "" + # "winrm_password": "" + # Specify passwords in script/csp/.static/config.json: + # { + # "winrm_password": "", + # "bmc_password": "", + # "pdu_password": { + # "pdu_ip": { + # "pdu_user": "" + # } + # } + # } + }, + } + } +} + +variable "controller_profile" { + default = { + vm_count = 1 + hosts = { + "controller-0": { + # Note: Uncomment and specify your user name + # "user_name": "", + "public_ip": "127.0.0.1", + "private_ip": "127.0.0.1", + "ssh_port": 22, + } + } + } +} + +output "instances" { + sensitive = true + value = merge({ + for i in range(var.worker_profile.vm_count) : + "worker-${i}" => merge(var.worker_profile.hosts[var.worker_profile.hosts["worker-0"].public_ip=="127.0.0.1"?"worker-0":"worker-${i}"], var.worker_profile.hosts["worker-0"].public_ip=="127.0.0.1"?{ + ansible_connection = "local" + }:{}) + }, { + for i in range(var.client_profile.vm_count) : + "client-${i}" => merge(var.client_profile.hosts[var.client_profile.hosts["client-0"].public_ip=="127.0.0.1"?"client-0":"client-${i}"], var.client_profile.hosts["client-0"].public_ip=="127.0.0.1"?{ + ansible_connection = "local" + }:{}) + }, { + for i in range(var.controller_profile.vm_count) : + "controller-${i}" => merge(var.controller_profile.hosts["controller-${i}"], var.controller_profile.hosts["controller-0"].public_ip=="127.0.0.1"?{ + ansible_connection = "local" + }:{}) + }) +} + +output "options" { + value = { + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + intel_publisher_sut_machine_type: var.intel_publisher_sut_machine_type, + intel_publisher_sut_metadata: var.intel_publisher_sut_metadata, + + # Enable k8s registry only in the DDCW use case. See doc/user-guide/preparing-infrastructure/setup-wsf.md + k8s_enable_registry: false, + } +} diff --git a/script/terraform/terraform-config.tencent.tf b/script/terraform/terraform-config.tencent.tf new file mode 100644 index 0000000..b08b521 --- /dev/null +++ b/script/terraform/terraform-config.tencent.tf @@ -0,0 +1,186 @@ +# +# Apache v2 license +# Copyright (C) 2023 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +variable "disk_spec_1" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "CLOUD_HSSD" + disk_iops = 0 + } +} + +variable "disk_spec_2" { + default = { + disk_count = 1 + disk_size = 200 + disk_format = "ext4" + disk_type = "CLOUD_HSSD" + disk_iops = 0 + } +} + +variable "region" { + default = null +} + +variable "zone" { + default = "ap-shanghai-8" +} + +variable "owner" { + default = "" +} + +variable "spot_instance" { + default = true +} + +variable "custom_tags" { + default = {} +} + +variable "wl_name" { + default = "" +} + +variable "wl_registry_map" { + default = "" +} + +variable "wl_namespace" { + default = "" +} + +variable "worker_profile" { + default = { + name = "worker" + instance_type = "S6.LARGE16" + cpu_model_regex = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "CLOUD_HSSD" + os_disk_size = 200 + + data_disk_spec = null + } +} + +variable "client_profile" { + default = { + name = "client" + instance_type = "S6.LARGE16" + cpu_model_regex = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "CLOUD_HSSD" + os_disk_size = 200 + + data_disk_spec = null + } +} + +variable "controller_profile" { + default = { + name = "controller" + instance_type = "S6.LARGE16" + cpu_model_regex = null + vm_count = 1 + + os_image = null + os_type = "ubuntu2204" + os_disk_type = "CLOUD_HSSD" + os_disk_size = 200 + + data_disk_spec = null + } +} + +module "wsf" { + source = "./template/terraform/tencent/main" + + region = var.region + zone = var.zone + job_id = var.wl_namespace + + sg_whitelist_cidr_blocks = compact(split("\n",file("proxy-ip-list.txt"))) + ssh_pub_key = file("ssh_access.key.pub") + + common_tags = { + for k,v in merge(var.custom_tags, { + owner: var.owner, + workload: var.wl_name, + }) : k => substr(replace(lower(v), "/[^a-z0-9_-]/", ""), 0, 63) + } + + instance_profiles = [ + merge(var.worker_profile, { + data_disk_spec: null, + }), + merge(var.client_profile, { + data_disk_spec: null, + }), + merge(var.controller_profile, { + data_disk_spec: null, + }), + ] + + spot_instance = var.spot_instance +} + +output "options" { + value = { + wl_name : var.wl_name, + wl_registry_map : var.wl_registry_map, + wl_namespace : var.wl_namespace, + + docker_dist_repo: "https://mirrors.aliyun.com/docker-ce", + containerd_pause_registry: "registry.aliyuncs.com/google_containers", + #docker_registry_mirrors: "https://mirror.ccs.tencentyun.com", + #containerd_registry_mirrors: "https://mirror.ccs.tencentyun.com", + + k8s_repo_key_url: { + "debian": "http://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg", + "centos": ["http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg","https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg"], + }, + k8s_repo_url: { + "debian": "http://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main", + "centos": "http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-$basearch", + }, + k8s_kubeadm_options: { + "ClusterConfiguration": { + "imageRepository": "registry.aliyuncs.com/google_containers", + }, + }, + k8s_preload_images: [ "public.ecr.aws/metakube/calico/cni:v3.27.3", "public.ecr.aws/metakube/calico/node:v3.27.3", "public.ecr.aws/metakube/calico/kube-controllers:v3.27.3" ] + k8s_registry_image: "public.ecr.aws/docker/library/registry:2", + k8s_calico_cni_repo: "public.ecr.aws/metakube/calico", + k8s_cni: "calico", + k8s_enable_nfd: false, + } +} + +output "instances" { + value = { + for k,v in module.wsf.instances : k => merge(v, { + csp = "tencent", + zone = var.zone, + }) + } +} + +output "terraform_replace" { + value = lookup(module.wsf, "terraform_replace", null)==null?null:{ + command = replace(module.wsf.terraform_replace.command, "=", "=module.wsf.") + cpu_model = module.wsf.terraform_replace.cpu_model + } +} +