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.
This commit is contained in:
2026-05-20 20:58:02 +02:00
parent dcf9a5c796
commit 829ab48919
24 changed files with 918 additions and 11 deletions
@@ -11,7 +11,7 @@ variable "fqdn" {
variable "tag" {
description = "The version of app to install"
type = string
default = "main"
default = "v0.8.12"
}
variable "issuer" {
@@ -32,7 +32,6 @@ variable "ollama_proxy" {
default = {
enabled = false
}
}
variable "secret_key" {
+6
View File
@@ -0,0 +1,6 @@
locals {
app_folder = var.persistent_folder
app_version = var.tag
app_fqdn = var.fqdn
}
+39
View File
@@ -0,0 +1,39 @@
resource "kubernetes_ingress_v1" "searxng" {
metadata {
name = "ingress"
namespace = kubernetes_namespace.searxng.metadata[0].name
annotations = {
"kubernetes.io/ingress.class" = "public"
"cert-manager.io/cluster-issuer" = var.issuer
"kubernetes.io/tls-acme" = "true"
"nginx.ingress.kubernetes.io/ssl-redirect" = "true"
}
}
spec {
dynamic "tls" {
for_each = var.tls_enabled ? [1] : []
content {
hosts = [var.fqdn]
secret_name = "searxng-tls"
}
}
rule {
host = var.fqdn
http {
path {
backend {
service {
name = kubernetes_service.searxng.metadata[0].name
port {
number = 8080
}
}
}
}
}
}
}
}
+191
View File
@@ -0,0 +1,191 @@
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
]
}
}
@@ -0,0 +1,9 @@
terraform {
required_version = "~>1.8"
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.36.0"
}
}
}
@@ -0,0 +1,33 @@
variable "persistent_folder" {
description = "The path to the persistent folder"
type = string
}
variable "fqdn" {
description = "FQDN name of the service"
type = string
}
variable "tag" {
description = "The version of searxng to install"
type = string
default = "latest"
}
variable "issuer" {
description = "The cert-manager cluster issuer"
type = string
default = "letsencrypt-prod"
}
variable "tls_enabled" {
description = "Enable TLS in ingress"
type = bool
default = true
}
variable "secret_key" {
description = "Secret key for SearXNG"
type = string
sensitive = true
}