-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add R/O Onboarding example for AKS (#230)
* Add R/O Onboarding example for AKS * remove unused variables * run make generate-sdk * update sdk --------- Co-authored-by: Phil Andrews <[email protected]> Co-authored-by: Phil Andrews <[email protected]>
- Loading branch information
1 parent
820d922
commit 3ed7998
Showing
8 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,23 @@ | ||
# AKS and CAST AI example with CAST AI Autoscaler policies and additional Node Configurations | ||
Following example shows how to onboard AKS cluster to CAST AI, configure [Autoscaler policies](https://docs.cast.ai/reference/policiesapi_upsertclusterpolicies) and additional [Node Configurations](https://docs.cast.ai/docs/node-configuration/). | ||
|
||
Example configuration should be analysed in the following order: | ||
1. Create Virtual network - `vnet.tf` | ||
2. Create AKS cluster - `aks.tf` | ||
3. Create CAST AI related resources to connect AKS cluster to CAST AI, configure Autoscaler and Node Configurations - `castai.tf` | ||
|
||
# Usage | ||
1. Rename `tf.vars.example` to `tf.vars` | ||
2. Update `tf.vars` file with your cluster name, cluster region and CAST AI API token. | ||
3. Initialize Terraform. Under example root folder run: | ||
``` | ||
terraform init | ||
``` | ||
4. Run Terraform apply: | ||
``` | ||
terraform apply -var-file=tf.vars | ||
``` | ||
5. To destroy resources created by this example: | ||
``` | ||
terraform destroy -var-file=tf.vars | ||
``` |
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,9 @@ | ||
data "azuread_client_config" "current" {} | ||
|
||
data "azurerm_subscription" "current" {} | ||
|
||
data "azurerm_kubernetes_cluster" "this" { | ||
name = var.cluster_name | ||
resource_group_name = var.resource_group | ||
} | ||
|
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,42 @@ | ||
# 3. Connect AKS cluster to CAST AI in READ-ONLY mode. | ||
|
||
# Configure Data sources and providers required for CAST AI connection. | ||
|
||
provider "castai" { | ||
api_url = var.castai_api_url | ||
api_token = var.castai_api_token | ||
} | ||
|
||
provider "helm" { | ||
kubernetes { | ||
host = data.azurerm_kubernetes_cluster.this.kube_config.0.host | ||
client_certificate = base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.client_certificate) | ||
client_key = base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.client_key) | ||
cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.this.kube_config.0.cluster_ca_certificate) | ||
} | ||
} | ||
|
||
resource "helm_release" "castai_agent" { | ||
name = "castai-agent" | ||
repository = "https://castai.github.io/helm-charts" | ||
chart = "castai-agent" | ||
namespace = "castai-agent" | ||
create_namespace = true | ||
cleanup_on_fail = true | ||
|
||
set { | ||
name = "provider" | ||
value = "aks" | ||
} | ||
set_sensitive { | ||
name = "apiKey" | ||
value = var.castai_api_token | ||
} | ||
|
||
# Required until https://github.com/castai/helm-charts/issues/135 is fixed. | ||
set { | ||
name = "createNamespace" | ||
value = "false" | ||
} | ||
} | ||
|
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,8 @@ | ||
# Following providers required by AKS and Vnet resources. | ||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
provider "azuread" { | ||
tenant_id = data.azurerm_subscription.current.tenant_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cluster_name = "EXAMPLE" | ||
cluster_region = "EXAMPLE" | ||
castai_api_token = "EXAMPLE" | ||
resource_group = "EXAMPLE_group" |
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,25 @@ | ||
variable "cluster_name" { | ||
type = string | ||
description = "Name of the AKS cluster to be connected to the CAST AI." | ||
} | ||
|
||
variable "cluster_region" { | ||
type = string | ||
description = "Region of the cluster to be connected to CAST AI." | ||
} | ||
|
||
variable "resource_group" { | ||
type = string | ||
description = "Azure resource group that contains the cluster." | ||
} | ||
|
||
variable "castai_api_url" { | ||
type = string | ||
description = "CAST AI url to API, default value is https://api.cast.ai" | ||
default = "https://api.cast.ai" | ||
} | ||
|
||
variable "castai_api_token" { | ||
type = string | ||
description = "CAST AI API token created in console.cast.ai API Access keys section." | ||
} |
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,14 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
} | ||
azuread = { | ||
source = "hashicorp/azuread" | ||
} | ||
castai = { | ||
source = "castai/castai" | ||
} | ||
} | ||
required_version = ">= 0.13" | ||
} |