-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk8s-config.tf
80 lines (68 loc) · 2.36 KB
/
k8s-config.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#
# This module does Kubernetes configuration settings after provisioning
#
# Create unique ID for volumume
resource "random_pet" "volume" {}
provider "kubernetes" {
host = azurerm_kubernetes_cluster.default.kube_config.0.host
client_certificate = base64decode( azurerm_kubernetes_cluster.default.kube_config.0.client_certificate )
client_key = base64decode( azurerm_kubernetes_cluster.default.kube_config.0.client_key )
cluster_ca_certificate = base64decode( azurerm_kubernetes_cluster.default.kube_config.0.cluster_ca_certificate )
}
# Create Secret token to allow access from PVC to Azure storage account
resource "kubernetes_secret" "default" {
metadata {
name = "myclusterstorage-secret"
namespace = "default"
}
data = {
azurestorageaccountname = azurerm_storage_account.default.name
azurestorageaccountkey = azurerm_storage_account.default.primary_access_key
}
type = "Opaque"
}
# Create PV
resource "kubernetes_persistent_volume" "default" {
metadata {
name = "msr-pv"
}
spec {
capacity = {
storage = "10M"
}
access_modes = ["ReadWriteMany"]
persistent_volume_reclaim_policy = "Retain" # If set as "Delete" container would be removed after pvc deletion
storage_class_name = "azureblob-fuse-premium"
mount_options = [ "-o allow_other", "--file-cache-timeout-in-seconds=120" ]
persistent_volume_source {
csi {
driver = "blob.csi.azure.com"
read_only = "false"
volume_handle = "${random_pet.volume.id}"
volume_attributes = {
container_name = azurerm_storage_container.default.name
}
node_stage_secret_ref {
name = kubernetes_secret.default.metadata[0].name
namespace = "default"
}
}
}
}
}
# Create PVC
resource "kubernetes_persistent_volume_claim" "default" {
metadata {
name = "msr-pvc"
}
spec {
access_modes = [ "ReadWriteMany" ]
resources {
requests = {
storage = "10M"
}
}
volume_name = kubernetes_persistent_volume.default.metadata[0].name
storage_class_name = "azureblob-fuse-premium"
}
}