diff --git a/infra/.gitignore b/infra/.gitignore new file mode 100644 index 00000000..84fcb582 --- /dev/null +++ b/infra/.gitignore @@ -0,0 +1,2 @@ +*.tfstate* +.terraform diff --git a/infra/load-testing/azure.tf b/infra/load-testing/azure.tf new file mode 100644 index 00000000..ba8b0888 --- /dev/null +++ b/infra/load-testing/azure.tf @@ -0,0 +1,74 @@ +provider "azurerm" { + subscription_id = "${var.subscription_id}" + client_id = "${var.client_id}" + client_secret = "${var.client_secret}" + tenant_id = "${var.tenant_id}" +} + +resource "random_id" "namer" { + keepers = { + resource_group = "res" + container_service = "cs" + dns_prefix = "k8s" + } + + byte_length = 8 +} + +variable "username" { + type = "string" + default = "amis" +} + +resource "azurerm_resource_group" "test" { + name = "istanbul-test-${random_id.namer.hex}" + location = "Southeast Asia" +} + +resource "azurerm_container_service" "test" { + name = "istanbul-test-${random_id.namer.hex}" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + orchestration_platform = "Kubernetes" + + master_profile { + count = 1 + dns_prefix = "istanbul-${random_id.namer.hex}" + } + + linux_profile { + admin_username = "${var.username}" + + ssh_key { + key_data = "${file("~/.ssh/id_rsa.pub")}" + } + } + + agent_pool_profile { + name = "default" + count = "${length(var.svcs)}" + dns_prefix = "agent-${random_id.namer.hex}" + vm_size = "Standard_DS2_v2" + } + + service_principal { + client_id = "${var.client_id}" + client_secret = "${var.client_secret}" + } + + diagnostics_profile { + enabled = false + } + + tags { + Environment = "Testing" + } +} + +resource "null_resource" "kubeconfig" { + provisioner "local-exec" { + command = "sleep 10 && scp -o StrictHostKeyChecking=no ${var.username}@istanbul-${random_id.namer.hex}.${azurerm_resource_group.test.location}.cloudapp.azure.com:~/.kube/config ~/.kube/config" + interpreter = ["bash", "-c"] + } + depends_on = ["azurerm_container_service.test"] +} diff --git a/infra/load-testing/kubernetes.tf b/infra/load-testing/kubernetes.tf new file mode 100644 index 00000000..3d61a398 --- /dev/null +++ b/infra/load-testing/kubernetes.tf @@ -0,0 +1,20 @@ +resource "kubernetes_service" "validator-svc" { + metadata { + name = "validator-svc-${count.index}" + } + + spec { + selector { + app = "validator-${count.index}" + } + type = "LoadBalancer" + port { + port = 8546 + target_port = 8546 + } + + type = "LoadBalancer" + } + + count = "${length(var.svcs)}" +} \ No newline at end of file diff --git a/infra/load-testing/variables.tf b/infra/load-testing/variables.tf new file mode 100644 index 00000000..80ec9d02 --- /dev/null +++ b/infra/load-testing/variables.tf @@ -0,0 +1,12 @@ +variable "count" { + default = 4 +} + +variable "svcs" { + default = [0, 1, 2, 3] +} + +variable "subscription_id" {} +variable "client_id" {} +variable "client_secret" {} +variable "tenant_id" {}