mirror of
https://github.com/wahyd4/home-docker.git
synced 2026-08-09 04:15:52 +10:00
add: cronjob for weekly security audit (Sat 7:50 AM)
This commit is contained in:
Executable
+50
@@ -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
|
||||
Reference in New Issue
Block a user