From c680804c915af9ca424652e9586de00c925411db Mon Sep 17 00:00:00 2001 From: sd109 Date: Mon, 1 Jul 2024 15:11:48 +0100 Subject: [PATCH] Add Danswer Azimuth chart --- danswer-azimuth/.helmignore | 23 +++ danswer-azimuth/Chart.yaml | 21 +++ danswer-azimuth/README.md | 4 + danswer-azimuth/azimuth-ui.schema.yaml | 2 + danswer-azimuth/templates/NOTES.txt | 1 + danswer-azimuth/templates/_helpers.tpl | 44 ++++++ danswer-azimuth/templates/client.yaml | 9 ++ danswer-azimuth/templates/hooks.yml | 163 +++++++++++++++++++++ danswer-azimuth/templates/reservation.yaml | 13 ++ danswer-azimuth/values.schema.json | 5 + danswer-azimuth/values.yaml | 29 ++++ 11 files changed, 314 insertions(+) create mode 100644 danswer-azimuth/.helmignore create mode 100644 danswer-azimuth/Chart.yaml create mode 100644 danswer-azimuth/README.md create mode 100644 danswer-azimuth/azimuth-ui.schema.yaml create mode 100644 danswer-azimuth/templates/NOTES.txt create mode 100644 danswer-azimuth/templates/_helpers.tpl create mode 100644 danswer-azimuth/templates/client.yaml create mode 100644 danswer-azimuth/templates/hooks.yml create mode 100644 danswer-azimuth/templates/reservation.yaml create mode 100644 danswer-azimuth/values.schema.json create mode 100644 danswer-azimuth/values.yaml diff --git a/danswer-azimuth/.helmignore b/danswer-azimuth/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/danswer-azimuth/.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/danswer-azimuth/Chart.yaml b/danswer-azimuth/Chart.yaml new file mode 100644 index 00000000..c1687ba4 --- /dev/null +++ b/danswer-azimuth/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: danswer-azimuth +description: An self-service platform for Retrieval-Augmented Generation. +type: application +version: 0.1.0 +appVersion: 0.1.0 +icon: https://raw.githubusercontent.com/danswer-ai/danswer/1fabd9372d66cd54238847197c33f091a724803b/DanswerWithName.png + +# TODO: Switch to upstream Danswer chart if/when the following patches are accepted: +# - https://github.com/danswer-ai/danswer/pull/1605 +# - https://github.com/danswer-ai/danswer/pull/1606 +# - https://github.com/danswer-ai/danswer/pull/1608 +# - https://github.com/danswer-ai/danswer/pull/1726 +# - https://github.com/danswer-ai/danswer/pull/1754 +dependencies: + - name: danswer-stack + version: 0.5.10 + repository: https://stackhpc.github.io/danswer + +annotations: + azimuth.stackhpc.com/label: Danswer diff --git a/danswer-azimuth/README.md b/danswer-azimuth/README.md new file mode 100644 index 00000000..0281268d --- /dev/null +++ b/danswer-azimuth/README.md @@ -0,0 +1,4 @@ +# Danswer Azimuth + +This Helm chart deploys a Danswer instance that is exposed to users +via the Azimuth Platforms page. diff --git a/danswer-azimuth/azimuth-ui.schema.yaml b/danswer-azimuth/azimuth-ui.schema.yaml new file mode 100644 index 00000000..af5511f5 --- /dev/null +++ b/danswer-azimuth/azimuth-ui.schema.yaml @@ -0,0 +1,2 @@ +controls: {} + diff --git a/danswer-azimuth/templates/NOTES.txt b/danswer-azimuth/templates/NOTES.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/danswer-azimuth/templates/NOTES.txt @@ -0,0 +1 @@ + diff --git a/danswer-azimuth/templates/_helpers.tpl b/danswer-azimuth/templates/_helpers.tpl new file mode 100644 index 00000000..d1340ec9 --- /dev/null +++ b/danswer-azimuth/templates/_helpers.tpl @@ -0,0 +1,44 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "danswer-azimuth.name" -}} +{{- .Chart.Name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +*/}} +{{- define "danswer-azimuth.fullname" -}} +{{- if contains .Chart.Name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "danswer-azimuth.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Selector labels for a chart-level resource. +*/}} +{{- define "danswer-azimuth.selectorLabels" -}} +app.kubernetes.io/name: {{ include "danswer-azimuth.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Labels for a chart-level resource. +*/}} +{{- define "danswer-azimuth.labels" -}} +helm.sh/chart: {{ include "danswer-azimuth.chart" . }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +{{ include "danswer-azimuth.selectorLabels" . }} +{{- end }} diff --git a/danswer-azimuth/templates/client.yaml b/danswer-azimuth/templates/client.yaml new file mode 100644 index 00000000..687e7990 --- /dev/null +++ b/danswer-azimuth/templates/client.yaml @@ -0,0 +1,9 @@ +apiVersion: zenith.stackhpc.com/v1alpha1 +kind: Client +metadata: + name: {{ include "danswer-azimuth.fullname" . }} + labels: {{ include "danswer-azimuth.labels" . | nindent 4 }} +spec: + reservationName: {{ include "danswer-azimuth.fullname" . }} + upstream: + serviceName: {{ .Release.Name }}-nginx diff --git a/danswer-azimuth/templates/hooks.yml b/danswer-azimuth/templates/hooks.yml new file mode 100644 index 00000000..635ee3f5 --- /dev/null +++ b/danswer-azimuth/templates/hooks.yml @@ -0,0 +1,163 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ .Release.Name }}-danswer-fixup + namespace: {{ .Release.Name }} + annotations: + # Need to keep around for post-delete hooks + helm.sh/resource-policy: keep +rules: +- apiGroups: + - "" + resources: + - persistentvolumeclaims + verbs: + - get + - list + - delete +- apiGroups: + - apps + resources: + - statefulsets + - deployments + verbs: + - get + - patch +- apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ .Release.Name }}-danswer-fixup + namespace: {{ .Release.Name }} + annotations: + # Need to keep around for post-delete hooks + helm.sh/resource-policy: keep +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ .Release.Name }}-danswer-fixup +subjects: +# Namespace is unique to Azimuth app so using default +# service account is fine. +- kind: ServiceAccount + name: default + namespace: {{ .Release.Name }} +--- +# Delete stateful set PVCs since upstream Helm chart doesn't expose this config option +apiVersion: batch/v1 +kind: Job +metadata: + name: pvc-cleanup + namespace: {{ .Release.Name }} + annotations: + helm.sh/hook: post-delete + helm.sh/hook-weight: "0" + helm.sh/hook-delete-policy: hook-succeeded +spec: + template: + spec: + containers: + - name: pvc-deleter + image: gcr.io/google_containers/hyperkube:v1.18.0 + command: + - kubectl + - delete + - -n + - {{ .Release.Name }} + - pvc + - --all + restartPolicy: Never + serviceAccountName: default +--- +# Until https://github.com/unoplat/vespa-helm-charts/pull/23 +# is merged, we need to patch vespa stateful set after deployment +# so that service label selectors match correctly. +# Since Danswer API pod gives up on Vespa application package +# init request after just 5 retries we also need to restart the API +# deployment to trigger a retry on the Vespa setup by the API pod +# after labels are corrected. +# Use three separate hooks with different hook-weights to control ordering. +apiVersion: batch/v1 +kind: Job +metadata: + name: vespa-label-updater + namespace: {{ .Release.Name }} + annotations: + helm.sh/hook: post-install,post-upgrade,post-rollback + helm.sh/hook-weight: "1" + helm.sh/hook-delete-policy: hook-succeeded +spec: + template: + spec: + containers: + - name: label-updater + image: gcr.io/google_containers/hyperkube:v1.18.0 + command: + - kubectl + - patch + - -n + - {{ .Release.Name }} + - statefulset/vespa + - -p + - {{ printf "{'spec':{'template':{'metadata':{'labels':{'app.kubernetes.io/instance':'%s'}}}}}" .Release.Name | replace "'" "\"" | squote }} + restartPolicy: Never + serviceAccountName: default +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: vespa-waiter + namespace: {{ .Release.Name }} + annotations: + helm.sh/hook: post-install,post-upgrade,post-rollback + helm.sh/hook-weight: "2" + helm.sh/hook-delete-policy: hook-succeeded +spec: + template: + spec: + containers: + - name: waiter + image: gcr.io/google_containers/hyperkube:v1.18.0 + command: + - kubectl + - wait + - -n + - {{ .Release.Name }} + - --for=condition=Ready + - pod/vespa-0 + restartPolicy: Never + serviceAccountName: default +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: danswer-api-restarter + namespace: {{ .Release.Name }} + annotations: + helm.sh/hook: post-install,post-upgrade,post-rollback + helm.sh/hook-weight: "3" + helm.sh/hook-delete-policy: hook-succeeded +spec: + template: + spec: + containers: + - name: restarter + image: gcr.io/google_containers/hyperkube:v1.18.0 + command: + - kubectl + - rollout + - restart + - -n + - {{ .Release.Name }} + - {{ printf "deployment/%s-danswer-stack-api-deployment" .Release.Name }} + restartPolicy: Never + serviceAccountName: default diff --git a/danswer-azimuth/templates/reservation.yaml b/danswer-azimuth/templates/reservation.yaml new file mode 100644 index 00000000..1c32d9c8 --- /dev/null +++ b/danswer-azimuth/templates/reservation.yaml @@ -0,0 +1,13 @@ +apiVersion: zenith.stackhpc.com/v1alpha1 +kind: Reservation +metadata: + name: {{ include "danswer-azimuth.fullname" . }} + labels: {{ include "danswer-azimuth.labels" . | nindent 4 }} + annotations: + azimuth.stackhpc.com/service-label: {{ quote .Values.zenithClient.label }} + azimuth.stackhpc.com/service-icon-url: {{ .Values.zenithClient.iconUrl }} + {{- with .Values.zenithClient.description }} + azimuth.stackhpc.com/service-description: {{ quote . }} + {{- end }} +spec: + credentialSecretName: {{ include "danswer-azimuth.fullname" . }}-credential diff --git a/danswer-azimuth/values.schema.json b/danswer-azimuth/values.schema.json new file mode 100644 index 00000000..51af8675 --- /dev/null +++ b/danswer-azimuth/values.schema.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/schema#", + "type": "object", + "properties": {} +} diff --git a/danswer-azimuth/values.yaml b/danswer-azimuth/values.yaml new file mode 100644 index 00000000..5e949f7e --- /dev/null +++ b/danswer-azimuth/values.yaml @@ -0,0 +1,29 @@ +zenithClient: + iconUrl: https://raw.githubusercontent.com/danswer-ai/danswer/1fabd9372d66cd54238847197c33f091a724803b/Danswer.png + description: + label: "Danswer" + +vespaVolumeSize: &vespa-capacity 10Gi + +danswer-stack: + # appVersionOverride: # e.g. v0.5.1 + configMap: + AUTH_TYPE: basic + DISABLE_TELEMETRY: true + DISABLE_LLM_CHOOSE_SEARCH: true + nginx: + service: + type: ClusterIP + vespa: + service: + type: ClusterIP + volumeClaimTemplates: + - metadata: + name: vespa-storage + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: *vespa-capacity +