mirror of
https://github.com/hoshikawa2/deploy_langfuse_oci.git
synced 2026-07-09 17:14:22 +00:00
clean-up e persistencia na nuvem
This commit is contained in:
BIN
src/langfuse-k8s-cleanup.zip
Normal file
BIN
src/langfuse-k8s-cleanup.zip
Normal file
Binary file not shown.
442
src/langfuse_dist_cloud.yaml
Normal file
442
src/langfuse_dist_cloud.yaml
Normal file
@@ -0,0 +1,442 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: langfuse-external-services
|
||||
namespace: ${K8S_NAMESPACE}
|
||||
type: Opaque
|
||||
stringData:
|
||||
# PostgreSQL OCI
|
||||
DATABASE_URL: "postgresql://langfuse:${DB_PASSWORD}@10.0.10.15:5432/langfuse"
|
||||
# Redis OCI
|
||||
REDIS_HOST: "10.0.20.10"
|
||||
REDIS_PORT: "6379"
|
||||
REDIS_AUTH: "${REDIS_AUTH}"
|
||||
# ClickHouse
|
||||
CLICKHOUSE_PASSWORD: "${CLICKHOUSE_PASSWORD}"
|
||||
# Langfuse
|
||||
NEXTAUTH_SECRET: "${NEXTAUTH_SECRET}"
|
||||
SALT: "${SALT}"
|
||||
ENCRYPTION_KEY: "${ENCRYPTION_KEY}"
|
||||
# OCI Object Storage
|
||||
S3_ACCESS_KEY: "${S3_ACCESS_KEY}"
|
||||
S3_SECRET_KEY: "${S3_SECRET_KEY}"
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: ${APP_NAME}-clickhouse
|
||||
namespace: ${K8S_NAMESPACE}
|
||||
spec:
|
||||
serviceName: ${APP_NAME}-clickhouse
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ${APP_NAME}-clickhouse
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ${APP_NAME}-clickhouse
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: ocirsecret
|
||||
containers:
|
||||
- name: clickhouse
|
||||
image: ${IMAGE_REPOSITORY}/clickhouse:${CLICKHOUSE_TAG}
|
||||
ports:
|
||||
- containerPort: 8123
|
||||
- containerPort: 9000
|
||||
resources:
|
||||
requests:
|
||||
cpu: "2"
|
||||
memory: "8Gi"
|
||||
limits:
|
||||
cpu: "4"
|
||||
memory: "16Gi"
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /var/lib/clickhouse
|
||||
env:
|
||||
- name: CLICKHOUSE_DB
|
||||
value: "default"
|
||||
- name: CLICKHOUSE_USER
|
||||
value: "default"
|
||||
- name: CLICKHOUSE_PASSWORD
|
||||
value: "${CLICKHOUSE_PASSWORD}"
|
||||
- name: CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT
|
||||
value: "1"
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
storageClassName: oci-bv-high-performance
|
||||
resources:
|
||||
requests:
|
||||
storage: 200Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: ${APP_NAME}-clickhouse
|
||||
namespace: ${K8S_NAMESPACE}
|
||||
spec:
|
||||
selector:
|
||||
app: ${APP_NAME}-clickhouse
|
||||
ports:
|
||||
- name: http
|
||||
port: 8123
|
||||
- name: native
|
||||
port: 9000
|
||||
---
|
||||
# ===== LANGFUSE APPLICATION =====
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ${APP_NAME}
|
||||
namespace: ${K8S_NAMESPACE}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ${APP_NAME}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ${APP_NAME}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: ocirsecret
|
||||
|
||||
initContainers:
|
||||
|
||||
- name: wait-for-postgres
|
||||
image: busybox
|
||||
env:
|
||||
|
||||
- name: DB_HOST
|
||||
|
||||
value: "10.0.10.15"
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
until nc -z $DB_HOST 5432; do
|
||||
echo "⏳ Waiting for PostgreSQL..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
- name: wait-for-redis
|
||||
image: busybox
|
||||
env:
|
||||
- name: REDIS_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: langfuse-external-services
|
||||
key: REDIS_HOST
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
until nc -z $REDIS_HOST 6379; do
|
||||
echo "⏳ Waiting for Redis..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
- name: wait-for-clickhouse
|
||||
image: busybox
|
||||
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
until nc -z ${APP_NAME}-clickhouse 9000; do
|
||||
echo "⏳ Waiting for ClickHouse..."
|
||||
sleep 2
|
||||
done
|
||||
containers:
|
||||
- name: ${APP_NAME}
|
||||
image: ${IMAGE_REPOSITORY}/langfuse:${LANGFUSE_TAG}
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
env:
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: langfuse-external-services
|
||||
key: DATABASE_URL
|
||||
|
||||
- name: NEXTAUTH_SECRET
|
||||
value: "${NEXTAUTH_SECRET}"
|
||||
- name: SALT
|
||||
value: "${SALT}"
|
||||
- name: ENCRYPTION_KEY
|
||||
value: "${ENCRYPTION_KEY}"
|
||||
- name: NEXTAUTH_URL
|
||||
value: ${NEXTAUTH_URL}
|
||||
- name: TELEMETRY_ENABLED
|
||||
value: "false"
|
||||
- name: CLICKHOUSE_URL
|
||||
value: "http://${APP_NAME}-clickhouse:8123"
|
||||
- name: CLICKHOUSE_USER
|
||||
value: "default"
|
||||
- name: CLICKHOUSE_PASSWORD
|
||||
value: "${CLICKHOUSE_PASSWORD}"
|
||||
- name: CLICKHOUSE_CLUSTER_ENABLED
|
||||
value: "false"
|
||||
- name: CLICKHOUSE_MIGRATION_URL
|
||||
value: "clickhouse://${APP_NAME}-clickhouse:9000"
|
||||
|
||||
- name: REDIS_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: langfuse-external-services
|
||||
key: REDIS_HOST
|
||||
|
||||
- name: REDIS_AUTH
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: langfuse-external-services
|
||||
key: REDIS_AUTH
|
||||
|
||||
# ===== OCI OBJECT STORAGE (EVENTS) =====
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_BUCKET
|
||||
value: "langfuse-events"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_PREFIX
|
||||
value: "events/"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_REGION
|
||||
value: "${OCI_REGION}"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_ENDPOINT
|
||||
value: "https://${OCI_NAMESPACE}.compat.objectstorage.${OCI_REGION}.oraclecloud.com"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID
|
||||
value: "${S3_ACCESS_KEY}"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY
|
||||
value: "${S3_SECRET_KEY}"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE
|
||||
value: "true"
|
||||
resources:
|
||||
requests:
|
||||
cpu: "50m"
|
||||
memory: "2Gi"
|
||||
limits:
|
||||
cpu: "512m"
|
||||
memory: "3Gi"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /api/public/health
|
||||
port: 3000
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 15
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/public/health
|
||||
port: 3000
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 10
|
||||
|
||||
---
|
||||
# ===== LANGFUSE WORKER =====
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ${APP_NAME}-worker
|
||||
namespace: ${K8S_NAMESPACE}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ${APP_NAME}-worker
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ${APP_NAME}-worker
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: ocirsecret
|
||||
|
||||
initContainers:
|
||||
|
||||
- name: wait-for-postgres
|
||||
image: busybox
|
||||
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
until nc -z $DB_HOST 5432; do
|
||||
echo "⏳ Waiting for PostgreSQL..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
- name: wait-for-redis
|
||||
image: busybox
|
||||
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
until nc -z $REDIS_HOST 6379; do
|
||||
echo "⏳ Waiting for Redis..."
|
||||
sleep 2
|
||||
done
|
||||
|
||||
- name: wait-for-clickhouse
|
||||
image: busybox
|
||||
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
until nc -z ${APP_NAME}-clickhouse 9000; do
|
||||
echo "⏳ Waiting for ClickHouse..."
|
||||
sleep 2
|
||||
done
|
||||
containers:
|
||||
- name: worker
|
||||
image: ${IMAGE_REPOSITORY}/langfuse-worker:${LANGFUSE_WORKER_TAG}
|
||||
env:
|
||||
- name: DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: langfuse-external-services
|
||||
key: DATABASE_URL
|
||||
- name: ENCRYPTION_KEY
|
||||
value: "${ENCRYPTION_KEY}"
|
||||
- name: CLICKHOUSE_URL
|
||||
value: "http://${APP_NAME}-clickhouse:8123"
|
||||
- name: CLICKHOUSE_USER
|
||||
value: "default"
|
||||
- name: CLICKHOUSE_PASSWORD
|
||||
value: "${CLICKHOUSE_PASSWORD}"
|
||||
- name: CLICKHOUSE_CLUSTER_ENABLED
|
||||
value: "false"
|
||||
- name: CLICKHOUSE_MIGRATION_URL
|
||||
value: "clickhouse://${APP_NAME}-clickhouse:9000"
|
||||
|
||||
- name: REDIS_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: langfuse-external-services
|
||||
key: REDIS_HOST
|
||||
|
||||
- name: REDIS_PORT
|
||||
value: "6379"
|
||||
|
||||
- name: REDIS_AUTH
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: langfuse-external-services
|
||||
key: REDIS_AUTH
|
||||
|
||||
# ===== OCI OBJECT STORAGE (EVENTS) =====
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_BUCKET
|
||||
value: "langfuse-events"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_PREFIX
|
||||
value: "events/"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_REGION
|
||||
value: "${OCI_REGION}"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_ENDPOINT
|
||||
value: "https://${OCI_NAMESPACE}.compat.objectstorage.${OCI_REGION}.oraclecloud.com"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID
|
||||
value: "${S3_ACCESS_KEY}"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY
|
||||
value: "${S3_SECRET_KEY}"
|
||||
|
||||
- name: LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE
|
||||
value: "true"
|
||||
resources:
|
||||
requests:
|
||||
cpu: "50m"
|
||||
memory: "2Gi"
|
||||
limits:
|
||||
cpu: "512m"
|
||||
memory: "3Gi"
|
||||
---
|
||||
# ===== LANGFUSE SERVICE =====
|
||||
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: langfuse-web
|
||||
namespace: ${K8S_NAMESPACE}
|
||||
annotations:
|
||||
service.beta.kubernetes.io/oci-load-balancer-internal: "true"
|
||||
oci.oraclecloud.com/healthcheck-path: "/api/public/health"
|
||||
oci.oraclecloud.com/healthcheck-port: "3000"
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
selector:
|
||||
app: ${APP_NAME}
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 3000
|
||||
---
|
||||
# ===== LANGFUSE HPA - HORIZONTAL POD AUTOSCALER =====
|
||||
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: ${APP_NAME}-hpa
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: ${APP_NAME}
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 70
|
||||
---
|
||||
# ===== WORKER - AUTOSCALER =====
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: langfuse-worker-hpa
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: ${APP_NAME}-worker
|
||||
minReplicas: 2
|
||||
maxReplicas: 10
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 70
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: ${APP_NAME}-lb
|
||||
namespace: ${K8S_NAMESPACE}
|
||||
annotations:
|
||||
service.beta.kubernetes.io/oci-load-balancer-shape: "flexible"
|
||||
oci.oraclecloud.com/healthcheck-path: "/api/public/health"
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
selector:
|
||||
app: ${APP_NAME}
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 3000
|
||||
Reference in New Issue
Block a user