diff --git a/adhoc-config/security-audit-cronjob.yaml b/adhoc-config/security-audit-cronjob.yaml new file mode 100755 index 0000000..6c6dc0c --- /dev/null +++ b/adhoc-config/security-audit-cronjob.yaml @@ -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