add: cronjob for weekly security audit (Sat 7:50 AM)

This commit is contained in:
Junv (via Hermes)
2026-06-13 15:20:38 +10:00
parent e6f3892b02
commit e99ec79ae5
+50
View File
@@ -0,0 +1,50 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: security-audit
namespace: default
spec:
schedule: "50 7 * * 6" # Saturday 7:50 AM
jobTemplate:
spec:
template:
spec:
containers:
- name: audit
image: bash:5.2
command: ["/bin/bash"]
args:
- "-c"
- |
set -euo pipefail
mkdir -p /audit-reports
OUTPUT="/audit-reports/security-audit-$(date +%Y-%m-%d).log"
echo "=== Security Audit Report ===" > "$OUTPUT"
echo "Date: $(date '+%Y-%m-%d %H:%M:%S %Z')" >> "$OUTPUT"
echo "" >> "$OUTPUT"
# Run the audit script against localhost
bash /scripts/security-audit-192.168.1.2.sh >> "$OUTPUT" 2>&1
echo "" >> "$OUTPUT"
echo "=== Audit Complete ===" >> "$OUTPUT"
volumeMounts:
- mountPath: /scripts
name: scripts
- mountPath: /audit-reports
name: audit-reports
restartPolicy: OnFailure
# Run on the main K3s server node
nodeSelector:
kubernetes.io/hostname: server-3
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
volumes:
- name: scripts
hostPath:
path: /home/junv/code/home-docker/scripts
type: Directory
- name: audit-reports
hostPath:
path: /var/log/security-audit
type: DirectoryOrCreate