Phase 5 — CI pipelines: - default.yml: add SOPS decrypt in prepare step, change git add . to specific paths (stacks/ state/ .woodpecker/), cleanup on success+failure - renew-tls.yml: change git add . to git add secrets/ state/ Phase 6 — sensitive=true: - Add sensitive = true to 256 variable declarations across 149 stack files - Prevents secret values from appearing in terraform plan output - Does NOT modify shared modules (ingress_factory, nfs_volume) to avoid breaking module interface contracts Note: CI pipeline SOPS decryption requires sops_age_key Woodpecker secret to be created before the pipeline will work with SOPS. Until then, the old terraform.tfvars path continues to function.
258 lines
6.2 KiB
HCL
258 lines
6.2 KiB
HCL
variable "tls_secret_name" {
|
|
type = string
|
|
sensitive = true
|
|
}
|
|
variable "nfs_server" { type = string }
|
|
|
|
|
|
resource "kubernetes_namespace" "frigate" {
|
|
metadata {
|
|
name = "frigate"
|
|
labels = {
|
|
tier = local.tiers.gpu
|
|
}
|
|
# labels = {
|
|
# "istio-injection" : "enabled"
|
|
# }
|
|
}
|
|
}
|
|
|
|
module "tls_secret" {
|
|
source = "../../modules/kubernetes/setup_tls_secret"
|
|
namespace = kubernetes_namespace.frigate.metadata[0].name
|
|
tls_secret_name = var.tls_secret_name
|
|
}
|
|
|
|
module "nfs_config" {
|
|
source = "../../modules/kubernetes/nfs_volume"
|
|
name = "frigate-config"
|
|
namespace = kubernetes_namespace.frigate.metadata[0].name
|
|
nfs_server = var.nfs_server
|
|
nfs_path = "/mnt/main/frigate/config"
|
|
}
|
|
|
|
module "nfs_media" {
|
|
source = "../../modules/kubernetes/nfs_volume"
|
|
name = "frigate-media"
|
|
namespace = kubernetes_namespace.frigate.metadata[0].name
|
|
nfs_server = var.nfs_server
|
|
nfs_path = "/mnt/main/frigate/media"
|
|
}
|
|
|
|
resource "kubernetes_deployment" "frigate" {
|
|
metadata {
|
|
name = "frigate"
|
|
namespace = kubernetes_namespace.frigate.metadata[0].name
|
|
labels = {
|
|
app = "frigate"
|
|
tier = local.tiers.gpu
|
|
}
|
|
annotations = {
|
|
"reloader.stakater.com/search" = "true"
|
|
}
|
|
}
|
|
spec {
|
|
replicas = 1 # Temporarily disabled due to high power consumption
|
|
strategy {
|
|
type = "Recreate"
|
|
}
|
|
selector {
|
|
match_labels = {
|
|
app = "frigate"
|
|
}
|
|
}
|
|
template {
|
|
metadata {
|
|
labels = {
|
|
app = "frigate"
|
|
}
|
|
}
|
|
spec {
|
|
node_selector = {
|
|
"gpu" : true
|
|
}
|
|
toleration {
|
|
key = "nvidia.com/gpu"
|
|
operator = "Equal"
|
|
value = "true"
|
|
effect = "NoSchedule"
|
|
}
|
|
container {
|
|
# image = "ghcr.io/blakeblackshear/frigate:stable"
|
|
# image = "ghcr.io/blakeblackshear/frigate:stable-tensorrt"
|
|
image = "ghcr.io/blakeblackshear/frigate:0.17.0-beta1-tensorrt"
|
|
name = "frigate"
|
|
|
|
resources {
|
|
requests = {
|
|
cpu = "500m"
|
|
memory = "2Gi"
|
|
}
|
|
limits = {
|
|
cpu = "4"
|
|
memory = "8Gi"
|
|
"nvidia.com/gpu" = "1"
|
|
}
|
|
}
|
|
env {
|
|
name = "FRIGATE_RTSP_PASSWORD"
|
|
value = "password"
|
|
}
|
|
port {
|
|
container_port = 5000
|
|
}
|
|
port {
|
|
container_port = 8554
|
|
}
|
|
port {
|
|
container_port = 8555
|
|
protocol = "TCP"
|
|
}
|
|
port {
|
|
container_port = 8555
|
|
protocol = "UDP"
|
|
}
|
|
volume_mount {
|
|
name = "config"
|
|
mount_path = "/config"
|
|
}
|
|
volume_mount {
|
|
name = "dri"
|
|
mount_path = "/dev/dri"
|
|
}
|
|
volume_mount {
|
|
name = "dshm"
|
|
mount_path = "/dev/shm"
|
|
}
|
|
volume_mount {
|
|
name = "media"
|
|
mount_path = "/media/frigate"
|
|
}
|
|
# Restart pod if GPU becomes unavailable or Frigate hangs
|
|
liveness_probe {
|
|
exec {
|
|
command = ["sh", "-c", "nvidia-smi > /dev/null 2>&1 && curl -sf http://localhost:5000/api/version > /dev/null"]
|
|
}
|
|
initial_delay_seconds = 120
|
|
period_seconds = 60
|
|
timeout_seconds = 10
|
|
failure_threshold = 3
|
|
}
|
|
# TensorRT model loading can take several minutes
|
|
startup_probe {
|
|
http_get {
|
|
path = "/api/version"
|
|
port = 5000
|
|
}
|
|
period_seconds = 10
|
|
failure_threshold = 30 # up to 5 minutes for startup
|
|
}
|
|
security_context {
|
|
privileged = true
|
|
}
|
|
}
|
|
|
|
volume {
|
|
name = "config"
|
|
persistent_volume_claim {
|
|
claim_name = module.nfs_config.claim_name
|
|
}
|
|
}
|
|
volume {
|
|
name = "dshm"
|
|
empty_dir {
|
|
medium = "Memory"
|
|
size_limit = "1Gi"
|
|
}
|
|
}
|
|
volume {
|
|
name = "media"
|
|
persistent_volume_claim {
|
|
claim_name = module.nfs_media.claim_name
|
|
}
|
|
}
|
|
volume {
|
|
name = "dri"
|
|
host_path {
|
|
path = "/dev/dri"
|
|
type = "Directory"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "kubernetes_service" "frigate" {
|
|
metadata {
|
|
name = "frigate"
|
|
namespace = kubernetes_namespace.frigate.metadata[0].name
|
|
labels = {
|
|
"app" = "frigate"
|
|
}
|
|
}
|
|
|
|
spec {
|
|
selector = {
|
|
app = "frigate"
|
|
}
|
|
port {
|
|
name = "http"
|
|
target_port = 5000
|
|
port = 80
|
|
protocol = "TCP"
|
|
}
|
|
}
|
|
}
|
|
|
|
resource "kubernetes_service" "frigate-rtsp" {
|
|
metadata {
|
|
name = "frigate-rtsp"
|
|
namespace = kubernetes_namespace.frigate.metadata[0].name
|
|
labels = {
|
|
"app" = "frigate"
|
|
}
|
|
}
|
|
|
|
spec {
|
|
type = "NodePort" # Should always live on node1 where the gpu is
|
|
selector = {
|
|
app = "frigate"
|
|
}
|
|
port {
|
|
name = "rtsp-tcp"
|
|
target_port = 8554
|
|
port = 8554
|
|
protocol = "TCP"
|
|
node_port = 30554
|
|
}
|
|
port {
|
|
name = "rtsp-udp"
|
|
target_port = 8554
|
|
port = 8554
|
|
protocol = "UDP"
|
|
node_port = 30554
|
|
}
|
|
}
|
|
}
|
|
|
|
module "ingress" {
|
|
source = "../../modules/kubernetes/ingress_factory"
|
|
namespace = kubernetes_namespace.frigate.metadata[0].name
|
|
name = "frigate"
|
|
tls_secret_name = var.tls_secret_name
|
|
protected = true
|
|
rybbit_site_id = "0d4044069ff5"
|
|
}
|
|
|
|
module "ingress-internal" {
|
|
source = "../../modules/kubernetes/ingress_factory"
|
|
namespace = kubernetes_namespace.frigate.metadata[0].name
|
|
name = "frigate-lan"
|
|
host = "frigate-lan"
|
|
root_domain = "viktorbarzin.lan"
|
|
service_name = "frigate"
|
|
tls_secret_name = var.tls_secret_name
|
|
allow_local_access_only = true
|
|
ssl_redirect = false
|
|
}
|