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