From 7367601d88199c635c51ca216f82dac544b13855 Mon Sep 17 00:00:00 2001 From: Shaohua Wen Date: Tue, 19 Mar 2024 15:58:15 +0700 Subject: [PATCH] show how to get admin password in the addon --- README.md | 1 + blueprints/01-getting-started/outputs.tf | 2 +- blueprints/02-at-scale/outputs.tf | 2 +- main.tf | 5 +++-- outputs.tf | 5 +++++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cee641b..ff09f08 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ The main components of CloudBees CD, use a file system to persist data. Data is | cbcd_domain_name | Route 53 Domain Name to host CloudBees CD Services. | | cbcd_flowserver_pod | Flow Server Pod for CloudBees CD Add-on. | | cbcd_namespace | Namespace for CloudBees CD Addon. | +| cbcd_password | Command to get the admin password of Cloudbees CD | | cbcd_url | URL for CloudBees CD Add-on. | | merged_helm_config | (merged) Helm Config for CloudBees CD | diff --git a/blueprints/01-getting-started/outputs.tf b/blueprints/01-getting-started/outputs.tf index f97ae6f..5f38667 100644 --- a/blueprints/01-getting-started/outputs.tf +++ b/blueprints/01-getting-started/outputs.tf @@ -27,7 +27,7 @@ output "cbcd_url" { output "cbcd_password" { description = "Command to get the admin password of Cloudbees CD" - value = "kubectl get secret --namespace ${module.eks_blueprints_addon_cbcd.cbcd_namespace} cloudbees-cd-cloudbees-flow-credentials -o jsonpath='{.data.CBF_SERVER_ADMIN_PASSWORD}' | base64 --decode; echo" + value = "module.eks_blueprints_addon_cbcd.cbcd_password" } output "acm_certificate_arn" { diff --git a/blueprints/02-at-scale/outputs.tf b/blueprints/02-at-scale/outputs.tf index 613ba0e..8248f88 100644 --- a/blueprints/02-at-scale/outputs.tf +++ b/blueprints/02-at-scale/outputs.tf @@ -25,7 +25,7 @@ output "cbcd_url" { output "cbcd_password" { description = "command to get the admin password of Cloudbees CD" - value = "kubectl get secret --namespace ${module.eks_blueprints_addon_cbcd.cbcd_namespace} cloudbees-cd-cloudbees-flow-credentials -o jsonpath='{.data.CBF_SERVER_ADMIN_PASSWORD}' | base64 --decode; echo" + value = "module.eks_blueprints_addon_cbcd.cbcd_password" } output "acm_certificate_arn" { diff --git a/main.tf b/main.tf index 08698f6..687485b 100644 --- a/main.tf +++ b/main.tf @@ -3,11 +3,12 @@ locals { flow_db_secret_data = fileexists(var.flow_db_secrets_file) ? yamldecode(file(var.flow_db_secrets_file)) : {} create_flow_db_secret = length(local.flow_db_secret_data) > 0 + namespace = try(var.helm_config.namespace, "cbcd") } resource "kubernetes_namespace" "cbcd" { metadata { - name = try(var.helm_config.namespace, "cbcd") + name = local.namespace } } @@ -25,7 +26,7 @@ resource "kubernetes_secret" "flow_db_secret" { resource "helm_release" "cloudbees_cd" { name = try(var.helm_config.name, "cloudbees-cd") - namespace = try(var.helm_config.namespace, "cbcd") + namespace = local.namespace create_namespace = false description = try(var.helm_config.description, null) chart = "cloudbees-flow" diff --git a/outputs.tf b/outputs.tf index 751e87e..394643d 100644 --- a/outputs.tf +++ b/outputs.tf @@ -15,6 +15,11 @@ output "cbcd_url" { value = "https://${var.host_name}" } +output "cbcd_password" { + description = "Command to get the admin password of Cloudbees CD" + value = "kubectl get secret --namespace ${local.namespace} cloudbees-cd-cloudbees-flow-credentials -o jsonpath='{.data.CBF_SERVER_ADMIN_PASSWORD}' | base64 --decode; echo" +} + output "cbcd_domain_name" { description = "Route 53 Domain Name to host CloudBees CD Services." value = var.host_name