Refactor Gitea and SSH configurations, update backup scripts, and enhance Nginx settings
- Updated SSH configuration for Gitea to disable banner and TTY, and modified the AuthorizedKeysCommand. - Simplified gitea-shell script to directly call the k8s_gitea_shell command with required parameters. - Removed unused gitea-auth script from playbook_gitea.yml. - Updated systools_version in playbook_systools.yml to 0.4.5. - Enhanced ssh_locker_helper to copy redirect URL to clipboard based on OS. - Added a new script test_imaps for IMAP testing. - Updated Terraform configurations for various applications, including: - Added a backup script for MariaDB with retention policy. - Changed Gitea version to 1.24-rootless and adjusted SSH settings. - Updated Nginx configurations to log errors and access to stderr/stdout. - Refactored services to use ClusterIP type and adjusted security contexts for deployments. - Added temporary storage for applications using empty_dir. - Enhanced backup.sh scripts for better error handling and logging.
This commit is contained in:
@@ -41,6 +41,16 @@ resource "kubernetes_config_map" "ssl_config" {
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_config_map" "backup_script" {
|
||||
metadata {
|
||||
name = "${var.app_name}-sql-backup-script"
|
||||
namespace = var.namespace
|
||||
}
|
||||
data = {
|
||||
"backup.sh" = file("${path.module}/resources/backup.sh")
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_service_account" "service_account" {
|
||||
|
||||
metadata {
|
||||
@@ -239,7 +249,6 @@ resource "kubernetes_deployment" "deployment" {
|
||||
}
|
||||
}
|
||||
|
||||
# TODO: This should move out of here
|
||||
resource "kubernetes_cron_job_v1" "backup_data_cron" {
|
||||
metadata {
|
||||
name = "mariadb-backup-job"
|
||||
@@ -289,25 +298,50 @@ resource "kubernetes_cron_job_v1" "backup_data_cron" {
|
||||
name = "MARIADB_DATABASE"
|
||||
value = var.app_name
|
||||
}
|
||||
env {
|
||||
name = "APP_NAME"
|
||||
value = var.app_name
|
||||
}
|
||||
env {
|
||||
name = "BACKUP_RETENTION"
|
||||
value = var.retention_days
|
||||
}
|
||||
security_context {
|
||||
allow_privilege_escalation = false
|
||||
}
|
||||
command = ["/bin/sh", "-c"]
|
||||
args = [join(";", [
|
||||
"/usr/bin/mariadb-dump --single-transaction -h mariadb -u $MARIADB_USER -p$MARIADB_PASSWORD $MARIADB_DATABASE | gzip > /backups/${var.app_name}-sql-`date +\"%Y%m%d\"`.sql.gz",
|
||||
"find /backups -type f -name '${var.app_name}-sql-*.sql.gz' -mtime +${var.retention_days} | xargs --no-run-if-empty rm"
|
||||
])]
|
||||
args = ["/tmp/scripts/backup.sh"]
|
||||
volume_mount {
|
||||
mount_path = "/backups"
|
||||
name = "backups-storage"
|
||||
mount_path = "/backup"
|
||||
name = "backup-storage"
|
||||
}
|
||||
volume_mount {
|
||||
name = "backup-script"
|
||||
mount_path = "/tmp/scripts"
|
||||
read_only = true
|
||||
}
|
||||
volume_mount {
|
||||
name = "tmp"
|
||||
mount_path = "/tmp"
|
||||
}
|
||||
}
|
||||
volume {
|
||||
name = "backups-storage"
|
||||
name = "backup-storage"
|
||||
host_path {
|
||||
path = var.backup_folder
|
||||
}
|
||||
}
|
||||
volume {
|
||||
name = "backup-script"
|
||||
config_map {
|
||||
name = kubernetes_config_map.backup_script.metadata[0].name
|
||||
default_mode = "0755"
|
||||
}
|
||||
}
|
||||
volume {
|
||||
name = "tmp"
|
||||
empty_dir {}
|
||||
}
|
||||
restart_policy = "Never"
|
||||
termination_grace_period_seconds = 30
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user