forked from innovacion/Mayacontigo
add healthcheck to remaining apps
This commit is contained in:
42
apps/voz-del-cliente/.k8s/deployment.yaml
Normal file
42
apps/voz-del-cliente/.k8s/deployment.yaml
Normal file
@@ -0,0 +1,42 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mayacontigo-voz-del-cliente
|
||||
namespace: apps
|
||||
labels:
|
||||
app: mayacontigo-voz-del-cliente
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mayacontigo-voz-del-cliente
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mayacontigo-voz-del-cliente
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: gitea-registry-cred
|
||||
containers:
|
||||
- name: mayacontigo-voz-del-cliente
|
||||
image: gitea.ia-innovacion.work/innovacion/mayacontigo-voz-del-cliente:latest
|
||||
env:
|
||||
- name: VAULT_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: mayacontigo-voz-del-cliente-secret
|
||||
key: VAULT_TOKEN
|
||||
ports:
|
||||
- containerPort: 80
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 80
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 80
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
19
apps/voz-del-cliente/.k8s/ingress.yaml
Normal file
19
apps/voz-del-cliente/.k8s/ingress.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: mayacontigo-voz-del-cliente-ingress
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
rules:
|
||||
- host: mayacontigo-voz-del-cliente.app.ia-innovacion.work
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: mayacontigo-voz-del-cliente-service
|
||||
port:
|
||||
number: 80
|
||||
17
apps/voz-del-cliente/.k8s/secrets.yaml
Normal file
17
apps/voz-del-cliente/.k8s/secrets.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
apiVersion: external-secrets.io/v1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: mayacontigo-voz-del-cliente-vault
|
||||
namespace: apps
|
||||
spec:
|
||||
refreshInterval: "15s"
|
||||
secretStoreRef:
|
||||
name: vault-backend
|
||||
kind: ClusterSecretStore
|
||||
target:
|
||||
name: mayacontigo-voz-del-cliente-secret
|
||||
data:
|
||||
- secretKey: VAULT_TOKEN
|
||||
remoteRef:
|
||||
key: mayacontigo-voz-del-cliente
|
||||
property: VAULT_TOKEN
|
||||
14
apps/voz-del-cliente/.k8s/service.yaml
Normal file
14
apps/voz-del-cliente/.k8s/service.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mayacontigo-voz-del-cliente-service
|
||||
labels:
|
||||
app: mayacontigo-voz-del-cliente
|
||||
spec:
|
||||
selector:
|
||||
app: mayacontigo-voz-del-cliente
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
type: ClusterIP
|
||||
@@ -1,9 +1,7 @@
|
||||
from hvac import Client
|
||||
from pydantic import Field
|
||||
from dotenv import load_dotenv
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
client = Client(url="https://vault.ia-innovacion.work")
|
||||
|
||||
if not client.is_authenticated():
|
||||
@@ -14,6 +12,7 @@ secret_map = client.secrets.kv.v2.read_secret_version(
|
||||
)["data"]["data"]
|
||||
|
||||
class Settings(BaseSettings):
|
||||
|
||||
"""
|
||||
Esta clase obtiene sus valores de variables de ambiente.
|
||||
Si no estan en el ambiente, los jala de nuestra Vault.
|
||||
@@ -39,11 +38,10 @@ class Settings(BaseSettings):
|
||||
async def init_mongo_db(self):
|
||||
"""Este helper inicia la conexion enter el MongoDB ORM y nuestra instancia"""
|
||||
|
||||
from banortegpt.database.mongo_memory.models import Conversation
|
||||
from beanie import init_beanie
|
||||
from motor.motor_asyncio import AsyncIOMotorClient
|
||||
|
||||
from banortegpt.database.mongo_memory.models import Conversation
|
||||
|
||||
await init_beanie(
|
||||
database=AsyncIOMotorClient(self.mongodb_url).voz_del_cliente,
|
||||
document_models=[Conversation],
|
||||
|
||||
@@ -35,16 +35,24 @@ class Message(BaseModel):
|
||||
|
||||
@app.post("/api/v1/message")
|
||||
async def send(message: Message):
|
||||
|
||||
def b64_sse(func):
|
||||
"""Este helper transforma un generador de strings a un generador del protocolo SSE"""
|
||||
|
||||
async def wrapper(*args, **kwargs):
|
||||
async for chunk in func(*args, **kwargs):
|
||||
content = chunk.model_dump_json()
|
||||
data = f"data: {content}\n\n"
|
||||
yield data
|
||||
|
||||
return wrapper
|
||||
|
||||
sse_stream = b64_sse(services.stream)
|
||||
generator = sse_stream(agent, message.prompt, message.conversation_id, message.with_deep_research)
|
||||
generator = sse_stream(
|
||||
agent, message.prompt, message.conversation_id, message.with_deep_research
|
||||
)
|
||||
return StreamingResponse(generator, media_type="text/event-stream")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def health():
|
||||
return {"app": "Voz del Cliente", "status": "OK"}
|
||||
|
||||
Reference in New Issue
Block a user