Skip to content
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

Enhance GKE Backup Configuration Support #1349

Merged
merged 3 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 18 additions & 4 deletions modules/gke-cluster-autopilot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,25 @@ resource "google_gke_backup_backup_plan" "backup_plan" {
backup_schedule {
cron_schedule = each.value.schedule
}
#TODO add support for configs

backup_config {
include_volume_data = true
include_secrets = true
all_namespaces = true
include_volume_data = each.value.include_volume_data
include_secrets = each.value.include_secrets

dynamic "encryption_key" {
for_each = lookup(each.value, "encryption_key", null) != null ? [""] : []
content {
gcp_kms_encryption_key = each.value.encryption_key
}
}

all_namespaces = lookup(each.value, "namespaces", null) != null ? null : true
dynamic "selected_namespaces" {
for_each = lookup(each.value, "namespaces", null) != null ? [""] : []
content {
namespaces = each.value.namespaces
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions modules/gke-cluster-autopilot/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ variable "backup_configs" {
type = object({
enable_backup_agent = optional(bool, false)
backup_plans = optional(map(object({
encryption_key = optional(string)
include_secrets = optional(bool, true)
include_volume_data = optional(bool, true)
namespaces = optional(list(string))
region = string
schedule = string
retention_policy_days = optional(string)
Expand Down
22 changes: 18 additions & 4 deletions modules/gke-cluster-standard/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,25 @@ resource "google_gke_backup_backup_plan" "backup_plan" {
backup_schedule {
cron_schedule = each.value.schedule
}
#TODO add support for configs

backup_config {
include_volume_data = true
include_secrets = true
all_namespaces = true
include_volume_data = each.value.include_volume_data
include_secrets = each.value.include_secrets

dynamic "encryption_key" {
for_each = lookup(each.value, "encryption_key", null) != null ? [""] : []
tacchino marked this conversation as resolved.
Show resolved Hide resolved
content {
gcp_kms_encryption_key = each.value.encryption_key
}
}

all_namespaces = lookup(each.value, "namespaces", null) != null ? null : true
dynamic "selected_namespaces" {
for_each = lookup(each.value, "namespaces", null) != null ? [""] : []
tacchino marked this conversation as resolved.
Show resolved Hide resolved
content {
namespaces = each.value.namespaces
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions modules/gke-cluster-standard/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ variable "backup_configs" {
type = object({
enable_backup_agent = optional(bool, false)
backup_plans = optional(map(object({
encryption_key = optional(string)
include_secrets = optional(bool, true)
include_volume_data = optional(bool, true)
namespaces = optional(list(string))
region = string
schedule = string
retention_policy_days = optional(string)
Expand Down