Dynamic provisioning of Cinder volume and Persistent volume using Terraform through Kubernetes

11/20/2018

I have been doing a research and I've been trying to find out if there is way to create Cinder and Persistent volumes dynamically using Terraform through Kubernetes. So I am taking info from here:

https://www.terraform.io/docs/providers/kubernetes/r/persistent_volume.html https://docs.okd.io/latest/install_config/persistent_storage/persistent_storage_cinder.html

but looks like Cinder volume must be created manually before and then Persistent volume could be associated with already created "volume_id" .

However, I believe there is a way of dynamic creation of PV looking here

https://www.terraform.io/docs/providers/kubernetes/d/storage_class.html

but I am not sure how should it looks like AND If it is possible using Terraform ?

Thank you !

-- Радослав Христов
kubernetes
openstack
terraform
terraform-provider-openstack

1 Answer

11/21/2018

I found the way .Here is the way to do that --> https://kubernetes.io/blog/2017/03/dynamic-provisioning-and-storage-classes-kubernetes/ and https://www.terraform.io/docs/providers/kubernetes/r/storage_class.html and https://kubernetes.io/docs/concepts/storage/storage-classes/#openstack-cinder

So when when you deploying with Terraform you must specify "storage_class_name = name_of_your_class" in your "resource "kubernetes_persistent_volume_claim"" in "spec" section .

Storage class must be created before tat in Kubernetes.

-- Радослав Христов
Source: StackOverflow