feat(assistente): gateway do LLM e netpols (22/10/2026)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
# Gateway do assistente de IA (21/10/2026): saida do BFF (pod frontend-spa) para o gateway na plataforma. NAO APLICADO ainda.
|
||||
# Par da 28-netpol-tenants-no-llm da plataforma.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: egress-llm
|
||||
namespace: acme-prod
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels: { app: frontend-spa }
|
||||
policyTypes: [Egress]
|
||||
egress:
|
||||
- to:
|
||||
- namespaceSelector:
|
||||
matchLabels: { kubernetes.io/metadata.name: plataforma-prod }
|
||||
podSelector:
|
||||
matchLabels: { app: llm-gateway }
|
||||
ports:
|
||||
- { protocol: TCP, port: 8092 }
|
||||
@@ -0,0 +1,19 @@
|
||||
# Gateway do assistente de IA (21/10/2026): saida do BFF (pod frontend-spa) para o gateway na plataforma. NAO APLICADO ainda.
|
||||
# Par da 28-netpol-tenants-no-llm da plataforma.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: egress-llm
|
||||
namespace: demo-prod
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels: { app: frontend-spa }
|
||||
policyTypes: [Egress]
|
||||
egress:
|
||||
- to:
|
||||
- namespaceSelector:
|
||||
matchLabels: { kubernetes.io/metadata.name: plataforma-prod }
|
||||
podSelector:
|
||||
matchLabels: { app: llm-gateway }
|
||||
ports:
|
||||
- { protocol: TCP, port: 8092 }
|
||||
@@ -0,0 +1,19 @@
|
||||
# Gateway do assistente de IA (21/10/2026): saida do BFF (pod frontend-spa) para o gateway na plataforma. NAO APLICADO ainda.
|
||||
# Par da 28-netpol-tenants-no-llm da plataforma.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: egress-llm
|
||||
namespace: escolinha-prod
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels: { app: frontend-spa }
|
||||
policyTypes: [Egress]
|
||||
egress:
|
||||
- to:
|
||||
- namespaceSelector:
|
||||
matchLabels: { kubernetes.io/metadata.name: plataforma-prod }
|
||||
podSelector:
|
||||
matchLabels: { app: llm-gateway }
|
||||
ports:
|
||||
- { protocol: TCP, port: 8092 }
|
||||
@@ -0,0 +1,19 @@
|
||||
# Gateway do assistente de IA (21/10/2026): saida do BFF (pod frontend-spa) para o gateway na plataforma. NAO APLICADO ainda.
|
||||
# Par da 28-netpol-tenants-no-llm da plataforma.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: egress-llm
|
||||
namespace: piloto-prod
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels: { app: frontend-spa }
|
||||
policyTypes: [Egress]
|
||||
egress:
|
||||
- to:
|
||||
- namespaceSelector:
|
||||
matchLabels: { kubernetes.io/metadata.name: plataforma-prod }
|
||||
podSelector:
|
||||
matchLabels: { app: llm-gateway }
|
||||
ports:
|
||||
- { protocol: TCP, port: 8092 }
|
||||
@@ -0,0 +1,73 @@
|
||||
# Gateway do assistente de IA (21/10/2026) — NAO APLICADO ainda (falta o tunel do servidor de IA; ver docs/assistente-ia-desenho-fase-2.md).
|
||||
# O LLM (Ollama) roda no servidor de IA da LAN (192.168.15.16, "InfluxIA"), que so se alcanca por TUNEL SSH REVERSO:
|
||||
# o servidor abre uma conexao de SAIDA para esta VPS e expoe o Ollama em 10.42.0.1:11436 (IP do cni0; nunca em 0.0.0.0).
|
||||
# Os pods nao chegam ao loopback do host, e o Ollama nao tem autenticacao nem restricao de API (pull/delete de modelo!):
|
||||
# por isso este nginx, que so repassa as 3 rotas de que o assistente precisa, com limite de taxa e corpo pequeno.
|
||||
# Um so para todos os tenants (como o servico-voz). SEM Ingress: a protecao e a rede (28-netpol-tenants-no-llm).
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: llm-gateway-nginx
|
||||
namespace: plataforma-prod
|
||||
data:
|
||||
default.conf: |
|
||||
limit_req_zone $binary_remote_addr zone=llm:1m rate=30r/m;
|
||||
server {
|
||||
listen 8092;
|
||||
client_max_body_size 64k;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_buffering off; # streaming (NDJSON) chega aos poucos
|
||||
proxy_read_timeout 180s;
|
||||
proxy_connect_timeout 3s;
|
||||
location = /saude { access_log off; default_type text/plain; return 200 "ok"; }
|
||||
location = /api/tags { limit_req zone=llm burst=10 nodelay; proxy_pass http://10.42.0.1:11436; }
|
||||
location = /api/chat { limit_req zone=llm burst=10 nodelay; proxy_pass http://10.42.0.1:11436; }
|
||||
location = /api/embed { limit_req zone=llm burst=10 nodelay; proxy_pass http://10.42.0.1:11436; }
|
||||
location / { return 404; } # nada de /api/pull, /api/delete, /api/generate, /api/create...
|
||||
}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: llm-gateway
|
||||
namespace: plataforma-prod
|
||||
labels: { app: llm-gateway }
|
||||
spec:
|
||||
replicas: 1
|
||||
selector: { matchLabels: { app: llm-gateway } }
|
||||
template:
|
||||
metadata:
|
||||
labels: { app: llm-gateway }
|
||||
spec:
|
||||
securityContext: { runAsNonRoot: true, runAsUser: 101 }
|
||||
containers:
|
||||
- name: nginx
|
||||
image: docker.io/nginxinc/nginx-unprivileged:1.27-alpine
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports: [{ containerPort: 8092 }]
|
||||
volumeMounts:
|
||||
- { name: conf, mountPath: /etc/nginx/conf.d/default.conf, subPath: default.conf }
|
||||
resources:
|
||||
requests: { cpu: 20m, memory: 32Mi }
|
||||
limits: { cpu: 200m, memory: 96Mi }
|
||||
readinessProbe:
|
||||
httpGet: { path: /saude, port: 8092 }
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
httpGet: { path: /saude, port: 8092 }
|
||||
periodSeconds: 30
|
||||
volumes:
|
||||
- name: conf
|
||||
configMap: { name: llm-gateway-nginx }
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: llm-gateway
|
||||
namespace: plataforma-prod
|
||||
labels: { app: llm-gateway }
|
||||
spec:
|
||||
selector: { app: llm-gateway }
|
||||
ports: [{ name: http, port: 8092, targetPort: 8092 }]
|
||||
@@ -0,0 +1,31 @@
|
||||
# Gateway do assistente de IA (21/10/2026): so o BFF dos tenants (pod frontend-spa) chega a porta 8092, e o gateway so
|
||||
# sai para o tunel do servidor de IA (10.42.0.1:11436). Mesmo padrao do 24-netpol-tenants-na-voz. NAO APLICADO ainda.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: tenants-no-llm
|
||||
namespace: plataforma-prod
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels: { app: llm-gateway }
|
||||
policyTypes: [Ingress, Egress]
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchExpressions:
|
||||
- { key: athleticmap.io/tenant, operator: Exists }
|
||||
- namespaceSelector:
|
||||
matchLabels: { kubernetes.io/metadata.name: piloto-prod }
|
||||
- namespaceSelector:
|
||||
matchLabels: { kubernetes.io/metadata.name: demo-prod }
|
||||
- namespaceSelector:
|
||||
matchLabels: { kubernetes.io/metadata.name: acme-prod }
|
||||
- namespaceSelector:
|
||||
matchLabels: { kubernetes.io/metadata.name: escolinha-prod }
|
||||
ports:
|
||||
- { protocol: TCP, port: 8092 }
|
||||
egress:
|
||||
- to:
|
||||
- ipBlock: { cidr: 10.42.0.1/32 }
|
||||
ports:
|
||||
- { protocol: TCP, port: 11436 }
|
||||
Reference in New Issue
Block a user