60 lines
1.8 KiB
YAML
60 lines
1.8 KiB
YAML
{{- if .Values.networkPolicy.enabled }}
|
|
# NetworkPolicy mínima del shape rest-api: bajo deny-all-default del namespace, permite:
|
|
# - Ingress: rke2-ingress-nginx (público) + Prometheus (scrape de /metrics).
|
|
# - Egress: DNS, Harbor pull HTTPS.
|
|
# Sin acceso a ns-addons (rest-api no tiene BD por diseño).
|
|
# 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
|
|
# Harbor pull (registro de imágenes) — HTTPS abierto
|
|
- to:
|
|
- ipBlock:
|
|
cidr: 0.0.0.0/0
|
|
ports:
|
|
- protocol: TCP
|
|
port: 443
|
|
{{- end }}
|