mirror of
https://gitlab.kube.huskypup.net/Scooby/Homelabv4.git
synced 2026-08-21 05:26:49 +00:00
Fix DDNS/failover Cloudflare zone name and add restricted PSS securityContext
- ZONE_NAME was "kube.huskypup.net" in both the home-ip-ddns CronJob and the VPS failover watcher - that's a record, not a Cloudflare zone (the actual zone is the parent "huskypup.net"). Caused home-ip-ddns to fail every run (zone lookup returned zero results, curl -f exit 22) - confirmed live and fixed. - Added seccompProfile/non-root/dropped-capabilities securityContext to the three CronJobs added this session that were missing it (flagged by the cluster's "restricted" PodSecurity admission). Repointed the raft snapshot job's mc binary install from /usr/local/bin to /tmp so it still works running as non-root.
This commit is contained in:
@@ -60,6 +60,11 @@ spec:
|
|||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
|
securityContext:
|
||||||
|
runAsNonRoot: true
|
||||||
|
runAsUser: 65534
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
affinity:
|
affinity:
|
||||||
podAffinity:
|
podAffinity:
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
@@ -70,6 +75,10 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: restic-backup
|
- name: restic-backup
|
||||||
image: restic/restic:0.16.4
|
image: restic/restic:0.16.4
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
capabilities:
|
||||||
|
drop: ["ALL"]
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/sh
|
||||||
- -c
|
- -c
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ data:
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
ZONE_NAME="kube.huskypup.net"
|
ZONE_NAME="huskypup.net" # Cloudflare zone is the parent domain - kube.huskypup.net is just a record within it, not its own zone
|
||||||
RECORD_NAME="home.kube.huskypup.net"
|
RECORD_NAME="home.kube.huskypup.net"
|
||||||
TOKEN="$(cat /etc/cf/cloudflare-token)"
|
TOKEN="$(cat /etc/cf/cloudflare-token)"
|
||||||
|
|
||||||
@@ -75,6 +75,8 @@ spec:
|
|||||||
securityContext:
|
securityContext:
|
||||||
runAsNonRoot: true
|
runAsNonRoot: true
|
||||||
runAsUser: 65534
|
runAsUser: 65534
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
containers:
|
containers:
|
||||||
- name: ddns-update
|
- name: ddns-update
|
||||||
image: alpine/k8s:1.32.13 # already has curl + jq (see MEMORY.md kubectl image note)
|
image: alpine/k8s:1.32.13 # already has curl + jq (see MEMORY.md kubectl image note)
|
||||||
|
|||||||
@@ -60,17 +60,18 @@ data:
|
|||||||
kubectl -n vault exec vault-0 -- rm -f "/tmp/${SNAP_NAME}"
|
kubectl -n vault exec vault-0 -- rm -f "/tmp/${SNAP_NAME}"
|
||||||
|
|
||||||
echo "==> Installing mc (MinIO client)..."
|
echo "==> Installing mc (MinIO client)..."
|
||||||
curl -sf https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc
|
curl -sf https://dl.min.io/client/mc/release/linux-amd64/mc -o /tmp/mc
|
||||||
chmod +x /usr/local/bin/mc
|
chmod +x /tmp/mc
|
||||||
mc alias set vps-minio "http://${VPS_MINIO_ENDPOINT}" \
|
export MC_CONFIG_DIR=/tmp/.mc
|
||||||
|
/tmp/mc alias set vps-minio "http://${VPS_MINIO_ENDPOINT}" \
|
||||||
"${MINIO_ACCESS_KEY}" "${MINIO_SECRET_KEY}" >/dev/null
|
"${MINIO_ACCESS_KEY}" "${MINIO_SECRET_KEY}" >/dev/null
|
||||||
|
|
||||||
echo "==> Uploading ${SNAP_NAME} to vps-minio/${BUCKET}..."
|
echo "==> Uploading ${SNAP_NAME} to vps-minio/${BUCKET}..."
|
||||||
mc cp "/tmp/${SNAP_NAME}" "vps-minio/${BUCKET}/${SNAP_NAME}"
|
/tmp/mc cp "/tmp/${SNAP_NAME}" "vps-minio/${BUCKET}/${SNAP_NAME}"
|
||||||
rm -f "/tmp/${SNAP_NAME}"
|
rm -f "/tmp/${SNAP_NAME}"
|
||||||
|
|
||||||
echo "==> Pruning snapshots older than 30 days..."
|
echo "==> Pruning snapshots older than 30 days..."
|
||||||
mc find "vps-minio/${BUCKET}" --older-than 30d --exec "mc rm {}" || true
|
/tmp/mc find "vps-minio/${BUCKET}" --older-than 30d --exec "/tmp/mc rm {}" || true
|
||||||
|
|
||||||
echo "==> Done: ${SNAP_NAME}"
|
echo "==> Done: ${SNAP_NAME}"
|
||||||
---
|
---
|
||||||
@@ -91,10 +92,19 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
serviceAccountName: argocd-hook-sa # already has kubectl exec rights in this namespace (see vault-init-job.yaml)
|
serviceAccountName: argocd-hook-sa # already has kubectl exec rights in this namespace (see vault-init-job.yaml)
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
|
securityContext:
|
||||||
|
runAsNonRoot: true
|
||||||
|
runAsUser: 65534
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
containers:
|
containers:
|
||||||
- name: raft-snapshot
|
- name: raft-snapshot
|
||||||
image: alpine/k8s:1.32.13
|
image: alpine/k8s:1.32.13
|
||||||
command: ["/bin/bash", "/scripts/snapshot.sh"]
|
command: ["/bin/bash", "/scripts/snapshot.sh"]
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
capabilities:
|
||||||
|
drop: ["ALL"]
|
||||||
env:
|
env:
|
||||||
- name: MINIO_ACCESS_KEY
|
- name: MINIO_ACCESS_KEY
|
||||||
valueFrom:
|
valueFrom:
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
TOKEN_FILE="/etc/vps-dns-failover/cloudflare-token"
|
TOKEN_FILE="/etc/vps-dns-failover/cloudflare-token"
|
||||||
STATE_DIR="/var/lib/vps-dns-failover"
|
STATE_DIR="/var/lib/vps-dns-failover"
|
||||||
ZONE_NAME="kube.huskypup.net"
|
ZONE_NAME="huskypup.net" # Cloudflare zone is the parent domain - kube.huskypup.net is just a record within it, not its own zone
|
||||||
HOME_CHECK_HOST="home.kube.huskypup.net"
|
HOME_CHECK_HOST="home.kube.huskypup.net"
|
||||||
HOME_CHECK_PORT=443
|
HOME_CHECK_PORT=443
|
||||||
FAILURE_THRESHOLD=3 # consecutive failed checks before flipping to the VPS
|
FAILURE_THRESHOLD=3 # consecutive failed checks before flipping to the VPS
|
||||||
|
|||||||
Reference in New Issue
Block a user