Skip to content

Commit

Permalink
add replicaCount and hpa for opik (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
liyaka authored Sep 5, 2024
1 parent 43c044b commit f04f1f3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
4 changes: 4 additions & 0 deletions deployment/helm_chart/opik/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Call opik api on http://localhost:5173/api
| clickhouse.replicasCount | int | `1` | |
| clickhouse.shardsCount | int | `1` | |
| clickhouse.storage | string | `"50Gi"` | |
| component.backend.autoscaling.enabled | bool | `false` | |
| component.backend.env.ANALYTICS_DB_DATABASE_NAME | string | `"opik"` | |
| component.backend.env.ANALYTICS_DB_HOST | string | `"clickhouse-opik-clickhouse"` | |
| component.backend.env.ANALYTICS_DB_MIGRATIONS_URL | string | `"jdbc:clickhouse://clickhouse-opik-clickhouse:8123"` | |
Expand All @@ -119,6 +120,7 @@ Call opik api on http://localhost:5173/api
| component.backend.initContainers[0].env[0].value | string | `"http://clickhouse-opik-clickhouse:8123"` | |
| component.backend.initContainers[0].image | string | `"stefanevinance/wait-for-200"` | |
| component.backend.initContainers[0].name | string | `"wait-for-clickhouse-service"` | |
| component.backend.replicaCount | int | `1` | |
| component.backend.service.ports[0].name | string | `"http"` | |
| component.backend.service.ports[0].port | int | `8080` | |
| component.backend.service.ports[0].protocol | string | `"TCP"` | |
Expand All @@ -129,9 +131,11 @@ Call opik api on http://localhost:5173/api
| component.backend.service.ports[1].targetPort | int | `3003` | |
| component.backend.service.type | string | `"ClusterIP"` | |
| component.backend.serviceAccount.create | bool | `true` | |
| component.frontend.autoscaling.enabled | bool | `false` | |
| component.frontend.image.pullPolicy | string | `"IfNotPresent"` | |
| component.frontend.image.repository | string | `"opik-frontend"` | |
| component.frontend.ingress.enabled | bool | `false` | |
| component.frontend.replicaCount | int | `1` | |
| component.frontend.service.ports[0].name | string | `"http"` | |
| component.frontend.service.ports[0].port | int | `5173` | |
| component.frontend.service.ports[0].protocol | string | `"TCP"` | |
Expand Down
4 changes: 3 additions & 1 deletion deployment/helm_chart/opik/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ metadata:
{{- include "opik.labels" $ | nindent 4 }}
component: {{ include "opik.name" $ }}-{{ $key | lower }}
spec:
replicas: 1
{{- if not $value.autoscaling.enabled }}
replicas: {{ $value.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "opik.labels" $ | nindent 6 }}
Expand Down
44 changes: 44 additions & 0 deletions deployment/helm_chart/opik/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- range $key, $value := .Values.component }}
{{- if $value.autoscaling.enabled }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "opik.name" $ }}-{{ $key | lower }}-hpa
labels:
{{- include "opik.labels" $ | nindent 4 }}
component: {{ include "opik.name" $ }}-{{ $key | lower }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: "Deployment"
name: {{ include "opik.name" $ }}-{{ $key | lower }}
minReplicas: {{ $value.autoscaling.minReplicas }}
maxReplicas: {{ $value.autoscaling.maxReplicas }}
metrics:
{{- if $value.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ $value.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if $value.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ $value.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- if $value.autoscaling.targetMemoryAverageValue }}
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageValue: {{ $value.autoscaling.targetMemoryAverageValue }}
{{- end }}
{{- end }}
{{- end }}
7 changes: 6 additions & 1 deletion deployment/helm_chart/opik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ component:
image:
repository: opik-backend
pullPolicy: IfNotPresent
replicaCount: 1
autoscaling:
enabled: false
initContainers:
- name: wait-for-clickhouse-service
image: stefanevinance/wait-for-200
Expand Down Expand Up @@ -71,7 +74,9 @@ component:
image:
repository: opik-frontend
pullPolicy: IfNotPresent

replicaCount: 1
autoscaling:
enabled: false
volumeMounts:
- mountPath: /etc/nginx/conf.d/
name: opik-frontend-nginx
Expand Down

0 comments on commit f04f1f3

Please sign in to comment.