Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(releaseci): adding a dedicated disk/pv/pvc for release.ci as standard-zrs #768

Merged
merged 5 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,9 @@ locals {
weekly_ci_disk_size = 8
weekly_ci_access_modes = ["ReadWriteOnce"]

release_ci_disk_size = 64
smerle33 marked this conversation as resolved.
Show resolved Hide resolved
release_ci_access_modes = ["ReadWriteOnce"]


end_dates = yamldecode(data.local_file.locals_yaml.content).end_dates
}
11 changes: 11 additions & 0 deletions privatek8s.tf
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,17 @@ resource "kubernetes_storage_class" "managed_csi_standard_ZRS_retain_private" {
allow_volume_expansion = true
}

resource "kubernetes_storage_class" "statically_provisionned_privatek8s" {
metadata {
name = "statically-provisionned"
}
storage_provisioner = "disk.csi.azure.com"
reclaim_policy = "Retain"
provider = kubernetes.publick8s
smerle33 marked this conversation as resolved.
Show resolved Hide resolved
allow_volume_expansion = true
}


# Used later by the load balancer deployed on the cluster, see https://github.com/jenkins-infra/kubernetes-management/config/privatek8s.yaml
resource "azurerm_public_ip" "public_privatek8s" {
name = "public-privatek8s"
Expand Down
70 changes: 70 additions & 0 deletions release.ci.jenkins.io.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
resource "azurerm_resource_group" "release_ci_controller" {
name = "release-ci"
location = "East US 2"
smerle33 marked this conversation as resolved.
Show resolved Hide resolved
}

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 = local.release_ci_disk_size
tags = {
environment = azurerm_resource_group.release_ci_controller.name
}
}

resource "kubernetes_persistent_volume" "jenkins_release_data" {
provider = kubernetes.publick8s
smerle33 marked this conversation as resolved.
Show resolved Hide resolved
metadata {
name = "jenkins-release-pv"
}
spec {
capacity = {
storage = local.release_ci_disk_size
}
access_modes = local.release_ci_access_modes
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.publick8s
smerle33 marked this conversation as resolved.
Show resolved Hide resolved
metadata {
name = "jenkins-release-data"
namespace = "jenkins-release"
}
spec {
access_modes = local.release_ci_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 = local.release_ci_disk_size
}
}
}
}

# Required to allow the release controller to read the 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.publick8s.identity[0].principal_id
smerle33 marked this conversation as resolved.
Show resolved Hide resolved
}