diff --git a/helm-charts/common/ui/.helmignore b/helm-charts/common/ui/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/helm-charts/common/ui/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helm-charts/common/ui/Chart.yaml b/helm-charts/common/ui/Chart.yaml new file mode 100644 index 000000000..a6d152d22 --- /dev/null +++ b/helm-charts/common/ui/Chart.yaml @@ -0,0 +1,9 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v2 +name: ui +description: A Helm chart to the UI for chatQnA workload +type: application +version: 0.8.0 +appVersion: "1.0.0" diff --git a/helm-charts/common/ui/templates/_helpers.tpl b/helm-charts/common/ui/templates/_helpers.tpl new file mode 100644 index 000000000..07e404849 --- /dev/null +++ b/helm-charts/common/ui/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "ui.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "ui.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "ui.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ui.labels" -}} +helm.sh/chart: {{ include "ui.chart" . }} +{{ include "ui.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ui.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ui.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "ui.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "ui.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/common/ui/templates/configmap.yaml b/helm-charts/common/ui/templates/configmap.yaml new file mode 100644 index 000000000..a9cf25859 --- /dev/null +++ b/helm-charts/common/ui/templates/configmap.yaml @@ -0,0 +1,20 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "ui.fullname" . }}-config + labels: + {{- include "ui.labels" . | nindent 4 }} +data: + http_proxy: {{ .Values.global.http_proxy | quote }} + https_proxy: {{ .Values.global.https_proxy | quote }} + no_proxy: {{ .Values.global.no_proxy | quote }} + BACKEND_SERVICE_ENDPOINT: {{ .Values.BACKEND_SERVICE_ENDPOINT | quote }} + DATAPREP_SERVICE_ENDPOINT: {{ .Values.DATAPREP_SERVICE_ENDPOINT | quote }} + DATAPREP_GET_FILE_ENDPOINT: {{ .Values.DATAPREP_GET_FILE_ENDPOINT | quote }} + CHAT_BASE_URL: {{ .Values.BACKEND_SERVICE_ENDPOINT | quote }} + UPLOAD_FILE_BASE_URL: {{ .Values.DATAPREP_SERVICE_ENDPOINT | quote }} + GET_FILE: {{ .Values.DATAPREP_GET_FILE_ENDPOINT | quote }} + DELETE_FILE: {{ .Values.DATAPREP_DELETE_FILE_ENDPOINT | quote }} diff --git a/helm-charts/common/ui/templates/deployment.yaml b/helm-charts/common/ui/templates/deployment.yaml new file mode 100644 index 000000000..4a5fcfbb0 --- /dev/null +++ b/helm-charts/common/ui/templates/deployment.yaml @@ -0,0 +1,67 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "ui.fullname" . }} + labels: + {{- include "ui.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "ui.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "ui.labels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + envFrom: + - configMapRef: + name: {{ include "ui.fullname" . }}-config + {{- if .Values.global.extraEnvConfig }} + - configMapRef: + name: {{ .Values.global.extraEnvConfig }} + optional: true + {{- end }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: ui + containerPort: {{ .Values.containerPort }} + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /tmp + name: tmp + volumes: + - name: tmp + emptyDir: {} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm-charts/common/ui/templates/service.yaml b/helm-charts/common/ui/templates/service.yaml new file mode 100644 index 000000000..0757f090a --- /dev/null +++ b/helm-charts/common/ui/templates/service.yaml @@ -0,0 +1,18 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Service +metadata: + name: {{ include "ui.fullname" . }} + labels: + {{- include "ui.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: ui + protocol: TCP + name: ui + selector: + {{- include "ui.selectorLabels" . | nindent 4 }} diff --git a/helm-charts/common/ui/templates/tests/test-pod.yaml b/helm-charts/common/ui/templates/tests/test-pod.yaml new file mode 100644 index 000000000..db92a5587 --- /dev/null +++ b/helm-charts/common/ui/templates/tests/test-pod.yaml @@ -0,0 +1,23 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "ui.fullname" . }}-testpod" + labels: + {{- include "ui.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test + #"helm.sh/hook-delete-policy": "hook-succeeded, hook-failure" +spec: + containers: + - name: curl + image: alpine/curl + #image: python:3.10.14 + command: ['sh', '-c'] + args: + - | + curl http://{{ include "ui.fullname" . }}:{{ .Values.service.port }} -sS --fail-with-body \ + -X GET + restartPolicy: Never diff --git a/helm-charts/common/ui/values.yaml b/helm-charts/common/ui/values.yaml new file mode 100644 index 000000000..fc712a233 --- /dev/null +++ b/helm-charts/common/ui/values.yaml @@ -0,0 +1,80 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +# Default values for conversational-ui. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: opea/chatqna-conversation-ui:latest + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + # tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # Currently comment the securityContext settings + # as the inappropriate settings within Conversational UI (need root privilege) + # issue: https://github.com/opea-project/GenAIExamples/issues/517 + #readOnlyRootFilesystem: true + #allowPrivilegeEscalation: false + #runAsNonRoot: true + #runAsUser: 1000 + #capabilities: + # drop: + # - ALL + #seccompProfile: + # type: RuntimeDefault + +# internal container port +# conventional ui container port: 5173, conversational ui container port: 80 +containerPort: 80 + +service: + type: ClusterIP + port: 5174 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# chatQnA Mega service URL, e.g. http://: +BACKEND_SERVICE_ENDPOINT: "" + +# data preparation service URL, http://: +DATAPREP_SERVICE_ENDPOINT: "" + +# data preparation get file service URL, http://: +DATAPREP_GET_FILE_ENDPOINT: "" + +# data preparation delete file service URL, http://: +DATAPREP_DELETE_FILE_ENDPOINT: "" + +global: + http_proxy: "" + https_proxy: "" + no_proxy: "" diff --git a/manifests/common/ui.yaml b/manifests/common/ui.yaml new file mode 100644 index 000000000..e482a026a --- /dev/null +++ b/manifests/common/ui.yaml @@ -0,0 +1,107 @@ +--- +# Source: ui/templates/configmap.yaml +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: ConfigMap +metadata: + name: ui-config + labels: + helm.sh/chart: ui-0.8.0 + app.kubernetes.io/name: ui + app.kubernetes.io/instance: ui + app.kubernetes.io/version: "1.0.0" + app.kubernetes.io/managed-by: Helm +data: + http_proxy: "" + https_proxy: "" + no_proxy: "" + BACKEND_SERVICE_ENDPOINT: "" + DATAPREP_SERVICE_ENDPOINT: "" + DATAPREP_GET_FILE_ENDPOINT: "" + CHAT_BASE_URL: "" + UPLOAD_FILE_BASE_URL: "" + GET_FILE: "" + DELETE_FILE: "" +--- +# Source: ui/templates/service.yaml +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v1 +kind: Service +metadata: + name: ui + labels: + helm.sh/chart: ui-0.8.0 + app.kubernetes.io/name: ui + app.kubernetes.io/instance: ui + app.kubernetes.io/version: "1.0.0" + app.kubernetes.io/managed-by: Helm +spec: + type: ClusterIP + ports: + - port: 5174 + targetPort: ui + protocol: TCP + name: ui + selector: + app.kubernetes.io/name: ui + app.kubernetes.io/instance: ui +--- +# Source: ui/templates/deployment.yaml +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ui + labels: + helm.sh/chart: ui-0.8.0 + app.kubernetes.io/name: ui + app.kubernetes.io/instance: ui + app.kubernetes.io/version: "1.0.0" + app.kubernetes.io/managed-by: Helm +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: ui + app.kubernetes.io/instance: ui + template: + metadata: + labels: + helm.sh/chart: ui-0.8.0 + app.kubernetes.io/name: ui + app.kubernetes.io/instance: ui + app.kubernetes.io/version: "1.0.0" + app.kubernetes.io/managed-by: Helm + spec: + securityContext: + {} + containers: + - name: ui + envFrom: + - configMapRef: + name: ui-config + - configMapRef: + name: extra-env-config + optional: true + securityContext: + {} + image: "opea/chatqna-conversation-ui:latest" + imagePullPolicy: IfNotPresent + ports: + - name: ui + containerPort: 80 + protocol: TCP + resources: + {} + volumeMounts: + - mountPath: /tmp + name: tmp + volumes: + - name: tmp + emptyDir: {}