-
Notifications
You must be signed in to change notification settings - Fork 28
/
release.ci.jenkins.io.tf
68 lines (63 loc) · 2.38 KB
/
release.ci.jenkins.io.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
resource "azurerm_resource_group" "release_ci_controller" {
name = "release-ci"
location = var.location
}
resource "azurerm_managed_disk" "jenkins_release_data" {
name = "jenkins-release-data"
location = azurerm_resource_group.release_ci_controller.location
resource_group_name = azurerm_resource_group.release_ci_controller.name
storage_account_type = "StandardSSD_ZRS"
create_option = "Empty"
disk_size_gb = 64
tags = local.default_tags
}
resource "kubernetes_persistent_volume" "jenkins_release_data" {
provider = kubernetes.privatek8s
metadata {
name = "jenkins-release-pv"
}
spec {
capacity = {
storage = "${azurerm_managed_disk.jenkins_release_data.disk_size_gb}Gi"
}
access_modes = ["ReadWriteOnce"]
persistent_volume_reclaim_policy = "Retain"
storage_class_name = kubernetes_storage_class.statically_provisionned_privatek8s.id
persistent_volume_source {
csi {
driver = "disk.csi.azure.com"
volume_handle = azurerm_managed_disk.jenkins_release_data.id
}
}
}
}
resource "kubernetes_persistent_volume_claim" "jenkins_release_data" {
provider = kubernetes.privatek8s
metadata {
name = "jenkins-release-data"
namespace = "jenkins-release"
}
spec {
access_modes = kubernetes_persistent_volume.jenkins_release_data.spec[0].access_modes
volume_name = kubernetes_persistent_volume.jenkins_release_data.metadata.0.name
storage_class_name = kubernetes_storage_class.statically_provisionned_privatek8s.id
resources {
requests = {
storage = "${azurerm_managed_disk.jenkins_release_data.disk_size_gb}Gi"
}
}
}
}
# Required to allow AKS CSI driver to access the Azure disk
resource "azurerm_role_definition" "release_ci_jenkins_io_controller_disk_reader" {
name = "ReadreleaseCIDisk"
scope = azurerm_resource_group.release_ci_controller.id
permissions {
actions = ["Microsoft.Compute/disks/read"]
}
}
resource "azurerm_role_assignment" "release_ci_jenkins_io_allow_azurerm" {
scope = azurerm_resource_group.release_ci_controller.id
role_definition_id = azurerm_role_definition.release_ci_jenkins_io_controller_disk_reader.role_definition_resource_id
principal_id = azurerm_kubernetes_cluster.privatek8s.identity[0].principal_id
}