diff --git a/ipa.tf b/application.tf similarity index 53% rename from ipa.tf rename to application.tf index 80f6f95f..949ba2ba 100644 --- a/ipa.tf +++ b/application.tf @@ -9,10 +9,6 @@ locals { storage_class = var.on_prem_test == false ? "encrypted-gp2" : "nfs-client" acm_arn = var.acm_arn == "" && var.enable_waf == true ? aws_acm_certificate_validation.alb[0].certificate_arn : var.acm_arn efs_values = var.include_efs == true ? [<--, so we can make +# sure their credentials only have access to create -* k8s auth methods module "secrets-operator-setup" { depends_on = [ module.cluster, - time_sleep.wait_1_minutes_after_cluster + time_sleep.wait_1_minutes_after_cluster, + kubernetes_secret.harbor-pull-secret ] count = var.secrets_operator_enabled == true ? 1 : 0 source = "./modules/common/vault-secrets-operator-setup" @@ -371,32 +303,162 @@ module "secrets-operator-setup" { kubernetes_host = module.cluster.kubernetes_host } - -resource "helm_release" "ipa-vso" { - count = var.thanos_enabled == true ? 1 : 0 +resource "kubectl_manifest" "gp2-storageclass" { depends_on = [ module.cluster, - data.github_repository_file.data-crds-values, - module.secrets-operator-setup, time_sleep.wait_1_minutes_after_cluster ] + yaml_body = < + secretKey: + backup: + enabled: ${var.include_miniobkp} + schedule: "0 4 * * 2" # This schedules the job to run at 4:00 AM every Tuesday + localBackup: false image: - repository: ${var.image_registry}/ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator - collectorImage: - repository: ${var.image_registry}/docker.io/otel/opentelemetry-collector-contrib -EOF - , - < + secretKey: + url: http://minio-tenant-hl.insights.svc.cluster.local:9000 + weaviate: + env: + GOMEMLIMIT: "31GiB" # 1 less than the hard limit on the used nodes + backups: + s3: + enabled: true + envconfig: + BACKUP_S3_ENDPOINT: minio-tenant-hl.insights.svc.cluster.local:9000 + secrets: + AWS_ACCESS_KEY_ID: + AWS_SECRET_ACCESS_KEY: + EOF + ] -data "external" "git_information" { - program = ["sh", "${path.module}/get_sha.sh"] + insights_values = < + EOF } -output "git_sha" { - value = data.external.git_information.result.sha +module "insights" { + depends_on = [ + module.indico-common + ] + source = "./modules/common/insights" + count = var.insights_enabled ? 1 : 0 + argo_enabled = var.argo_enabled + github_repo_name = var.argo_repo + github_repo_branch = var.argo_branch + github_file_path = var.argo_path + github_commit_message = var.message + helm_registry = var.ipa_repo + namespace = "insights" + ins_pre_reqs_version = var.insights_pre_reqs_version + pre_reqs_values_yaml_b64 = var.insights-pre-reqs-values-yaml-b64 + ins_pre_reqs_values_overrides = local.insights_pre_reqs_values + account = var.aws_account + region = var.region + label = var.label + argo_application_name = lower("${var.aws_account}.${var.region}.${var.label}-insights") + vault_path = "tools/argo/data/ipa-deploy" + argo_server = module.cluster.kubernetes_host + argo_project_name = var.argo_enabled ? module.argo-registration[0].argo_project_name : "" + insights_version = var.insights_version + k8s_version = var.k8s_version + insights_values_terraform_overrides = local.insights_values + insights_values_overrides = var.insights_values } +# And we can install any additional helm charts at this point as well +module "additional_application" { + depends_on = [ + module.indico-common + ] -output "git_branch" { - value = data.external.git_information.result.branch + for_each = var.applications + + source = "./modules/common/application-deployment" + account = var.aws_account + region = var.region + label = var.label + namespace = each.value.namespace + argo_enabled = var.argo_enabled + github_repo_name = var.argo_repo + github_repo_branch = var.argo_branch + github_file_path = "${var.argo_path}/${each.value.name}_application.yaml" + github_commit_message = var.message + argo_application_name = lower("${var.aws_account}-${var.region}-${var.label}-${each.value.name}") + argo_vault_plugin_path = each.value.vaultPath + argo_server = module.cluster.kubernetes_host + argo_project_name = var.argo_enabled ? module.argo-registration[0].argo_project_name : "" + chart_name = each.value.chart + chart_repo = each.value.repo + chart_version = each.value.version + k8s_version = var.k8s_version + release_name = each.value.name + terraform_helm_values = "" + helm_values = trimspace(base64decode(each.value.values)) } -/* -resource "null_resource" "sleep-5-minutes-wait-for-charts-smoketest-build" { + +resource "argocd_application" "ipa" { depends_on = [ - time_sleep.wait_1_minutes_after_pre_reqs + # local_file.kubeconfig, + module.intake, + module.insights, + module.argo-registration, + kubernetes_job.snapshot-restore-job, ] - triggers = { - always_run = "${timestamp()}" + count = var.argo_enabled == true ? 1 : 0 + + wait = true + + metadata { + name = lower("${var.aws_account}-${var.region}-${var.label}-deploy-ipa") + namespace = var.argo_namespace + labels = { + test = "true" + } } - provisioner "local-exec" { - command = "sleep 300" + spec { + project = module.argo-registration[0].argo_project_name + + source { + repo_url = "https://github.com/IndicoDataSolutions/${var.argo_repo}.git" + path = var.argo_path + target_revision = var.argo_branch + directory { + recurse = false + jsonnet { + } + } + } + sync_policy { + automated { + prune = true + self_heal = true + allow_empty = false + } + sync_options = [ + "ServerSideApply=true", + "CreateNamespace=true" + ] + } + + destination { + #server = "https://kubernetes.default.svc" + name = "in-cluster" + namespace = var.argo_namespace + } + } + + timeouts { + create = "30m" + delete = "30m" } } -*/ resource "null_resource" "wait-for-tf-cod-chart-build" { count = var.argo_enabled == true ? 1 : 0 depends_on = [ - time_sleep.wait_1_minutes_after_pre_reqs, - helm_release.ipa-pre-requisites + module.intake, + module.indico-common ] triggers = { @@ -1036,7 +1295,6 @@ resource "null_resource" "wait-for-tf-cod-chart-build" { } } - output "harbor-api-token" { sensitive = true value = var.argo_enabled == true ? jsondecode(data.vault_kv_secret_v2.harbor-api-token[0].data_json)["bearer_token"] : "" @@ -1046,45 +1304,6 @@ output "smoketest_chart_version" { value = "${path.module}/validate_chart.sh terraform-smoketests 0.1.1-${data.external.git_information.result.branch}-${substr(data.external.git_information.result.sha, 0, 8)}" } -resource "helm_release" "terraform-smoketests" { - count = var.terraform_smoketests_enabled == true ? 1 : 0 - - depends_on = [ - null_resource.wait-for-tf-cod-chart-build, - #null_resource.sleep-5-minutes-wait-for-charts-smoketest-build, - kubernetes_config_map.terraform-variables, - helm_release.monitoring - ] - - verify = false - name = "terraform-smoketests-${substr(data.external.git_information.result.sha, 0, 8)}" - namespace = "default" - repository = var.ipa_repo - chart = "terraform-smoketests" - version = "0.1.1-${data.external.git_information.result.branch}-${substr(data.external.git_information.result.sha, 0, 8)}" - wait = true - wait_for_jobs = true - timeout = "300" # 5 minutes - disable_webhooks = false - values = [< + secretKey: +weaviate: + cronjob: + services: + weaviate-backup: + enabled: true + backupStorageConfig: + accessKey: + secretKey: + url: http://minio-tenant-hl.insights.svc.cluster.local:9000 + weaviate: + env: + GOMEMLIMIT: "31GiB" # 1 less than the hard limit on the used nodes + # TODO: enable this when we have a backup bucket + backups: + s3: + enabled: false + envconfig: + BACKUP_S3_ENDPOINT: minio-tenant-hl.insights.svc.cluster.local:9000 + secrets: + AWS_ACCESS_KEY_ID: + AWS_SECRET_ACCESS_KEY: + EOF + ] + + insights_values = < + tokenSecret: + cookieSecret: +insights-edge: + additionalAllowedOrigins: + - https://local.indico.io:1234 +server: + services: + lagoon: + env: + FIELD_AUTOCONFIRM_CONFIDENCE: 0.8 + FIELD_CONFIG_PATH: "fields_config.yaml" +ask-my-docs: + llmConfig: + llm: indico-azure-instance + azure: + apiBase: https://indico-openai.openai.azure.com/ + deployment: indico-gpt-4 + apiKey: + EOF +} + +module "insights" { + depends_on = [ + module.indico-common + ] + source = "../modules/common/insights" + count = var.insights_enabled ? 1 : 0 + argo_enabled = var.argo_enabled + github_repo_name = var.argo_repo + github_repo_branch = var.argo_branch + github_file_path = var.argo_path + github_commit_message = var.message + helm_registry = var.ipa_repo + namespace = "insights" + ins_pre_reqs_version = var.insights_pre_reqs_version + pre_reqs_values_yaml_b64 = var.insights-pre-reqs-values-yaml-b64 + ins_pre_reqs_values_overrides = local.insights_pre_reqs_values + account = var.account + region = var.region + label = var.label + argo_application_name = lower("${var.account}.${var.region}.${var.label}-insights") + vault_path = "tools/argo/data/ipa-deploy" + argo_server = module.cluster.kubernetes_host + argo_project_name = module.argo-registration[0].argo_project_name + insights_version = var.insights_version + k8s_version = var.k8s_version + insights_values_terraform_overrides = local.insights_values + insights_values_overrides = var.insights_values +} + +# And we can install any additional helm charts at this point as well +module "additional_application" { + depends_on = [ + module.indico-common + ] + + for_each = var.applications + + source = "../modules/common/application-deployment" + account = var.account + region = var.region + label = var.label + namespace = each.value.namespace + argo_enabled = var.argo_enabled + github_repo_name = var.argo_repo + github_repo_branch = var.argo_branch + github_file_path = "${var.argo_path}/${each.value.name}_application.yaml" + github_commit_message = var.message + argo_application_name = lower("${var.account}-${var.region}-${var.label}-${each.value.name}") + argo_vault_plugin_path = each.value.vaultPath + argo_server = module.cluster.kubernetes_host + argo_project_name = var.argo_enabled ? module.argo-registration[0].argo_project_name : "" + chart_name = each.value.chart + chart_repo = each.value.repo + chart_version = each.value.version + k8s_version = var.k8s_version + release_name = each.value.name + terraform_helm_values = "" + helm_values = trimspace(base64decode(each.value.values)) +} + +data "vault_kv_secret_v2" "zerossl_data" { + mount = local.customer_vault_mount_path + name = "zerossl" +} + +output "zerossl" { + sensitive = true + value = data.vault_kv_secret_v2.zerossl_data.data_json +} + +resource "argocd_application" "ipa" { + depends_on = [ + module.intake, + module.insights, + module.argo-registration, + helm_release.cod-snapshot-restore + ] + + count = var.ipa_enabled == true ? 1 : 0 + + wait = true + + metadata { + name = lower("${var.account}-${var.region}-${var.label}-deploy-ipa") + namespace = "argo" + labels = { + test = "true" + } + } + + spec { + + project = lower("${var.account}.${var.label}.${var.region}") + + source { + repo_url = "https://github.com/IndicoDataSolutions/${var.argo_repo}.git" + path = var.argo_path + target_revision = var.argo_branch + directory { + recurse = false + jsonnet { + } + } + } + + sync_policy { + automated { + prune = true + self_heal = true + allow_empty = false + } + sync_options = [ + "ServerSideApply=true", + "CreateNamespace=true" + ] + } + + destination { + server = "https://kubernetes.default.svc" + namespace = "argo" + } + } + + timeouts { + create = "30m" + delete = "30m" + } +} + +resource "null_resource" "wait-for-tf-cod-chart-build" { + count = var.argo_enabled == true ? 1 : 0 + + depends_on = [ + module.intake, + module.indico-common + ] + + triggers = { + always_run = "${timestamp()}" + } + + provisioner "local-exec" { + environment = { + HARBOR_API_TOKEN = jsondecode(data.vault_kv_secret_v2.harbor-api-token[0].data_json)["bearer_token"] + } + command = "${path.module}/validate_chart.sh terraform-smoketests 0.1.1-${data.external.git_information.result.branch}-${substr(data.external.git_information.result.sha, 0, 8)}" + } +} diff --git a/azure/ipa.tf b/azure/ipa.tf deleted file mode 100644 index 30992aec..00000000 --- a/azure/ipa.tf +++ /dev/null @@ -1,1084 +0,0 @@ -locals { - openshift_dns_credentials = <