-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce node configuration (#11)
- Loading branch information
1 parent
55725d9
commit 0f04114
Showing
11 changed files
with
221 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
terraform.d | ||
.idea/ | ||
|
||
# terraform examples/ | ||
examples/**/.terraform/ | ||
examples/**/terraform.d/ | ||
examples/**/crash.log | ||
examples/**/*.tfstate | ||
examples/**/*.tfstate.backup | ||
examples/**/.terraform.lock.hcl | ||
examples/**/local.auto.tfvars | ||
examples/**/.kube/* | ||
terraform.tfstate | ||
.terraform* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
provider "helm" { | ||
kubernetes { | ||
host = azurerm_kubernetes_cluster.this.kube_config.0.host | ||
client_certificate = base64decode(azurerm_kubernetes_cluster.this.kube_config.0.client_certificate) | ||
client_key = base64decode(azurerm_kubernetes_cluster.this.kube_config.0.client_key) | ||
cluster_ca_certificate = base64decode(azurerm_kubernetes_cluster.this.kube_config.0.cluster_ca_certificate) | ||
} | ||
} | ||
|
||
resource "azurerm_resource_group" "this" { | ||
name = var.aks_cluster_name | ||
location = var.aks_cluster_region | ||
} | ||
|
||
resource "azurerm_virtual_network" "this" { | ||
name = "${var.aks_cluster_name}-network" | ||
location = azurerm_resource_group.this.location | ||
resource_group_name = azurerm_resource_group.this.name | ||
address_space = ["10.1.0.0/16"] | ||
} | ||
|
||
resource "azurerm_subnet" "internal" { | ||
name = "internal" | ||
virtual_network_name = azurerm_virtual_network.this.name | ||
resource_group_name = azurerm_resource_group.this.name | ||
address_prefixes = ["10.1.0.0/22"] | ||
} | ||
|
||
resource "azurerm_kubernetes_cluster" "this" { | ||
name = var.aks_cluster_name | ||
resource_group_name = azurerm_resource_group.this.name | ||
location = azurerm_resource_group.this.location | ||
dns_prefix = var.aks_cluster_name | ||
node_resource_group = "${var.aks_cluster_name}-ng" | ||
|
||
default_node_pool { | ||
name = "default" | ||
node_count = 1 | ||
vm_size = "Standard_D2_v2" | ||
vnet_subnet_id = azurerm_subnet.internal.id | ||
} | ||
|
||
identity { | ||
type = "SystemAssigned" | ||
} | ||
|
||
tags = { | ||
Environment = "Production" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
provider "castai" { | ||
api_token = var.castai_api_token | ||
} | ||
|
||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
data "azurerm_subscription" "current" {} | ||
|
||
provider "azuread" { | ||
tenant_id = data.azurerm_subscription.current.tenant_id | ||
} | ||
|
||
module "castai-aks-cluster" { | ||
source = "../../" | ||
|
||
aks_cluster_name = var.aks_cluster_name | ||
aks_cluster_region = var.aks_cluster_region | ||
subscription_id = data.azurerm_subscription.current.subscription_id | ||
tenant_id = data.azurerm_subscription.current.tenant_id | ||
|
||
node_resource_group = azurerm_kubernetes_cluster.this.node_resource_group | ||
resource_group = azurerm_kubernetes_cluster.this.resource_group_name | ||
delete_nodes_on_disconnect = true | ||
|
||
default_node_configuration = module.castai-aks-cluster.castai_node_configurations["default"] | ||
|
||
node_configurations = { | ||
default = { | ||
disk_cpu_ratio = 25 | ||
subnets = [azurerm_subnet.internal.id] | ||
tags = { | ||
"node-config" : "default" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
variable "castai_api_token" { | ||
type = string | ||
description = "CAST AI API token used for user authentication" | ||
} | ||
|
||
variable "aks_cluster_name" { | ||
type = string | ||
description = "Name of the AKS cluster, resources will be created for." | ||
default = "aks-basic" | ||
} | ||
|
||
variable "aks_cluster_region" { | ||
type = string | ||
description = "Region of the AKS cluster, resources will be created for." | ||
default = "westeurope" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
terraform { | ||
required_version = ">= 0.13" | ||
|
||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "3.7.0" | ||
} | ||
azuread = { | ||
source = "hashicorp/azuread" | ||
version = "2.22.0" | ||
} | ||
castai = { | ||
source = "castai/castai" | ||
version = ">= 0.26.3" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
output "cluster_id" { | ||
value = castai_aks_cluster.castai_cluster.id | ||
description = "CAST.AI cluster id, which can be used for accessing cluster data using API" | ||
sensitive = true | ||
} | ||
|
||
output "castai_node_configurations" { | ||
description = "Map of node configurations ids by name" | ||
value = { | ||
for k, v in castai_node_configuration.this : v.name => v.id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters