hashicorp / terraform-provider-kubernetes

Terraform Kubernetes provider
https://www.terraform.io/docs/providers/kubernetes/
Mozilla Public License 2.0
1.59k stars 973 forks source link

Create kubernetes_persistent_volume_claim from snapshot #2608

Open divomen opened 1 week ago

divomen commented 1 week ago

Description

Currently kubernetes_persistent_volume_claim does not allow to specify data source. This prevents us from using terraform to automate volume backups.

Potential Terraform Configuration

resource "kubernetes_persistent_volume_claim" "default" {
  metadata {
    name = "my-pvc-clone"
  }
  spec {
    access_modes = ["ReadWriteOnce"]
    resources {
      requests = {
        storage = "1Gi"
      }
    }
    data_source {
      persistent_volume_claim {
        claim_name = "my-pvc-original"
      }
    }
  }
}

Сorresponding kubectl manifest

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc-clone
spec:
  dataSource:
    kind: PersistentVolumeClaim
    name: my-pvc-original
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
BBBmau commented 1 week ago

Looks like this was opened previously but wasn't worked on due to needing to support older k8s versions at the time. This isn't an issue now as it's been stable since v1.20

related issue: https://github.com/hashicorp/terraform-provider-kubernetes/issues/1232

JaylonmcShan03 commented 3 days ago

@BBBmau I can take this on for Q4 :)