-
Notifications
You must be signed in to change notification settings - Fork 993
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
Add an example for GKE + NFS + PVC #840
Conversation
capacity = { | ||
storage = "1T" | ||
} | ||
storage_class_name = "filestore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refer kubernetes_storage_class.nfs.metadata[0].name
instead of the literal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Done.
} | ||
spec { | ||
access_modes = ["ReadWriteMany"] | ||
storage_class_name = "filestore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
spec { | ||
access_modes = ["ReadWriteMany"] | ||
storage_class_name = "filestore" | ||
volume_name = "nfs-volume" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refer kubernetes_persistent_volume .example.metadata[0].name
?
storage = "1T" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nicer to add depends_on
.
For example,
depends_on = [kubernetes_persistent_volume.example]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this resource now has these references defined, there is an implicit dependency. So the PVC won't be created until the storageclass and the PV are created.
storage_class_name = kubernetes_storage_class.nfs.metadata[0].name
volume_name = kubernetes_persistent_volume.example.metadata[0].name
I looked it up in the docs to be sure:
"Explicitly specifying a dependency is only necessary when a resource relies on some other resource's behavior but doesn't access any of that resource's data in its arguments."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Let's keep the current implementation.
I got the error when executing Environment
Error messages
|
I'm glad you brought that up! I ran into that error too, with the node_version. It means there is a mismatch in version availability between the master and node. The availability of versions varies by zone, and the version that you pass in via the CLI might not be available in your chosen zone for both the master and node. I've made a change to the config that will install the latest version available for the master (since it looks like older versions are available for masters). And if no version is found, it'll use the GKE default. It worked in my testing when I passed in |
This example config shows how to use GKE with Google Filestore (NFS) to create Persistent Volumes in Kubernetes.
This example is great @dak1n1 thanks for making this. |
Co-authored-by: John Houston <jrhouston@users.noreply.github.com>
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Description
This example shows how to create a GKE cluster and use Google Filestore (NFS) to create Persistent Volumes in Kubernetes. It also mounts the volume to an example Deployment (mariadb) using a Persistent Volume Claim.
References
There is a limitation in the current version of the terraform-plugin-sdk, which makes it difficult to differentiate between
null
and""
values for attributes. For example, thestorage_class_name
attribute of thekubernetes_persistent_volume_claim
resource cannot accept a value of""
using the current SDK. It will interpret the value as if the attribute had been omitted entirely, which generally will cause Kubernetes to use the default storage class.This example demonstrates a workaround, which is to create a storageclass instead of attempting to use the blank value.
There are related issues that may be mitigated by this workaround.