From 7f4ef1b401d5ba8087921dd2cc2ac34675ce0ef7 Mon Sep 17 00:00:00 2001 From: Andrej Kislovskij Date: Thu, 7 Dec 2023 13:56:12 +0200 Subject: [PATCH] feat: Add pod-pinner to CAST AI onboarding --- main.tf | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ variables.tf | 6 ++++++ 2 files changed, 61 insertions(+) diff --git a/main.tf b/main.tf index c63d4e7..a36cd7e 100644 --- a/main.tf +++ b/main.tf @@ -242,6 +242,61 @@ resource "null_resource" "wait_for_cluster" { } } +resource "helm_release" "castai_pod_pinner" { + name = "castai-pod-pinner" + repository = "https://castai.github.io/helm-charts" + chart = "castai-pod-pinner" + namespace = "castai-agent" + create_namespace = true + cleanup_on_fail = true + wait = true + + set { + name = "castai.clusterID" + value = castai_gke_cluster.castai_cluster.id + } + + dynamic "set" { + for_each = var.api_url != "" ? [var.api_url] : [] + content { + name = "castai.apiURL" + value = var.api_url + } + } + + set_sensitive { + name = "castai.apiKey" + value = castai_gke_cluster.castai_cluster.cluster_token + } + + dynamic "set" { + for_each = var.grpc_url != "" ? [var.grpc_url] : [] + content { + name = "castai.grpcURL" + value = var.grpc_url + } + } + + dynamic "set" { + for_each = var.castai_components_labels + content { + name = "podLabels.${set.key}" + value = set.value + } + } + + set { + name = "replicaCount" + value = "0" + } + + depends_on = [helm_release.castai_agent] + + lifecycle { + ignore_changes = [set, version] + } +} + resource "helm_release" "castai_spot_handler" { name = "castai-spot-handler" repository = "https://castai.github.io/helm-charts" diff --git a/variables.tf b/variables.tf index 1336672..35aa329 100644 --- a/variables.tf +++ b/variables.tf @@ -11,6 +11,12 @@ variable "castai_api_token" { default = "" } +variable "grpc_url" { + type = string + description = "gRPC endpoint used by pod-pinner" + default = "grpc.cast.ai:443" +} + variable "project_id" { type = string description = "The project id from GCP"