-
Notifications
You must be signed in to change notification settings - Fork 992
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
storage_class_name = "" is treated as nil, preventing Google Filestore use #1379
Comments
Hello, I was able to reproduce your issue and even though I do not have any working knowledge of this library, here are the possible culprits
This here is tricky.
This checks if the old string is empty and emits addop or replaceop accordingly. However, the zero-state for // PVC spec
// Name of the StorageClass required by the claim.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1
// +optional
StorageClassName *string `json:"storageClassName,omitempty" protobuf:"bytes,5,opt,name=storageClassName"` // PV spec
// Name of StorageClass to which this persistent volume belongs. Empty value
// means that this volume does not belong to any StorageClass.
// +optional
StorageClassName string `json:"storageClassName,omitempty" protobuf:"bytes,6,opt,name=storageClassName"` I have so several questions here:
|
To emphasize the validity of this bug here is a reference to the official kubernetes docs , where you can see the comment
|
This makes TF unable to handle static configured PV's for the EFS CSI controller too. |
Yup, actually any class-less PVCs/PVs can't be described as resources currently. I raised this as a core terraform bug, but they redirected to the provider. Here's the relevant part: I'm trying to specify a
However, it looks like Terraform K8S provider interprets that as "use the default", which in this case, means that it looks up and uses the default storage class as the field value, and so it does not match with a class-less PV as expected. A literal empty string is required to tell Kubernetes that it should match against class-less persistent volumes. It'd be awesome to have a way to set the |
@dinibu https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest Requires kubernetes access during planning, other than that it'll work just fine. You can convert existing specs with k2tf. |
Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you! |
still broken |
Still broken. Trying to work around it by providing a kubernetes_manifest directly... |
Yes, something like this works to get around this for now: resource "kubernetes_manifest" "persistentvolumeclaim" {
manifest = yamldecode(<<-EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: whatever-pvc-name
namespace: whatever
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Mi
volumeName: existing-pv-name-goes-here
storageClassName: ""
EOF
)
} |
+1 to this issue. I am configuring a AWS S3 volume mount for EKS, and found the PVC's resource "kubernetes_persistent_volume" "default" {
metadata {
name = "${local.name}-pv"
}
spec {
capacity = {
storage = "5Gi"
}
access_modes = ["ReadWriteMany"]
storage_class_name = "" # it is treated as empty string correctly
persistent_volume_source {
csi {
driver = "s3.csi.aws.com"
volume_handle = "s3-csi-driver-volume"
volume_attributes = {
bucketName: aws_s3_bucket.default.id
}
}
}
}
}
resource "kubernetes_persistent_volume_claim" "default" {
metadata {
name = "${local.name}-pvc"
namespace = kubernetes_namespace_v1.ns.metadata.0.name
}
spec {
access_modes = ["ReadWriteMany"]
storage_class_name = "" # <- being treated as nil
resources {
requests = {
storage = "3Gi"
}
}
volume_name = kubernetes_persistent_volume.default.metadata.0.name
}
wait_until_bound = false
} |
@VardyNg use kubernetes_manifest instead, it just works ™ |
It works! Hopefully there will be a fix for this parameter as well |
Still not fixed :/ will switch to manifest |
Terraform Version, Provider Version and Kubernetes Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Can't paste the whole thing, contains proprietary information. Here's the relevant bits though: https://gist.github.com/dpkirchner/76447ded8e97ae7286a83faf034420df
Steps to Reproduce
terraform apply
kubectl get events -w
Expected Behavior
The PVC should have been created with an empty string for the storage class name.
Actual Behavior
The PVC ends up being created with the default ("standard") storage class name.
Community Note
The text was updated successfully, but these errors were encountered: