-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backup and restore the Terraform state #310
Comments
Let's discuss a typical Assume that we have a apiVersion: terraform.core.oam.dev/v1beta1
kind: Configuration
metadata:
name: alibaba-oss-bucket-hcl
spec:
hcl: |
resource "alicloud_oss_bucket" "bucket-acl" {
bucket = var.bucket
acl = var.acl
}
output "BUCKET_NAME" {
value = "${alicloud_oss_bucket.bucket-acl.bucket}.${alicloud_oss_bucket.bucket-acl.extranet_endpoint}"
}
variable "bucket" {
description = "OSS bucket name"
default = "vela-website"
type = string
}
variable "acl" {
description = "OSS bucket ACL, supported 'private', 'public-read', 'public-read-write'"
default = "private"
type = string
}
backend:
secretSuffix: oss
inClusterConfig: true
variable:
bucket: "vela-website-20211130-1900-51"
acl: "private"
writeConnectionSecretToRef:
name: oss-conn
namespace: default After we apply the
Now, we can Next, we assume that the kubernetes cluster has a disaster and is no longer avaialbe. We need to restore the configuration to a new kuberentes and don't recreate the cloud resource (the oss bucket is this scenario). First, we should rebuild the Terraform backend. we can read the Terraform state from the Second, we should restore the configuration object. We can just apply the |
@loheagn What are the exact procedures for restoring the state?
|
|
Any executable commands for step 1 and 2. And how do you verify your restore is successful? Append any evidence for it please. |
@loheagn Please also take a look at this requirement.
|
We can build a command line tool to
backeup
andrestore
the Configuration Object and the Terraform state. The command line tool may have two subcommands:backup
andrestore
.The usage of the
backup
subcommand may like this:The
restore
subcommand can be used to restore the Configuration Object and it will also restore the Terraform state if the configuration uses the default Terraform kubernetes backend.When the
retore
subcommand works, it will accept a yaml file or dir. It fetches the configuration definations from the yaml file or the dir, and check if the configurations use the default kubernetes backend, if the configuration does, therestore
subcommand will read thestate.json
file and restore the bakcend secret before resotring the configuration objects.The usage of the
restore
subcommand may like this:The text was updated successfully, but these errors were encountered: