From 6533272605a150955035d88ebd5e505ce8a7af89 Mon Sep 17 00:00:00 2001 From: Marcin Jasion Date: Wed, 19 Jul 2023 20:00:47 +0200 Subject: [PATCH] feat(leo): Add Leo definition --- charts/studio/Chart.yaml | 2 +- charts/studio/README.md | 29 ++++-- charts/studio/templates/_helpers.tpl | 32 +++++-- charts/studio/templates/configmap-studio.yaml | 6 ++ .../templates/deployment-studio-leo.yaml | 94 +++++++++++++++++++ charts/studio/templates/service-leo.yaml | 15 +++ charts/studio/values.yaml | 69 +++++++++++--- 7 files changed, 218 insertions(+), 29 deletions(-) create mode 100644 charts/studio/templates/deployment-studio-leo.yaml create mode 100644 charts/studio/templates/service-leo.yaml diff --git a/charts/studio/Chart.yaml b/charts/studio/Chart.yaml index b3e3ea7a..78f26a8e 100644 --- a/charts/studio/Chart.yaml +++ b/charts/studio/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.2.10 +version: 0.2.12 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/studio/README.md b/charts/studio/README.md index 19408ff2..4d14bf2c 100644 --- a/charts/studio/README.md +++ b/charts/studio/README.md @@ -1,6 +1,6 @@ # studio -![Version: 0.2.10](https://img.shields.io/badge/Version-0.2.10-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.9.1](https://img.shields.io/badge/AppVersion-v2.9.1-informational?style=flat-square) +![Version: 0.2.12](https://img.shields.io/badge/Version-0.2.12-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v2.9.1](https://img.shields.io/badge/AppVersion-v2.9.1-informational?style=flat-square) A Helm chart for Kubernetes @@ -113,10 +113,8 @@ A Helm chart for Kubernetes | studioBackend.autoscaling.targetCPUUtilizationPercentage | int | `80` | | | studioBackend.envFromSecret | string | `""` | Studio: The name of an existing Secret that contains sensitive environment variables passed to backend pods. | | studioBackend.envVars | object | `{}` | Studio: Additional environment variables for backend pods | -| studioBackend.fullnameOverride | string | `""` | | | studioBackend.image.pullPolicy | string | `"IfNotPresent"` | | | studioBackend.image.repository | string | `"docker.iterative.ai/viewer_backend"` | | -| studioBackend.nameOverride | string | `""` | | | studioBackend.nodeSelector | object | `{}` | | | studioBackend.podAnnotations | object | `{}` | | | studioBackend.podSecurityContext | object | `{}` | | @@ -136,8 +134,6 @@ A Helm chart for Kubernetes | studioBeat.autoscaling.targetCPUUtilizationPercentage | int | `80` | | | studioBeat.envFromSecret | string | `""` | Studio: The name of an existing Secret that contains sensitive environment variables passed to beat pods. | | studioBeat.envVars | object | `{}` | Studio: Additional environment variables for beat pods | -| studioBeat.fullnameOverride | string | `""` | | -| studioBeat.nameOverride | string | `""` | | | studioBeat.nodeSelector | object | `{}` | | | studioBeat.podAnnotations | object | `{}` | | | studioBeat.podSecurityContext | object | `{}` | | @@ -148,6 +144,27 @@ A Helm chart for Kubernetes | studioBeat.resources.requests.memory | string | `"128Mi"` | | | studioBeat.securityContext | object | `{}` | | | studioBeat.tolerations | list | `[]` | | +| studioLeo.affinity | object | `{}` | | +| studioLeo.autoscaling.enabled | bool | `false` | | +| studioLeo.autoscaling.maxReplicas | int | `1` | | +| studioLeo.autoscaling.minReplicas | int | `1` | | +| studioLeo.autoscaling.targetCPUUtilizationPercentage | int | `80` | | +| studioLeo.envFromSecret | string | `""` | Studio: The name of an existing Secret that contains sensitive environment variables passed to leo pods. | +| studioLeo.envVars | object | `{}` | Studio: Additional environment variables for leo pods | +| studioLeo.image.pullPolicy | string | `"IfNotPresent"` | | +| studioLeo.image.repository | string | `"docker.iterative.ai/leo-server"` | | +| studioLeo.nodeSelector | object | `{}` | | +| studioLeo.podAnnotations | object | `{}` | | +| studioLeo.podSecurityContext | object | `{}` | | +| studioLeo.replicaCount | int | `1` | | +| studioLeo.resources.limits.cpu | string | `"500m"` | | +| studioLeo.resources.limits.memory | string | `"1Gi"` | | +| studioLeo.resources.requests.cpu | string | `"100m"` | | +| studioLeo.resources.requests.memory | string | `"512Mi"` | | +| studioLeo.securityContext | object | `{}` | | +| studioLeo.service.port | int | `8181` | | +| studioLeo.service.type | string | `"ClusterIP"` | | +| studioLeo.tolerations | list | `[]` | | | studioUi.affinity | object | `{}` | | | studioUi.autoscaling.enabled | bool | `false` | | | studioUi.autoscaling.maxReplicas | int | `5` | | @@ -178,8 +195,6 @@ A Helm chart for Kubernetes | studioWorker.autoscaling.targetCPUUtilizationPercentage | int | `80` | | | studioWorker.envFromSecret | string | `""` | Studio: The name of an existing Secret that contains sensitive environment variables passed to worker pods. | | studioWorker.envVars | object | `{}` | Studio: Additional environment variables for worker pods | -| studioWorker.fullnameOverride | string | `""` | | -| studioWorker.nameOverride | string | `""` | | | studioWorker.nodeSelector | object | `{}` | | | studioWorker.podAnnotations | object | `{}` | | | studioWorker.podSecurityContext | object | `{}` | | diff --git a/charts/studio/templates/_helpers.tpl b/charts/studio/templates/_helpers.tpl index 1e5e4d76..6c51d480 100644 --- a/charts/studio/templates/_helpers.tpl +++ b/charts/studio/templates/_helpers.tpl @@ -50,18 +50,18 @@ helm.sh/chart: {{ include "studio.chart" . }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} - {{- end }} -{{- define "studio-worker.labels" -}} + +{{- define "studio-backend.labels" -}} helm.sh/chart: {{ include "studio.chart" . }} -{{ include "studio-worker.selectorLabels" . }} +{{ include "studio-backend.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} -{{- define "studio-backend.labels" -}} +{{- define "studio-leo.labels" -}} helm.sh/chart: {{ include "studio.chart" . }} {{ include "studio-backend.selectorLabels" . }} {{- if .Chart.AppVersion }} @@ -79,6 +79,15 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} +{{- define "studio-worker.labels" -}} +helm.sh/chart: {{ include "studio.chart" . }} +{{ include "studio-worker.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + {{/* Selector labels */}} @@ -88,11 +97,6 @@ app.kubernetes.io/name: {{ include "studio.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} -{{- define "studio-ui.selectorLabels" -}} -app.kubernetes.io/name: studio-ui -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end }} - {{- define "studio-backend.selectorLabels" -}} app.kubernetes.io/name: studio-backend app.kubernetes.io/instance: {{ .Release.Name }} @@ -103,6 +107,16 @@ app.kubernetes.io/name: studio-beat app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} +{{- define "studio-leo.selectorLabels" -}} +app.kubernetes.io/name: studio-leo +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "studio-ui.selectorLabels" -}} +app.kubernetes.io/name: studio-ui +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + {{- define "studio-worker.selectorLabels" -}} app.kubernetes.io/name: studio-worker app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/charts/studio/templates/configmap-studio.yaml b/charts/studio/templates/configmap-studio.yaml index 0c699c8a..1b90bb99 100644 --- a/charts/studio/templates/configmap-studio.yaml +++ b/charts/studio/templates/configmap-studio.yaml @@ -119,3 +119,9 @@ data: DQL_ENABLED: {{ $dvcx.enabled | default "False" | quote }} DVCX_ENABLED: {{ $dvcx.enabled | default "False" | quote }} + LEO_SERVICE_HOST: {{ .Release.Name }}-studio-leo + LEO_SERVICE_PORT: {{ .Values.studioLeo.service.port }} + LEO_HOST: "{{ .Release.Name }}-studio-leo:{{ .Values.studioLeo.service.port }}" + LEO_ENCODING: "utf-8" + LEO_API_PATH_PREFIX: "{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}/{{ include "studio.basePath" . }}{{- end }}/leo" + LEO_ORIGIN: "http://{{.Release.Name}}-studio-leo" diff --git a/charts/studio/templates/deployment-studio-leo.yaml b/charts/studio/templates/deployment-studio-leo.yaml new file mode 100644 index 00000000..d252f8ae --- /dev/null +++ b/charts/studio/templates/deployment-studio-leo.yaml @@ -0,0 +1,94 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-studio-leo + labels: + {{- include "studio-leo.labels" . | nindent 4 }} +spec: + {{- if not .Values.studioLeo.autoscaling.enabled }} + replicas: {{ .Values.studioLeo.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "studio-leo.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + {{- include "studio.checksum" . | indent 8 }} + {{- with .Values.studioLeo.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "studio-leo.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "studio.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.studioLeo.podSecurityContext | nindent 8 }} + containers: + - name: studio-leo + securityContext: + {{- toYaml .Values.studioLeo.securityContext | nindent 12 }} + image: "{{ .Values.studioLeo.image.repository }}:{{ .Values.studioLeo.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.studioBackend.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + startupProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 5 + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: 80 + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /leo/debug/version + port: 80 + initialDelaySeconds: 5 + periodSeconds: 25 + successThreshold: 3 + timeoutSeconds: 120 + resources: + {{- toYaml .Values.studioLeo.resources | nindent 12 }} + envFrom: + - secretRef: + name: studio + {{- if .Values.global.envFromSecret }} + - secretRef: + name: {{ .Values.global.envFromSecret }} + {{- end }} + {{- if .Values.studioLeo.envFromSecret }} + - secretRef: + name: {{ .Values.studioLeo.envFromSecret }} + {{- end }} + volumeMounts: + {{- if .Values.global.customCaCert }} + - name: studio-ca-certificates + mountPath: /usr/local/share/ca-certificates + {{- end }} + volumes: + {{- if .Values.global.customCaCert }} + - name: studio-ca-certificates + configMap: + name: studio-ca-certificates + {{- end }} + {{- with .Values.studioLeo.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.studioLeo.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.studioLeo.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/studio/templates/service-leo.yaml b/charts/studio/templates/service-leo.yaml new file mode 100644 index 00000000..9336e5b3 --- /dev/null +++ b/charts/studio/templates/service-leo.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name}}-studio-leo + labels: + {{- include "studio-leo.labels" . | nindent 4 }} +spec: + type: {{ .Values.studioLeo.service.type }} + ports: + - port: {{ .Values.studioLeo.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "studio-leo.selectorLabels" . | nindent 4 }} diff --git a/charts/studio/values.yaml b/charts/studio/values.yaml index bb5ef362..41a2f8a4 100644 --- a/charts/studio/values.yaml +++ b/charts/studio/values.yaml @@ -419,10 +419,6 @@ studioBackend: targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 - nameOverride: "" - - fullnameOverride: "" - podAnnotations: {} podSecurityContext: {} @@ -470,10 +466,6 @@ studioBeat: targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 - nameOverride: "" - - fullnameOverride: "" - podAnnotations: {} podSecurityContext: {} @@ -493,6 +485,63 @@ studioBeat: affinity: {} +studioLeo: + # -- Studio: Additional environment variables for leo pods + envVars: {} + # Example: + # envVars: + # DEBUG: "True" + + # -- Studio: The name of an existing Secret that contains sensitive environment variables + # passed to leo pods. + envFromSecret: "" + + replicaCount: 1 + + image: + repository: docker.iterative.ai/leo-server + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + # tag: "v1.34.0" + + service: + type: ClusterIP + port: 8181 + + resources: + requests: + cpu: 100m + memory: 512Mi + limits: + cpu: 500m + memory: 1Gi + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 1 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + podAnnotations: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + nodeSelector: {} + + tolerations: [] + + affinity: {} + studioWorker: # -- Studio: Additional environment variables for worker pods envVars: {} @@ -521,10 +570,6 @@ studioWorker: targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 - nameOverride: "" - - fullnameOverride: "" - podAnnotations: {} podSecurityContext: {}