69 lines
2.0 KiB
YAML
69 lines
2.0 KiB
YAML
{{- if .Values.networkPolicy.enabled }}
|
|
# NetworkPolicy mínima del shape: bajo deny-all-default del namespace, permite:
|
|
# - Ingress: rke2-ingress-nginx (web-backend público) + Prometheus (scrape de /metrics).
|
|
# - Egress: DNS, Harbor (pull en startup), ns-addons del tenant (BD).
|
|
# Nota: el cluster tenant usa rke2-ingress-nginx en kube-system, NO Traefik.
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: {{ .Release.Name }}
|
|
labels:
|
|
{{- include "app.labels" . | nindent 4 }}
|
|
spec:
|
|
podSelector:
|
|
matchLabels:
|
|
{{- include "app.selectorLabels" . | nindent 6 }}
|
|
policyTypes: [Ingress, Egress]
|
|
|
|
ingress:
|
|
# Tráfico HTTP desde rke2-ingress-nginx (Ingress estándar).
|
|
# El controller corre en kube-system por default en RKE2.
|
|
- from:
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
kubernetes.io/metadata.name: {{ .Values.networkPolicy.ingressControllerNamespace | default "kube-system" }}
|
|
ports:
|
|
- protocol: TCP
|
|
port: 8000
|
|
# Scrape de métricas Prometheus
|
|
- from:
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
kubernetes.io/metadata.name: cattle-monitoring-system
|
|
podSelector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: prometheus
|
|
ports:
|
|
- protocol: TCP
|
|
port: 8000
|
|
|
|
egress:
|
|
# DNS
|
|
- to:
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
kubernetes.io/metadata.name: kube-system
|
|
ports:
|
|
- protocol: UDP
|
|
port: 53
|
|
- protocol: TCP
|
|
port: 53
|
|
# ns-addons del tenant: MariaDB primary + pool
|
|
- to:
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
kubernetes.io/metadata.name: {{ .Values.networkPolicy.addonsNamespace }}
|
|
ports:
|
|
- protocol: TCP
|
|
port: 3306
|
|
- protocol: TCP
|
|
port: 6033
|
|
# Harbor pull (registro de imágenes)
|
|
- to:
|
|
- ipBlock:
|
|
cidr: 0.0.0.0/0
|
|
ports:
|
|
- protocol: TCP
|
|
port: 443
|
|
{{- end }}
|