fixing tests and refactoring default
This commit is contained in:
parent
596acb63e4
commit
1fb7e114fd
|
@ -126,30 +126,30 @@ module "cluster-1" {
|
|||
|
||||
### Backup for GKE
|
||||
|
||||
This example shows how to [enable the Backup for GKE agent and configure a Backup Plan](https://cloud.google.com/kubernetes-engine/docs/how-to/cloud-dns) for GKE Standard clusters.
|
||||
This example shows how to [enable the Backup for GKE agent and configure a Backup Plan](https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/concepts/backup-for-gke) for GKE Standard clusters.
|
||||
|
||||
```hcl
|
||||
module "cluster-1" {
|
||||
source = "./fabric/modules/gke-cluster"
|
||||
project_id = var.project_id
|
||||
name = "cluster-1"
|
||||
location = "europe-west1"
|
||||
location = "europe-west1-b"
|
||||
vpc_config = {
|
||||
network = var.vpc.self_link
|
||||
subnetwork = var.subnet.self_link
|
||||
secondary_range_names = { pods = "pods", services = "services" }
|
||||
}
|
||||
backup_configs = {
|
||||
backup_configs = {
|
||||
enable_backup_agent = true
|
||||
backup_plans = {
|
||||
"backup-1" = {
|
||||
region = "europe-west-2"
|
||||
schedule = "0 9 * * 1"
|
||||
}
|
||||
region = "europe-west-2"
|
||||
schedule = "0 9 * * 1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=1 inventory=backup.yaml
|
||||
# tftest modules=1 resources=2 inventory=backup.yaml
|
||||
```
|
||||
<!-- BEGIN TFDOC -->
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ resource "google_container_cluster" "cluster" {
|
|||
enabled = var.enable_addons.config_connector
|
||||
}
|
||||
gke_backup_agent_config {
|
||||
enabled = try(var.backup_configs.enable_backup_agent, false)
|
||||
enabled = var.backup_configs.enable_backup_agent
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ resource "google_container_cluster" "cluster" {
|
|||
}
|
||||
|
||||
resource "google_gke_backup_backup_plan" "backup_plan" {
|
||||
for_each = try(var.backup_configs.enable_backup_agent, false) ? var.backup_configs.backup_plans : {}
|
||||
for_each = var.backup_configs.enable_backup_agent ? var.backup_configs.backup_plans : {}
|
||||
name = each.key
|
||||
cluster = google_container_cluster.cluster.id
|
||||
location = each.value.region
|
||||
|
|
|
@ -24,9 +24,10 @@ variable "backup_configs" {
|
|||
retention_policy_days = optional(string)
|
||||
retention_policy_lock = optional(bool, false)
|
||||
retention_policy_delete_lock_days = optional(string)
|
||||
})))
|
||||
})), {})
|
||||
})
|
||||
default = null
|
||||
default = {}
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "cluster_autoscaling" {
|
||||
|
|
|
@ -14,15 +14,25 @@
|
|||
|
||||
values:
|
||||
module.cluster-1.google_container_cluster.cluster:
|
||||
backup_configs:
|
||||
enable_backup_agent: true
|
||||
backup_plans:
|
||||
backup-1:
|
||||
region: europe-west2
|
||||
schedule: 0 9 * * 1
|
||||
retention_policy_days: 30
|
||||
retention_policy_lock: false
|
||||
retention_policy_delete_lock_days: 15
|
||||
location: europe-west1-b
|
||||
name: cluster-1
|
||||
|
||||
module.cluster-1.google_gke_backup_backup_plan.backup_plan["backup-1"]:
|
||||
backup_config:
|
||||
- all_namespaces: true
|
||||
encryption_key: []
|
||||
include_secrets: true
|
||||
include_volume_data: true
|
||||
selected_applications: []
|
||||
selected_namespaces: []
|
||||
backup_schedule:
|
||||
- cron_schedule: 0 9 * * 1
|
||||
location: europe-west-2
|
||||
name: backup-1
|
||||
project: project-id
|
||||
retention_policy:
|
||||
- locked: false
|
||||
|
||||
counts:
|
||||
google_container_cluster: 1
|
||||
google_gke_backup_backup_plan: 1
|
||||
|
|
Loading…
Reference in New Issue