Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(model): add pvc for deployment config #1008

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions charts/core/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ internal TLS secret names
{{/*
Persistent Volume Claims
*/}}
{{- define "core.modelConfigDataVolume" -}}
{{- printf "%s-model-config-data-volume" (include "core.fullname" .) -}}
{{- end -}}

{{- define "core.registryDataVolume" -}}
{{- printf "%s-registry-data-volume" (include "core.fullname" .) -}}
{{- end -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/core/templates/model-backend/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ data:
{{- end }}
rayserver:
grpcuri: {{ include "core.ray" . }}:{{ include "core.ray.serveGrpcPort" . }}
modelstore: /model-backend
modelstore: /model-config
vram: {{ .Values.rayService.vram }}
database:
username: {{ default (include "core.database.username" .) .Values.database.external.username }}
Expand Down
24 changes: 24 additions & 0 deletions charts/core/templates/model-backend/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.tags.model -}}
{{- $modelConfig := .Values.persistence.persistentVolumeClaim.modelConfig -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -125,6 +126,15 @@ spec:
value: "{{ template "core.ray" . }}"
- name: RAY_SERVER_SERVE_PORT
value: "{{ template "core.ray.servePort" . }}"
- name: chmod-model-config
securityContext:
runAsUser: 0
runAsGroup: 0
image: busybox
command: ["sh", "-c", "chmod -R 777 /model-config"]
volumeMounts:
- name: model-config
mountPath: /model-config
containers:
- name: model-backend-worker
image: {{ .Values.modelBackend.image.repository }}:{{ .Values.modelBackend.image.tag }}
Expand All @@ -141,6 +151,8 @@ spec:
- name: config
mountPath: {{ .Values.modelBackend.configPath }}
subPath: config.yaml
- name: model-config
mountPath: /model-config
{{- with .Values.modelBackend.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -174,6 +186,8 @@ spec:
- name: config
mountPath: {{ .Values.modelBackend.configPath }}
subPath: config.yaml
- name: model-config
mountPath: /model-config
{{- if .Values.internalTLS.enabled }}
- name: model-internal-certs
mountPath: "/etc/instill-ai/model/ssl/model"
Expand All @@ -192,6 +206,16 @@ spec:
- name: config
configMap:
name: {{ template "core.modelBackend" . }}
- name: model-config
{{- if not .Values.persistence.enabled }}
emptyDir: {}
{{- else if $modelConfig.existingClaim }}
persistentVolumeClaim:
claimName: {{ $modelConfig.existingClaim }}
{{- else }}
persistentVolumeClaim:
claimName: core-model-config-data-volume
{{- end }}
{{- if .Values.internalTLS.enabled }}
- name: model-internal-certs
secret:
Expand Down
32 changes: 32 additions & 0 deletions charts/core/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
{{- if .Values.persistence.enabled }}
{{- if .Values.tags.model -}}
{{- $modelConfig := .Values.persistence.persistentVolumeClaim.modelConfig -}}
{{- if not $modelConfig.existingClaim }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "core.modelConfigDataVolume" . }}
annotations:
{{- range $key, $value := $modelConfig.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if eq .Values.persistence.resourcePolicy "keep" }}
helm.sh/resource-policy: keep
{{- end }}
labels:
{{- include "core.labels" . | nindent 4 }}
app.kubernetes.io/component: model-backend
spec:
accessModes:
- {{ $modelConfig.accessMode }}
resources:
requests:
storage: {{ $modelConfig.size }}
{{- if $modelConfig.storageClass }}
{{- if eq "-" $modelConfig.storageClass }}
storageClassName: ""
{{- else }}
storageClassName: {{ $modelConfig.storageClass }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if eq .Values.registry.config.storage.type "filesystem" }}
{{- $registry := .Values.persistence.persistentVolumeClaim.registry -}}
{{- if not $registry.existingClaim }}
Expand Down
8 changes: 8 additions & 0 deletions charts/core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ persistence:
resourcePolicy: "keep"
persistentVolumeClaim:
# If external database is used, the following settings for database will be ignored
modelConfig:
existingClaim: ""
storageClass: ""
subPath: ""
accessMode: ReadWriteOnce
size: 512Mi
annotations: {}
database:
existingClaim: ""
storageClass: ""
Expand Down Expand Up @@ -1431,6 +1438,7 @@ registry:
auth_provider_x509_cert_url:
client_x509_cert_url:
rootdirectory:
chunksize:
delete:
enabled: true
redirect:
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ networks:
volumes:
elasticsearch_data:
name: elasticsearch-data
model_config:
name: model-config

services:
api_gateway:
Expand Down Expand Up @@ -224,7 +226,7 @@ services:
CFG_SERVER_EDITION: ${EDITION}
CFG_SERVER_INSTILLCOREHOST: http://${INSTILL_CORE_HOST}:${API_GATEWAY_PORT}
CFG_RAYSERVER_GRPCURI: ${RAY_SERVER_HOST}:${RAY_SERVER_SERVE_GRPC_PORT}
CFG_RAYSERVER_MODELSTORE: /model-backend
CFG_RAYSERVER_MODELSTORE: /model-config
CFG_RAYSERVER_VRAM: ${RAY_SERVER_VRAM}
CFG_DATABASE_HOST: ${POSTGRESQL_HOST}
CFG_DATABASE_PORT: ${POSTGRESQL_PORT}
Expand All @@ -236,6 +238,8 @@ services:
CFG_CACHE_REDIS_REDISOPTIONS_ADDR: ${REDIS_HOST}:${REDIS_PORT}
CFG_LOG_EXTERNAL: ${OBSERVE_ENABLED}
CFG_LOG_OTELCOLLECTOR_PORT: ${OTEL_COLLECTOR_PORT}
volumes:
- model_config:/model-config
command:
- /bin/sh
- -c
Expand Down Expand Up @@ -282,6 +286,8 @@ services:
CFG_CACHE_REDIS_REDISOPTIONS_ADDR: ${REDIS_HOST}:${REDIS_PORT}
CFG_LOG_EXTERNAL: ${OBSERVE_ENABLED}
CFG_LOG_OTELCOLLECTOR_PORT: ${OTEL_COLLECTOR_PORT}
volumes:
- model_config:/model-config
entrypoint: ./model-backend-worker
depends_on:
temporal:
Expand Down
Loading