init: copied modules from lawndale-infra
This commit is contained in:
23
9p-persistent-volume/outputs.tf
Normal file
23
9p-persistent-volume/outputs.tf
Normal file
@@ -0,0 +1,23 @@
|
||||
output "namespace" {
|
||||
value = var.namespace
|
||||
}
|
||||
|
||||
output "host_path" {
|
||||
value = local.host_path
|
||||
}
|
||||
|
||||
output "pv_name" {
|
||||
value = kubernetes_persistent_volume.this.metadata.0.name
|
||||
}
|
||||
|
||||
output "pvc_name" {
|
||||
value = kubernetes_persistent_volume_claim.this.metadata.0.name
|
||||
}
|
||||
|
||||
output "persistent_volume" {
|
||||
value = kubernetes_persistent_volume.this
|
||||
}
|
||||
|
||||
output "persistent_volume_claim" {
|
||||
value = kubernetes_persistent_volume_claim.this
|
||||
}
|
||||
9
9p-persistent-volume/providers.tf
Normal file
9
9p-persistent-volume/providers.tf
Normal file
@@ -0,0 +1,9 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.11"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
9p-persistent-volume/variables.tf
Normal file
15
9p-persistent-volume/variables.tf
Normal file
@@ -0,0 +1,15 @@
|
||||
variable "name" {
|
||||
type = string
|
||||
description = "The name of the volume"
|
||||
}
|
||||
|
||||
variable "namespace" {
|
||||
type = string
|
||||
description = "The namespace for the persistent volume claim"
|
||||
}
|
||||
|
||||
variable "volume_storage_capacity" {
|
||||
type = string
|
||||
description = "Size of the persistent volume reported to Kubernetes"
|
||||
default = "1Gi"
|
||||
}
|
||||
37
9p-persistent-volume/volume.tf
Normal file
37
9p-persistent-volume/volume.tf
Normal file
@@ -0,0 +1,37 @@
|
||||
locals {
|
||||
pv_name = "pv-p9hostpath-${var.name}"
|
||||
host_path = "/mnt/datastore/${var.name}"
|
||||
}
|
||||
|
||||
resource "kubernetes_persistent_volume" "this" {
|
||||
metadata {
|
||||
name = local.pv_name
|
||||
}
|
||||
spec {
|
||||
capacity = {
|
||||
storage = var.volume_storage_capacity
|
||||
}
|
||||
access_modes = ["ReadWriteMany"]
|
||||
persistent_volume_source {
|
||||
host_path {
|
||||
path = local.host_path
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_persistent_volume_claim" "this" {
|
||||
metadata {
|
||||
name = var.name
|
||||
namespace = var.namespace
|
||||
}
|
||||
spec {
|
||||
access_modes = ["ReadWriteMany"]
|
||||
resources {
|
||||
requests = {
|
||||
storage = var.volume_storage_capacity
|
||||
}
|
||||
}
|
||||
volume_name = kubernetes_persistent_volume.this.metadata.0.name
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user