Move media stack to tofu
This commit is contained in:
148
media/qbittorrent.tf
Normal file
148
media/qbittorrent.tf
Normal file
@@ -0,0 +1,148 @@
|
||||
variable "qbittorrent" {
|
||||
type = object({
|
||||
app_name = optional(string, "qbittorrent")
|
||||
image = string
|
||||
version = optional(string, "latest")
|
||||
subdomain = optional(string, "qbittorrent")
|
||||
port = optional(number, 8080)
|
||||
})
|
||||
}
|
||||
|
||||
resource "kubernetes_service_v1" "qbittorrent" {
|
||||
metadata {
|
||||
name = var.qbittorrent.app_name
|
||||
namespace = kubernetes_namespace_v1.media.metadata[0].name
|
||||
}
|
||||
|
||||
spec {
|
||||
selector = {
|
||||
app = var.qbittorrent.app_name
|
||||
}
|
||||
port {
|
||||
port = var.qbittorrent.port
|
||||
target_port = var.qbittorrent.port
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_ingress_v1" "qbittorrent" {
|
||||
metadata {
|
||||
name = var.qbittorrent.app_name
|
||||
namespace = kubernetes_namespace_v1.media.metadata[0].name
|
||||
|
||||
annotations = {
|
||||
"cert-manager.io/cluster-issuer" = "letsencrypt"
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
tls {
|
||||
hosts = ["${var.qbittorrent.subdomain}.${var.domain}"]
|
||||
secret_name = "${var.qbittorrent.app_name}-tls"
|
||||
}
|
||||
|
||||
rule {
|
||||
host = "${var.qbittorrent.subdomain}.${var.domain}"
|
||||
http {
|
||||
path {
|
||||
path = "/"
|
||||
path_type = "Prefix"
|
||||
backend {
|
||||
service {
|
||||
name = kubernetes_service_v1.qbittorrent.metadata[0].name
|
||||
port {
|
||||
number = var.qbittorrent.port
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_persistent_volume_claim_v1" "qbittorrent-config" {
|
||||
metadata {
|
||||
name = "${var.qbittorrent.app_name}-config"
|
||||
namespace = kubernetes_namespace_v1.media.metadata[0].name
|
||||
}
|
||||
|
||||
spec {
|
||||
storage_class_name = "local-path"
|
||||
access_modes = ["ReadWriteOnce"]
|
||||
|
||||
resources {
|
||||
requests = {
|
||||
storage = "1Gi"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_deployment_v1" "qbittorrent" {
|
||||
metadata {
|
||||
name = var.qbittorrent.app_name
|
||||
namespace = kubernetes_namespace_v1.media.metadata[0].name
|
||||
labels = {
|
||||
app = var.qbittorrent.app_name
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
replicas = 1
|
||||
selector {
|
||||
match_labels = {
|
||||
app = var.qbittorrent.app_name
|
||||
}
|
||||
}
|
||||
|
||||
template {
|
||||
metadata {
|
||||
labels = {
|
||||
"app" = var.qbittorrent.app_name
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
container {
|
||||
name = var.qbittorrent.app_name
|
||||
image = "${var.qbittorrent.image}:${var.qbittorrent.version}"
|
||||
image_pull_policy = "Always"
|
||||
|
||||
port {
|
||||
container_port = var.qbittorrent.port
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
name = "qbittorrent-config"
|
||||
mount_path = "/config"
|
||||
}
|
||||
volume_mount {
|
||||
name = "qbittorrent-data"
|
||||
mount_path = "/downloads"
|
||||
}
|
||||
resources {
|
||||
limits = {
|
||||
"memory" = "1Gi"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
volume {
|
||||
name = "qbittorrent-config"
|
||||
persistent_volume_claim {
|
||||
claim_name = kubernetes_persistent_volume_claim_v1.qbittorrent-config.metadata[0].name
|
||||
}
|
||||
}
|
||||
volume {
|
||||
name = "qbittorrent-data"
|
||||
nfs {
|
||||
path = "${var.media_storage.root_path}/${var.media_storage.torrent_path}"
|
||||
server = var.media_storage.server_ip
|
||||
read_only = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user