terraform kubernetes_storage_class for azurefile on aks

6/16/2019

I am converting some kubernetes yaml files to terraform. I have got almost everything working but I am stuck with my storageClass. I need to use azurefile and I can not work out how to set the file permissions for the mount.

As far as I can tell this is the supported syntax:

resource "kubernetes_storage_class" "azurefile" {
  metadata {
    name = "azurefile"
  }
  storage_provisioner = "kubernetes.io/azure-file"
  reclaim_policy = "Retain"
  parameters {
    skuName = "Standard_LRS"
  }
}

However I don't know where I can specify mount options.

Here is the yaml I am starting with:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azurefile
provisioner: kubernetes.io/azure-file
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=1000
  - gid=1000
parameters:
  skuName: Standard_LRS

Is there any supported way to add in the mount options? If not, I will not be able to use azure file. Has anyone been able to do this and if not, do you have a work-around?

I know I can use local_exec (I had already done this) but that is what I am trying to move away from.

-- Leigh K
azure
azure-aks
azure-kubernetes
kubernetes
terraform

1 Answer

6/16/2019

yeah, looking at this it doesn't seem like mountOptions are supported in terraform yet.

-- 4c74356b41
Source: StackOverflow