From 459c933a9bdeef535a67dc698ab531fc0473aded Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Thu, 30 May 2024 14:22:08 +0530 Subject: [PATCH] chore: add testflight for cala --- ci/tasks/cala-smoketest.sh | 3 + ci/testflight/cala/main.tf | 86 +++++++++++++++++++ ci/testflight/cala/testflight-values.yml.tmpl | 9 ++ 3 files changed, 98 insertions(+) create mode 100755 ci/tasks/cala-smoketest.sh create mode 100644 ci/testflight/cala/main.tf create mode 100644 ci/testflight/cala/testflight-values.yml.tmpl diff --git a/ci/tasks/cala-smoketest.sh b/ci/tasks/cala-smoketest.sh new file mode 100755 index 0000000000..df3cd87a47 --- /dev/null +++ b/ci/tasks/cala-smoketest.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +set -eu diff --git a/ci/testflight/cala/main.tf b/ci/testflight/cala/main.tf new file mode 100644 index 0000000000..e1f50bf804 --- /dev/null +++ b/ci/testflight/cala/main.tf @@ -0,0 +1,86 @@ +variable "testflight_namespace" {} + +locals { + cluster_name = "galoy-staging-cluster" + cluster_location = "us-east1" + gcp_project = "galoy-staging" + + smoketest_namespace = "galoy-staging-smoketest" + testflight_namespace = var.testflight_namespace + +} + +resource "kubernetes_namespace" "testflight" { + metadata { + name = local.testflight_namespace + } +} + +resource "random_password" "postgresql" { + length = 20 + special = false +} + +resource "kubernetes_secret" "cala" { + metadata { + name = "cala" + namespace = kubernetes_namespace.testflight.metadata[0].name + } + + data = { + pg-user-pw : random_password.postgresql.result + pg-con : "postgres://cala:${random_password.postgresql.result}@cala-postgresql:5432/cala" + } +} + +resource "helm_release" "cala" { + name = "cala" + chart = "${path.module}/chart" + namespace = kubernetes_namespace.testflight.metadata[0].name + + values = [ + templatefile("${path.module}/testflight-values.yml.tmpl") + ] + + depends_on = [kubernetes_secret.cala] + + dependency_update = true +} + +resource "kubernetes_secret" "smoketest" { + metadata { + name = local.testflight_namespace + namespace = local.smoketest_namespace + } + data = {} +} + +data "google_container_cluster" "primary" { + project = local.gcp_project + name = local.cluster_name + location = local.cluster_location +} + +data "google_client_config" "default" { + provider = google-beta +} + +provider "kubernetes" { + host = "https://${data.google_container_cluster.primary.private_cluster_config.0.private_endpoint}" + token = data.google_client_config.default.access_token + cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth.0.cluster_ca_certificate) +} + +provider "kubernetes-alpha" { + host = "https://${data.google_container_cluster.primary.private_cluster_config.0.private_endpoint}" + token = data.google_client_config.default.access_token + cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth.0.cluster_ca_certificate) +} + +provider "helm" { + kubernetes { + host = "https://${data.google_container_cluster.primary.private_cluster_config.0.private_endpoint}" + token = data.google_client_config.default.access_token + cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth.0.cluster_ca_certificate) + } +} diff --git a/ci/testflight/cala/testflight-values.yml.tmpl b/ci/testflight/cala/testflight-values.yml.tmpl new file mode 100644 index 0000000000..413fc2b7c3 --- /dev/null +++ b/ci/testflight/cala/testflight-values.yml.tmpl @@ -0,0 +1,9 @@ +cala: + secrets: + create: false + +postgresql: + auth: + existingSecret: cala + secretKeys: + userPasswordKey: "pg-user-pw"