From cc5c54234893a2e76e72b799ae519282ccc93df0 Mon Sep 17 00:00:00 2001 From: Shaohua Wen Date: Fri, 22 Mar 2024 16:13:14 +0700 Subject: [PATCH] fix velero error --- Makefile | 10 +++------- blueprints/01-getting-started/main.tf | 4 ++-- blueprints/02-at-scale/README.md | 14 ++++++++++++++ blueprints/02-at-scale/k8s/velero-values.yml | 2 +- blueprints/02-at-scale/main.tf | 4 +++- blueprints/02-at-scale/outputs.tf | 11 +++++++++++ 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index a84b106..4181fa1 100644 --- a/Makefile +++ b/Makefile @@ -112,18 +112,14 @@ else @printf $(MSG_ERROR) "Blueprint $(ROOT) did not complete the Deployment target thus it is not Ready to be validated." endif +blueprints/$(ROOT)/terraform.output: deploy + .PHONY: test -test: ## Runs a test for blueprint passed as parameters throughout their Terraform Lifecycle. Example: ROOT=02-at-scale make test +test: blueprints/$(ROOT)/terraform.output ## Runs a test for blueprint passed as parameters throughout their Terraform Lifecycle. Example: ROOT=02-at-scale make test @printf $(MSG_INFO) "Running Test for $(ROOT) blueprint ..." - $(call deploy,$(ROOT)) - until ls blueprints/$(ROOT)/terraform.output; do sleep 3 && echo "Waiting for output file..."; done ; -ifneq ("$(wildcard blueprints/$(ROOT)/terraform.output)","") $(call validate,$(ROOT)) $(call destroy,$(ROOT)) $(call clean,$(ROOT)) -else - @printf $(MSG_ERROR) "Blueprint $(ROOT) did not complete the Deployment target thus it is not Ready for the following phases." -endif .PHONY: test-all test-all: ## Runs test for all blueprints throughout their Terraform Lifecycle. Example: make test diff --git a/blueprints/01-getting-started/main.tf b/blueprints/01-getting-started/main.tf index 8b8188a..957412c 100644 --- a/blueprints/01-getting-started/main.tf +++ b/blueprints/01-getting-started/main.tf @@ -16,8 +16,8 @@ locals { vpc_cidr = "10.0.0.0/16" - #https://docs.cloudbees.com/docs/cloudbees-common/latest/supported-platforms/cloudbees-ci-cloud#_kubernetes - k8s_version = "1.27" + #https://docs.cloudbees.com/docs/cloudbees-common/latest/supported-platforms/cloudbees-cd-k8s#_supported_kubernetes_versions + k8s_version = "1.28" route53_zone_id = data.aws_route53_zone.this.id route53_zone_arn = data.aws_route53_zone.this.arn diff --git a/blueprints/02-at-scale/README.md b/blueprints/02-at-scale/README.md index 9aeac7d..cff1620 100644 --- a/blueprints/02-at-scale/README.md +++ b/blueprints/02-at-scale/README.md @@ -50,6 +50,8 @@ Once you have familiarized yourself with the [Getting Started blueprint](../01-g | eks_cluster_arn | EKS cluster ARN | | kubeconfig_add | Add Kubeconfig to local configuration to access the K8s API. | | kubeconfig_export | Export KUBECONFIG environment variable to access to access the K8s API. | +| rds_instance_id | DB identifier for CloudBees CD Add-on. | +| rds_snapshot_id | DB snapshot identifier for CloudBees CD Add-on. | | s3_cbcd_arn | cbcd s3 Bucket Arn | | s3_cbcd_name | cbcd s3 Bucket Name. It is required by Velero for backup | | velero_backup_on_demand_team_cd | Take an on-demand velero backup from the schedulle for Team CD. | @@ -83,6 +85,18 @@ Additionally, the following is required: ### Backups and Restores +- For Database Storage is based on RDS. + + - Create a snapshot of the RDS instance. + + ```sh + aws rds create-db-snapshot --db-instance-identifier $(terraform output --raw rds_instance_id) --db-snapshot-identifier $(terraform output --raw rds_snapshot_id) + ``` + - Restore the RDS instance from the snapshot. + ```sh + aws rds restore-db-instance-from-db-snapshot --db-instance-identifier $(terraform output --raw rds_instance_id) --db-snapshot-identifier $(terraform output --raw rds_snapshot_id) + ``` + - For EBS Storage is based on Velero. - Create a Velero Backup schedule for Team CD to take regular backups. diff --git a/blueprints/02-at-scale/k8s/velero-values.yml b/blueprints/02-at-scale/k8s/velero-values.yml index 468bc40..fba683d 100644 --- a/blueprints/02-at-scale/k8s/velero-values.yml +++ b/blueprints/02-at-scale/k8s/velero-values.yml @@ -5,5 +5,5 @@ kubectl: image: - #Issue #60 + #Issue https://github.com/cloudbees/terraform-aws-cloudbees-ci-eks-addon/issues/60 tag: 1.26.14-debian-11-r6 diff --git a/blueprints/02-at-scale/main.tf b/blueprints/02-at-scale/main.tf index a2fb2ec..c5b32db 100644 --- a/blueprints/02-at-scale/main.tf +++ b/blueprints/02-at-scale/main.tf @@ -38,6 +38,8 @@ locals { velero_s3_backup_location = "${module.cbcd_s3_bucket.s3_bucket_arn}/velero" velero_bk_demo = "team-cd-bk" + rds_instance_id = "flow-db-${random_string.dbsuffix.result}" + rds_snapshot_id = "flow-db-snapshot-${random_string.dbsuffix.result}" } ################################################################################ @@ -47,7 +49,7 @@ locals { module "db" { source = "terraform-aws-modules/rds/aws" - identifier = "flow-db-${random_string.dbsuffix.result}" + identifier = local.rds_instance_id # All available versions: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts engine = "postgres" diff --git a/blueprints/02-at-scale/outputs.tf b/blueprints/02-at-scale/outputs.tf index 0ff1633..f13a245 100644 --- a/blueprints/02-at-scale/outputs.tf +++ b/blueprints/02-at-scale/outputs.tf @@ -18,6 +18,7 @@ output "cbcd_namespace" { description = "Namespace for CloudBees CD Add-on." value = module.eks_blueprints_addon_cbcd.cbcd_namespace } + output "cbcd_url" { description = "URL of the CloudBees CD Operations Center for CloudBees CD Add-on." value = module.eks_blueprints_addon_cbcd.cbcd_url @@ -28,6 +29,16 @@ output "cbcd_password" { value = module.eks_blueprints_addon_cbcd.cbcd_password } +output "rds_instance_id" { + description = "DB identifier for CloudBees CD Add-on." + value = local.rds_instance_id +} + +output "rds_snapshot_id" { + description = "DB snapshot identifier for CloudBees CD Add-on." + value = local.rds_snapshot_id +} + output "acm_certificate_arn" { description = "ACM certificate ARN" value = module.acm.acm_certificate_arn