Files
a13labs.infra/terraform/modules/apps/searxng/main.tf
T
alexandre.pires 829ab48919 feat: Add SearXNG module and update infrastructure
- Introduced a new SearXNG module with configuration for Kubernetes deployment, service, and ingress.
- Updated existing Terraform app modules to include SearXNG in both dev-01 and prod-01 environments.
- Added necessary variables and secrets for SearXNG in the respective Terraform files.
- Updated Dockerfiles for llama.cpp and ollama to use latest versions.
- Enhanced security and hardening defaults in Kubernetes deployments.
- Improved documentation for Copilot instructions and Terraform workflows.
2026-05-20 20:58:02 +02:00

192 lines
3.7 KiB
Terraform

resource "kubernetes_namespace" "searxng" {
metadata {
name = "searxng"
}
}
resource "kubernetes_service_account" "searxng" {
metadata {
name = "searxng-sa"
namespace = kubernetes_namespace.searxng.metadata[0].name
}
automount_service_account_token = false
}
resource "kubernetes_config_map" "searxng_config" {
metadata {
name = "searxng-config"
namespace = kubernetes_namespace.searxng.metadata[0].name
}
data = {
BASE_URL = "https://${local.app_fqdn}/"
GRANIAN_HOST = "0.0.0.0"
}
}
resource "kubernetes_secret" "searxng_secrets" {
metadata {
name = "searxng-keys"
namespace = kubernetes_namespace.searxng.metadata[0].name
}
data = {
SEARXNG_SECRET = var.secret_key
}
}
resource "kubernetes_deployment" "searxng" {
metadata {
name = "searxng"
namespace = kubernetes_namespace.searxng.metadata[0].name
labels = {
app = "searxng"
}
}
spec {
replicas = 1
selector {
match_labels = {
app = "searxng"
}
}
strategy {
type = "Recreate"
}
template {
metadata {
labels = {
app = "searxng"
}
}
spec {
service_account_name = kubernetes_service_account.searxng.metadata[0].name
automount_service_account_token = false
security_context {
run_as_non_root = true
run_as_user = 977
run_as_group = 977
fs_group = 977
seccomp_profile {
type = "RuntimeDefault"
}
}
container {
name = "searxng"
image = "searxng/searxng:${local.app_version}"
env_from {
config_map_ref {
name = kubernetes_config_map.searxng_config.metadata[0].name
}
}
env {
name = "SEARXNG_SECRET"
value_from {
secret_key_ref {
name = kubernetes_secret.searxng_secrets.metadata[0].name
key = "SEARXNG_SECRET"
}
}
}
security_context {
allow_privilege_escalation = false
privileged = false
capabilities {
drop = ["ALL"]
}
read_only_root_filesystem = true
}
port {
name = "http"
container_port = 8080
protocol = "TCP"
}
liveness_probe {
http_get {
path = "/"
port = "http"
}
initial_delay_seconds = 30
period_seconds = 15
}
readiness_probe {
http_get {
path = "/"
port = "http"
}
initial_delay_seconds = 10
period_seconds = 10
}
volume_mount {
name = "searxng-data"
mount_path = "/var/cache/searxng"
}
volume_mount {
name = "searxng-tmp"
mount_path = "/tmp"
}
}
volume {
name = "searxng-data"
host_path {
path = local.app_folder
}
}
volume {
name = "searxng-tmp"
empty_dir {}
}
}
}
}
}
resource "kubernetes_service" "searxng" {
metadata {
name = "searxng-service"
namespace = kubernetes_namespace.searxng.metadata[0].name
}
spec {
selector = {
app = "searxng"
}
port {
name = "http"
port = 8080
target_port = 8080
}
type = "ClusterIP"
}
lifecycle {
ignore_changes = [
metadata[0].annotations
]
}
}