homek8s/apps/base/sirius-growth/networkpolicy-backup.yaml

49 lines
1.6 KiB
YAML
Raw Normal View History

# Egress lockdown for the nightly leadgen-backup CronJob (card t_9d0428d8).
#
# Why: the job used to `apk add --no-cache rsync openssh-client` at container
# start, so each run depended on the Alpine CDN (Fastly 151.101.x.132:443).
# rsync/ssh/bash (+kubectl, unused here) are baked into
# images/backup/Dockerfile now.
#
# `sirius-growth-allow` (networkpolicy.yaml) selects every pod in this
# namespace and allows `world` (Telegram Bot API, the leadgen crawlers), so a
# pod-scoped allow list alone would NOT restrict this job — Cilium unions
# policies. The `egressDeny` for `world` closes it for this pod only; the app
# pods keep their internet access.
#
# Allow list, and nothing else: cluster DNS, and [email protected]:22 (the Linode
# node's InternalIP — `remote-node`, not `world`) for the rsync mirror.
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: leadgen-backup-egress
namespace: sirius-growth
labels:
app: leadgen-backup
spec:
description: >-
leadgen-backup pod: cluster DNS + SSH to the backup host (10.10.0.5:22)
only; no internet egress at run time.
endpointSelector:
matchLabels:
app: leadgen-backup
egress:
- toEndpoints:
- matchLabels:
io.kubernetes.pod.namespace: kube-system
k8s-app: kube-dns
toPorts:
- ports:
- port: "53"
protocol: UDP
- port: "53"
protocol: TCP
- toEntities:
- remote-node
toPorts:
- ports:
- port: "22"
protocol: TCP
egressDeny:
- toEntities:
- world