Is it possible to configure a kubernetes_persistent_volume using DigitalOcean volumes with Terraform? I can do it with a YAML file for kubectl. eg:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: myapp
name: myapp-config-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: do-block-storage
but when I try to do the same with Terraform, it wants a persistent_volume_source. Offering an empty persistence_volume_source will pass a terraform plan, but when I try to apply, it complains. “Error: PersistentVolume “myapp-config-pv” is invalid: spec: Required value: must specify a volume type”
resource "kubernetes_persistent_volume" "myapp-config-pv" {
metadata {
name = "myapp-config-pv"
}
spec {
access_modes = ["ReadWriteOnce"]
storage_class_name = "do-block-storage"
persistent_volume_source { }
capacity = {
storage = "1Gi"
}
}
}
I don’t really know where to go from here. None of the arguments in the TF docs ( https://www.terraform.io/docs/providers/kubernetes/r/persistent_volume.html#persistent_volume_source-1 ) seem relevant. What am I missing?
3 posts - 2 participants