### Initialize Terraform Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/gke/gke_live_migration/README.MD Initialize the Terraform CLI in the example root folder. Ensure Terraform is installed and configured. ```bash tofu init ``` -------------------------------- ### Start Minikube Cluster Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/anywhere/README.md Starts a Minikube cluster with 3 nodes. Ensure Docker Desktop is running. ```sh minikube start --nodes=3 ``` -------------------------------- ### Copy Example Terraform Variables Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/gke/gke_clusters_with_workspaces/README.md Before running the example, rename the provided variable files to their active counterparts. ```bash cp tf.vars.example tf.vars cp tf_clusterA.vars.example tf_clusterA.vars cp tf_clusterB.vars.example tf_clusterB.vars ``` -------------------------------- ### Initialize Terraform Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/aks/aks_cluster/README.MD Run this command in the example root folder to initialize Terraform and download necessary providers. ```bash terraform init ``` -------------------------------- ### Example Usage of castai_workload_scaling_policy_order Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/workload_scaling_policy_order.md This example demonstrates how to configure the order of workload scaling policies for a cluster. It fetches existing policy IDs, defines a custom order for specific policies, and then concatenates them with the remaining policies sorted alphabetically. ```terraform data "castai_workload_scaling_policy_order" "cluster" { cluster_id = castai_gke_cluster.cluster.id } locals { ordered_policy_ids = [ "be61e44b-0f7c-44da-b60e-0594d6fd3634", "f60b79f0-d21e-4eda-a59f-f5daa846d289", ] unordered_policy_ids = tolist(setsubtract(data.castai_workload_scaling_policy_order.cluster.policy_ids, local.ordered_policy_ids)) } resource "castai_workload_scaling_policy_order" "custom" { cluster_id = castai_gke_cluster.cluster.id policy_ids = concat(local.ordered_policy_ids, sort(local.unordered_policy_ids)) } ``` -------------------------------- ### Deploy Private Hosted Model Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/ai_optimizer_hosted_model.md This example shows how to deploy a private hosted model. No vLLM configuration is needed for private models. ```terraform resource "castai_ai_optimizer_hosted_model" "private_example" { cluster_id = castai_eks_cluster.example.id model_specs_id = castai_ai_optimizer_model_specs.private_example.id service = "custom-model" port = 8080 } ``` -------------------------------- ### Build and Clone CastAI Terraform Provider Source: https://github.com/castai/terraform-provider-castai/blob/master/README.md Clone the repository and build the provider locally. Ensure Go is installed and meets the requirements. ```bash git clone https://github.com/CastAI/terraform-provider-castai.git cd terraform-provider-castai make build ``` -------------------------------- ### Import castai_node_template resource example Source: https://github.com/castai/terraform-provider-castai/blob/master/README.md This command demonstrates how to import an existing `default-by-castai` node template into Terraform state. This is an optional step if following the migration guide. ```sh terraform import castai_node_template.default_by_castai 105e6fa3-20b1-424e-v589-9a64d1eeabea/default-by-castai ``` -------------------------------- ### EKS Cluster Authentication Configuration Example Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_existing/README.MD This snippet shows an example entry for the aws-auth ConfigMap, which might be necessary if your EKS cluster uses CONFIGMAP authentication mode. It ensures the instance profile used by CAST AI is present. ```yaml apiVersion: v1 kind: ConfigMap metadata: name: aws-auth namespace: kube-system data: mapRoles: - rolearn: arn:aws:iam::ACCOUNT_ID:role/CAST_AI_NODE_INSTANCE_ROLE username: castai-node-role groups: - system:bootstrappers - system:nodes ``` -------------------------------- ### Example Reservations CSV Structure Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/reservations.md Defines the expected structure for the reservations CSV file, including headers and example data for AWS reservations. ```csv name,provider,region,instance_type,price,count,start_date,end_date,zone_id,zone_name reservation1,aws,us-east-1,c5n.large,,1,2020-01-01T00:00:00Z,2050-01-01T00:00:00Z,, reservation2,aws,us-east-1,c5n.large,,2,2020-01-01T00:00:00Z,2050-01-01T00:00:01Z,, ``` -------------------------------- ### Kops Node Configuration Example Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/node_configuration.md Configure Kops specific settings for provisioned nodes, such as the AWS key pair ID. ```hcl kops { key_pair_id = "my-aws-key-pair" } ``` -------------------------------- ### castai_gke_cluster Resource Example Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/gke_cluster.md Example usage of the castai_gke_cluster resource to connect a GKE cluster to CAST AI. ```APIDOC ## castai_gke_cluster Resource ### Description Connects an existing GKE cluster to CAST AI. ### Schema #### Required - `location` (String) GCP cluster zone in case of zonal or region in case of regional cluster - `name` (String) GKE cluster name - `project_id` (String) GCP project id #### Optional - `credentials_json` (String, Sensitive) GCP credentials.json from ServiceAccount with credentials for CAST AI - `delete_nodes_on_disconnect` (Boolean) Should CAST AI remove nodes managed by CAST.AI on disconnect - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) #### Read-Only - `cluster_token` (String, Sensitive) CAST.AI agent cluster token - `credentials_id` (String) CAST AI credentials id for cluster - `id` (String) The ID of this resource. - `organization_id` (String) CAST AI organization ID ### Nested Schema for `timeouts` Optional: - `create` (String) - `delete` (String) - `update` (String) ### Example Usage ```terraform resource "castai_gke_cluster" "this" { project_id = var.project_id location = module.gke.location name = var.gke_cluster_name delete_nodes_on_disconnect = var.delete_nodes_on_disconnect credentials_json = var.gke_credentials } ``` ``` -------------------------------- ### Resource Operation Timeouts Example Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/node_configuration.md Define custom timeouts for create, delete, read, and update operations on node configuration resources. ```hcl timeouts { create = "30m" delete = "30m" read = "10m" update = "30m" } ``` -------------------------------- ### Example Usage of castai_gke_user_policies Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/data-sources/gke_user_policies.md Use this data source to fetch the required GCP policies for CAST AI integration. No specific configuration is needed for basic usage. ```terraform data "castai_gke_user_policies" "gke" {} ``` -------------------------------- ### Example Generated Resource Block after Import Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/workload_scaling_policy.md After running `terraform plan -out=import.plan -var-file=tf.vars -generate-config-out=generated.tf`, Terraform may generate resource blocks with zero values for certain parameters. This is an example of such a generated block. ```hcl cpu { look_back_period_seconds = 0 } ``` -------------------------------- ### GKE Node Configuration Example Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/node_configuration.md Configure GKE specific settings for provisioned nodes, such as disk type, load balancer configurations, maximum pods per node, network tags, and maintenance behavior. ```hcl gke { disk_type = "pd-ssd" loadbalancers { target_backend_pools { name = "my-target-backend-pool" } unmanaged_instance_groups { name = "my-instance-group" zone = "us-central1-a" } } max_pods_per_node = 100 max_pods_per_node_formula = "math.least(110, 5 * NUM_CPU, 5 * NUM_RAM_GB)" network_tags = ["tag1", "tag2"] on_host_maintenance = "terminate" secondary_ip_range { range_name = "pods" } use_ephemeral_storage_local_ssd = true zones = ["us-central1-a", "us-central1-b"] } ``` -------------------------------- ### Recommended: Use presets for standard metrics Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/workload_custom_metrics_data_source.md Use presets for standard metrics managed by CAST AI, which are kept up-to-date automatically. This example configures a Prometheus data source with the 'jvm' preset. ```terraform resource "castai_workload_custom_metrics_data_source" "prometheus" { cluster_id = castai_eks_cluster.this.id name = "my-prometheus" prometheus { url = "http://prometheus-server.monitoring.svc.cluster.local:9090" timeout = "30s" presets = ["jvm"] } } ``` -------------------------------- ### Azure Exported Reservations CSV Structure Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/reservations.md Provides an example of the CSV format for reservations exported from Azure, including specific Azure-related fields. ```csv Name,Reservation Id,Reservation order Id,Status,Expiration date,Purchase date,Term,Scope,Scope subscription,Scope resource group,Type,Product name,Region,Quantity,Utilization % 1 Day,Utilization % 7 Day,Utilization % 30 Day,Deep link to reservation VM_RI_01-01-2023_01-01,3b3de39c-bc44-4d69-be2d-69527dfe9958,630226bb-5170-4b95-90b0-f222757130c1,Succeeded,2050-01-01T00:00:00Z,2023-01-11T00:00:00Z,P3Y,Single subscription,8faa0959-093b-4612-8686-a996ac19db00,All resource groups,VirtualMachines,Standard_D32as_v4,eastus,3,100,100,100,https://portal.azure.com#resource/providers/microsoft.capacity/reservationOrders/59791a62-264b-4b9f-aa3a-5eeb761e4583/reservations/883afd52-54c8-4bc6-a0f2-ccbaf7b84bda/overview VM_RI_01-01-2023_01-02,3b3de39c-bc44-4d69-be2d-69527dfe9958,630226bb-5170-4b95-90b0-f222757130c1,Succeeded,2050-01-01T00:00:00Z,2023-01-11T00:00:01Z,P3Y,Single subscription,8faa0959-093b-4612-8686-a996ac19db00,All resource groups,VirtualMachines,Standard_D32as_v4,eastus,2,100,100,100,https://portal.azure.com#resource/providers/microsoft.capacity/reservationOrders/59791a62-264b-4b9f-aa3a-5eeb761e4583/reservations/25b95bdb-b78b-4973-a60c-71e70f158eca/overview VM_RI_01-01-2023_01-03,3b3de39c-bc44-4d69-be2d-69527dfe9958,630226bb-5170-4b95-90b0-f222757130c1,Succeeded,2050-01-01T00:00:00Z,2023-01-11T00:00:02Z,P3Y,Single subscription,8faa0959-093b-4612-8686-a996ac19db00,All resource groups,VirtualMachines,Standard_D32as_v4,eastus,1,100,100,100,https://portal.azure.com#resource/providers/microsoft.capacity/reservationOrders/59791a62-264b-4b9f-aa3a-5eeb761e4583/reservations/1745741b-f3c6-46a9-ad16-b93775a1bc38/overview ``` -------------------------------- ### Fetch CAST AI Runtime Rules Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_with_security_runtime_rules/README.MD Execute the provided shell script to fetch CAST AI runtime rules. This script requires 'jq' to be installed. You can fetch all rules or only those that are already enabled. ```bash # Fetch all rules ./fetch_castai_runtime_rules.sh # Fetch only already enabled rules ./fetch_castai_runtime_rules.sh --enabled-only ``` -------------------------------- ### Deploy CAST AI Spot Handler on AKS Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/aks/aks_cluster_gitops/README.md Installs the spot handler component. This command configures it to use the cluster's metadata and sets the provider to Azure. Ensure the `CAST_CONFIG_CLUSTERID` is correctly set. ```bash helm upgrade -i castai-spot-handler castai-helm/castai-spot-handler -n castai-agent \ --set "envFrom[0].configMapRef.name=$CAST_CONFIG_CLUSTERID" \ --set castai.provider=azure ``` -------------------------------- ### Deploy CAST AI Agent using Helm Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_gitops/README.md Installs or upgrades the castai-agent Helm chart. This is a mandatory component for cluster onboarding and requires the CAST AI API key and cluster ID. ```bash CASTAI_API_KEY="" CAST_CONFIG_CLUSTERID="castai-agent-metadata" CAST_SECRET_APIKEY="castai-agent" helm upgrade -i castai-agent castai-helm/castai-agent -n castai-agent --create-namespace \ --set apiKey="$CASTAI_API_KEY" \ --set provider=eks \ --set createNamespace=false \ --set metadataStore.enabled=true ``` -------------------------------- ### Importing an Existing Scaling Policy Order Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/workload_scaling_policy_order.md This example shows how to import an existing workload scaling policy order into your Terraform state. Ensure you have the correct cluster ID and adjust the import configuration as needed. ```terraform import { to = castai_workload_scaling_policy_order.custom id = var.castai_gke_cluster_id } ``` -------------------------------- ### EKS Settings Data Source Example Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/data-sources/eks_settings.md Use this data source to fetch EKS settings, including IAM policies, for a specified cluster. Ensure you have the necessary AWS credentials and cluster information configured. ```terraform data "castai_eks_settings" "current" { account_id = data.aws_caller_identity.current.account_id region = var.cluster_region cluster = var.cluster_name vpc = var.vpc } ``` -------------------------------- ### Initialize and Apply Terraform Configuration Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_existing_with_ai_optimizer/README.MD Initialize Terraform and apply the configuration to set up CAST AI resources, NVIDIA device plugin, and model deployments. Use `terraform destroy` to remove created resources. ```bash terraform init terraform apply terraform destroy ``` -------------------------------- ### Apply Terraform Configuration Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/aks/aks_cluster/README.MD Execute this command to create the resources defined in your Terraform configuration. ```bash terraform apply ``` -------------------------------- ### Initialize and Apply Terraform Configuration Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_kent/README.MD Initialize the Terraform working directory and apply the configuration to deploy the EKS cluster stack. Ensure you have filled in the required variables in `terraform.tfvars`. ```sh cp terraform.tfvars.example terraform.tfvars # fill in cluster_name, cluster_region, castai_api_token terraform init terraform apply ``` -------------------------------- ### Install CAST AI in read-only mode Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/gke/gke_cluster_gitops_umbrella_chart/README.md Installs the CAST AI umbrella Helm chart in read-only mode on a GKE cluster. This mode allows CAST AI to observe the cluster without making any changes to workloads or nodes. Requires a CAST AI member API key and Helm. ```sh helm upgrade -i castai castai-helm/castai -n castai-agent --create-namespace \ --set global.castai.apiKey="" \ --set global.castai.provider="gke" \ --set tags.readonly=true ``` -------------------------------- ### Example Usage of castai_workload_scaling_policy Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/workload_scaling_policy.md Demonstrates how to configure a workload scaling policy with various settings including assignment rules, CPU and memory scaling, predictive scaling, and anomaly detection. This is useful for defining fine-grained control over how workloads scale. ```terraform resource "castai_workload_scaling_policy" "services" { name = "services" cluster_id = castai_gke_cluster.dev.id apply_type = "IMMEDIATE" management_option = "MANAGED" assignment_rules { rules { namespace { names = ["default", "kube-system"] } } rules { workload { gvk = ["Deployment", "StatefulSet"] labels_expressions { key = "region" operator = "NotIn" values = ["eu-west-1", "eu-west-2"] } labels_expressions { key = "helm.sh/chart" operator = "Exists" } } } } cpu { function = "QUANTILE" overhead = 0.15 apply_threshold_strategy { type = "PERCENTAGE" percentage = 0.1 } args = ["0.9"] look_back_period_seconds = 172800 min = 0.1 max = 1 } memory { function = "MAX" overhead = 0.35 apply_threshold_strategy { type = "DEFAULT_ADAPTIVE" } limit { type = "MULTIPLIER" multiplier = 1.5 } management_option = "READ_ONLY" } predictive_scaling { cpu { enabled = true } } startup { period_seconds = 240 } downscaling { apply_type = "DEFERRED" } memory_event { apply_type = "IMMEDIATE" } anti_affinity { consider_anti_affinity = false } confidence { threshold = 0.9 } rollout_behavior { type = "NO_DISRUPTION" } anomaly_detection { cpu_pressure { cpu_stall_threshold_percentage = 50 min_pressured_pod_percentage = 30 } } jvm { memory { optimization = true } } excluded_containers = ["container-1", "container-2"] } ``` -------------------------------- ### Import Node Template by Cluster ID and Name Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/node_template.md Use this command to import a node template by providing its cluster ID and name. Ensure the cluster ID and node template name are correctly specified. ```shell # Import node template by specifying cluster ID and node template name. terraform import castai_node_template.default_by_castai 105e6fa3-20b1-424e-v589-9a64d1eeabea/default-by-castai ``` -------------------------------- ### Enable Debug Logging for Terraform Source: https://github.com/castai/terraform-provider-castai/blob/master/README.md To get more detailed logs during Terraform operations, set the `TF_LOG` environment variable to `DEBUG`. ```bash TF_LOG=DEBUG terraform plan ``` -------------------------------- ### Create Organization Workspace and Resources Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/gke/gke_clusters_with_workspaces/README.md Create a new Terraform workspace for the organization and apply the initial configuration using the organization's variable file. ```bash terraform workspace new org-workspace terraform plan -var-file=tf.vars terraform apply -var-file=tf.vars ``` -------------------------------- ### Plan Terraform Deployment Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/anywhere/README.md Previews the resources Terraform will create or modify. ```sh terraform plan ``` -------------------------------- ### Azure Commitments Configuration Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/commitments.md Example of configuring Azure Reserved Instances with specific matchers, allowed usage, and cluster assignments. Auto-assignment is enabled by default. ```terraform resource "castai_commitments" "azure_test" { azure_reservations_csv = file("./reservations.csv") commitment_configs { matcher { region = "eastus" type = "Standard_D32as_v4" name = "test-res-1" } prioritization = false allowed_usage = 0.9 status = "Active" scaling_strategy = "Default" assignments { cluster_id = "cluster-id-3" } assignments { cluster_id = "cluster-id-4" } } } ``` -------------------------------- ### Initialize and apply Terraform for Full mode Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/gke/gke_cluster_gitops_umbrella_chart/README.md Initializes the Terraform configuration and applies it to create a GCP service account with necessary IAM permissions for node provisioning and to register the cluster with CAST AI. This step is required before upgrading to Full mode. ```sh terraform init terraform apply ``` -------------------------------- ### Add castai-helm repository Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/gke/gke_cluster_gitops_umbrella_chart/README.md Adds the castai-helm repository to your Helm configuration and updates the repository list. This is a prerequisite for installing the CAST AI Helm chart. ```sh helm repo add castai-helm https://castai.github.io/helm-charts helm repo update ``` -------------------------------- ### Run Unit Tests for CastAI Terraform Provider Source: https://github.com/castai/terraform-provider-castai/blob/master/README.md Execute the unit tests for the provider using the `make test` command. ```bash make test ``` -------------------------------- ### Enable Extended Permissions in Terraform Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/castware-operator/README.md Set the `extended_permissions` variable to `true` in your Terraform configuration to enable extended permissions, which is required for installing the `cluster-controller` component. ```hcl extended_permissions = true ``` -------------------------------- ### Expected CAST AI Stream Connection Log Output Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_kent/README.MD This is an example of successful log messages indicating a healthy stream connection and registration with CAST AI. ```log msg="getStream: stream registered confirmation received, stream is ready" cluster_id= msg="streaming messages..." cluster_id= msg="stream connected, syncing all schedules to Kent" cluster_id= ``` -------------------------------- ### Configure Terraform for Local Provider Development Source: https://github.com/castai/terraform-provider-castai/blob/master/README.md Set up the `~/.terraformrc` file to use a locally built provider. Replace `` with the actual path to your cloned repository. ```terraform provider_installation { dev_overrides { "castai/castai" = "" } direct {} } ``` -------------------------------- ### Get Service Account Unique IDs Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/gke/gke_castai_iam/README.md Run this script to obtain the unique IDs for service accounts, which are necessary for configuring IAM policies with custom conditions. ```bash PROJECT_ID= LOCATION= CLUSTER_NAME= ./script.sh ``` -------------------------------- ### Granting EC2 and Pricing Read Permissions to Kentroller Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_kent/README.MD This example demonstrates how to create a dedicated IAM role with specific read permissions for EC2 inventory, instance offerings, spot-price, and pricing lookups, and associate it with the `castai-kentroller` ServiceAccount. ```terraform resource "aws_iam_role" "castai_kentroller" { name = "${var.cluster_name}-castai-kentroller" assume_role_policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = "sts:AssumeRole" Effect = "Allow" Principal = { Federated = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/${data.aws_eks_cluster.castai.identity.0.oidc.0.issuer}" } Condition = { "oidc.eks.amazonaws.com/TokenEx": { "${data.aws_eks_cluster.castai.identity.0.oidc.0.issuer}": "system:serviceaccount:castai-agent:castai-kentroller" } } } ] }) } resource "aws_iam_role_policy" "castai_kentroller" { name = "castai-kentroller" role = aws_iam_role.castai_kentroller.id policy = jsonencode({ Version = "2012-10-17" Statement = [ { Action = [ "ec2:DescribeInstanceTypes", "ec2:DescribeInstances", "ec2:DescribeImages", "ec2:DescribeSubnets", "ec2:DescribeSecurityGroups", "ec2:DescribeVpcs", "ec2:DescribeAddresses", "ec2:DescribeNetworkInterfaces", "ec2:DescribeInstanceAttribute", "ec2:DescribeInstanceTopology", "ec2:DescribeInstanceStatus", "ec2:DescribeEbsVolumes", "ec2:DescribeVolumesModifications", "ec2:DescribeSnapshots", "ec2:DescribeTags", "ec2:DescribeRegions", "ec2:DescribeAvailabilityZones", "ec2:DescribeHostTenancy" ] Effect = "Allow" Resource = "*" }, { Action = "pricing:GetProducts" Effect = "Allow" Resource = "*" }, { Action = "eks:DescribeCluster" Effect = "Allow" Resource = "${data.aws_eks_cluster.castai.arn}" } ] }) } resource "aws_eks_pod_identity_association" "castai_kentroller" { cluster_id = data.aws_eks_cluster.castai.id namespace = "castai-agent" service_account_name = "castai-kentroller" role_arn = aws_iam_role.castai_kentroller.arn } ``` -------------------------------- ### Deploy CAST AI Workload Autoscaler using Helm Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_gitops/README.md Installs or upgrades the castai-workload-autoscaler Helm chart. This component requires specific secret and configMap references for its configuration. ```bash helm upgrade -i castai-workload-autoscaler castai-helm/castai-workload-autoscaler -n castai-agent \ --set "envFrom[0].secretRef.name=$CAST_SECRET_APIKEY" \ --set "envFrom[1].configMapRef.name=$CAST_CONFIG_CLUSTERID" \ ``` -------------------------------- ### Enable CAST AI Live Migrations (CLM) Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_kent/README.MD Configure the `kent` subchart to enable live migrations by setting the CLM controller replica count. ```hcl kent = { enabled = true castai-live = { controller = { replicaCount = 2 } } } ``` -------------------------------- ### Retrieve CAST AI Cluster ID Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_kent/README.MD Get the CAST AI cluster ID from the agent's ConfigMap, which is used for identification within the CAST AI platform. ```sh kubectl -n castai-agent get cm castai-agent-metadata -o jsonpath='{.data.CLUSTER_ID}' ``` -------------------------------- ### Configure S3 Model Registry Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/resources/ai_optimizer_model_registry.md Example of how to configure an AWS S3 bucket as the AI optimizer model registry. Ensure the `registry_credentials` variable is properly set with JSON-encoded credentials. ```terraform resource "castai_ai_optimizer_model_registry" "example" { provider_type = "S3" credentials = var.registry_credentials s3 { bucket = "my-company-model-registry" region = "us-east-1" prefix = "models/" } } ``` -------------------------------- ### Example Usage of castai_workload_scaling_policy_order Source: https://github.com/castai/terraform-provider-castai/blob/master/docs/data-sources/workload_scaling_policy_order.md Use this data source to fetch the ordered list of workload scaling policies for a given Cast AI cluster. It requires the cluster ID as input. ```terraform data "castai_workload_scaling_policy_order" "cluster" { cluster_id = castai_gke_cluster.cluster.id } ``` -------------------------------- ### Deploy CAST AI Spot Handler using Helm Source: https://github.com/castai/terraform-provider-castai/blob/master/examples/eks/eks_cluster_gitops/README.md Installs or upgrades the castai-spot-handler Helm chart. This component is configured using a ConfigMap and specifies the cloud provider as AWS. ```bash helm upgrade -i castai-spot-handler castai-helm/castai-spot-handler -n castai-agent \ --set "envFrom[0].configMapRef.name=$CAST_CONFIG_CLUSTERID" \ --set castai.provider=aws ```