From 44fef26abd60d126865c0e1b86b346babe6f6dc1 Mon Sep 17 00:00:00 2001 From: Dan Patrick Date: Sat, 27 Jan 2024 13:20:28 -0500 Subject: [PATCH] add management ui helm chart --- deploy/helm/chat-ui/values.yaml | 2 +- deploy/helm/management-ui/.helmignore | 23 +++++ deploy/helm/management-ui/Chart.yaml | 5 ++ .../helm/management-ui/templates/_helpers.tpl | 40 +++++++++ .../management-ui/templates/configmap.yaml | 14 +++ .../management-ui/templates/deployment.yaml | 88 +++++++++++++++++++ .../helm/management-ui/templates/ingress.yaml | 41 +++++++++ .../helm/management-ui/templates/secret.yaml | 14 +++ .../helm/management-ui/templates/service.yaml | 19 ++++ .../templates/serviceaccount.yaml | 9 ++ deploy/helm/management-ui/values.yaml | 37 ++++++++ 11 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 deploy/helm/management-ui/.helmignore create mode 100644 deploy/helm/management-ui/Chart.yaml create mode 100644 deploy/helm/management-ui/templates/_helpers.tpl create mode 100644 deploy/helm/management-ui/templates/configmap.yaml create mode 100644 deploy/helm/management-ui/templates/deployment.yaml create mode 100644 deploy/helm/management-ui/templates/ingress.yaml create mode 100644 deploy/helm/management-ui/templates/secret.yaml create mode 100644 deploy/helm/management-ui/templates/service.yaml create mode 100644 deploy/helm/management-ui/templates/serviceaccount.yaml create mode 100644 deploy/helm/management-ui/values.yaml diff --git a/deploy/helm/chat-ui/values.yaml b/deploy/helm/chat-ui/values.yaml index c434104bd8..5c29b2034d 100644 --- a/deploy/helm/chat-ui/values.yaml +++ b/deploy/helm/chat-ui/values.yaml @@ -5,7 +5,7 @@ replicaCount: 1 serviceAccountName: chat-ui image: - repository: ghcr.io/solliancenet/foundationallm/chat-ui + repository: ghcr.io/solliancenet/foundationallm pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. tag: latest diff --git a/deploy/helm/management-ui/.helmignore b/deploy/helm/management-ui/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deploy/helm/management-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/deploy/helm/management-ui/Chart.yaml b/deploy/helm/management-ui/Chart.yaml new file mode 100644 index 0000000000..690a3209a2 --- /dev/null +++ b/deploy/helm/management-ui/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: management-ui +version: 0.0.0 diff --git a/deploy/helm/management-ui/templates/_helpers.tpl b/deploy/helm/management-ui/templates/_helpers.tpl new file mode 100644 index 0000000000..1cf0eeddc4 --- /dev/null +++ b/deploy/helm/management-ui/templates/_helpers.tpl @@ -0,0 +1,40 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "management-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 "management.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 "management-ui.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "management-ui.apihost" -}} +{{- if .Values.apihost -}} +{{- printf "%s" .Values.apihost -}} +{{- else -}} +{{- printf "%s" (index .Values.ingress.hosts 0) -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/deploy/helm/management-ui/templates/configmap.yaml b/deploy/helm/management-ui/templates/configmap.yaml new file mode 100644 index 0000000000..d7f810fc57 --- /dev/null +++ b/deploy/helm/management-ui/templates/configmap.yaml @@ -0,0 +1,14 @@ +{{- $name := include "management-ui.fullname" . -}} +{{- $apihost := include "management-ui.apihost" . -}} + +apiVersion: v1 +kind: ConfigMap +metadata: + name: "cfg-{{ $name }}" + labels: + app: {{ template "management-ui.name" . }} + chart: {{ template "management-ui.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + AZURE_CLIENT_ID: {{ .Values.azureWorkloadIdentity.managementUiClientId }} diff --git a/deploy/helm/management-ui/templates/deployment.yaml b/deploy/helm/management-ui/templates/deployment.yaml new file mode 100644 index 0000000000..cf835122ee --- /dev/null +++ b/deploy/helm/management-ui/templates/deployment.yaml @@ -0,0 +1,88 @@ +{{- $name := include "management-ui.fullname" . -}} +{{- $cfgname := printf "%s-%s" "cfg" $name -}} +{{- $secretName := printf "%s-%s" "secret" $name -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "management-ui.fullname" . }} + labels: + app: {{ template "management-ui.name" . }} + chart: {{ template "management-ui.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "management-ui.name" . }} + release: {{ .Release.Name }} + template: + metadata: + annotations: + rollme: {{ randAlphaNum 5 | quote }} + labels: + app: {{ template "management-ui.name" . }} + release: {{ .Release.Name }} + azure.workload.identity/use: "true" + spec: + serviceAccountName: {{ .Values.serviceAccountName }} + {{ if .Values.imagePullSecrets -}} + imagePullSecrets: + {{ range .Values.imagePullSecrets -}} + - name: {{ .name }} + {{- end -}} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + {{- if .Values.env.values -}} + {{- range .Values.env.values }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end -}} + {{- end -}} + {{- if .Values.env.configmap -}} + {{- range .Values.env.configmap }} + - name: {{ .name }} + valueFrom: + configMapKeyRef: + name: {{ $cfgname }} + key: {{ .name }} + {{- end -}} + {{- end }} + {{- if .Values.env.secret -}} + {{- range .Values.env.secret }} + - name: {{ .name }} + valueFrom: + secretKeyRef: + name: {{ $secretName }} + key: {{ .name }} + {{- end -}} + {{- end }} + ports: + - name: http + containerPort: 3000 + protocol: TCP + readinessProbe: + httpGet: + path: /status + port: 3000 + periodSeconds: 3 + timeoutSeconds: 1 + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + diff --git a/deploy/helm/management-ui/templates/ingress.yaml b/deploy/helm/management-ui/templates/ingress.yaml new file mode 100644 index 0000000000..83fc3af509 --- /dev/null +++ b/deploy/helm/management-ui/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "management-ui.fullname" . -}} + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app: {{ template "management-ui.name" . }} + chart: {{ template "management-ui.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ $fullName }} + port: + number: 80 + {{- end }} +{{- end }} diff --git a/deploy/helm/management-ui/templates/secret.yaml b/deploy/helm/management-ui/templates/secret.yaml new file mode 100644 index 0000000000..2db2c0d786 --- /dev/null +++ b/deploy/helm/management-ui/templates/secret.yaml @@ -0,0 +1,14 @@ +{{- $name := include "management-ui.fullname" . -}} + +apiVersion: v1 +kind: Secret +metadata: + name: "secret-{{ $name }}" + labels: + app: {{ template "management-ui.name" . }} + chart: {{ template "management-ui.chart" .}} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +type: Opaque +data: + NUXT_APP_CONFIG_ENDPOINT: {{ .Values.appConfig.connectionString | b64enc }} diff --git a/deploy/helm/management-ui/templates/service.yaml b/deploy/helm/management-ui/templates/service.yaml new file mode 100644 index 0000000000..1fc56aafe8 --- /dev/null +++ b/deploy/helm/management-ui/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "management-ui.fullname" . }} + labels: + app: {{ template "management-ui.name" . }} + chart: {{ template "management-ui.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app: {{ template "management-ui.name" . }} + release: {{ .Release.Name }} diff --git a/deploy/helm/management-ui/templates/serviceaccount.yaml b/deploy/helm/management-ui/templates/serviceaccount.yaml new file mode 100644 index 0000000000..42228fefa3 --- /dev/null +++ b/deploy/helm/management-ui/templates/serviceaccount.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.serviceAccountName }} + annotations: + azure.workload.identity/client-id: {{ .Values.azureWorkloadIdentity.managementUiClientId }} + azure.workload.identity/tenant-id: {{ .Values.azureWorkloadIdentity.tenantId }} + labels: + azure.workload.identity/use: "true" \ No newline at end of file diff --git a/deploy/helm/management-ui/values.yaml b/deploy/helm/management-ui/values.yaml new file mode 100644 index 0000000000..6a6f9cc884 --- /dev/null +++ b/deploy/helm/management-ui/values.yaml @@ -0,0 +1,37 @@ +# Default values for chat-ui. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 +serviceAccountName: chat-ui +image: + repository: ghcr.io/solliancenet/foundationallm/management-ui + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: latest + +service: + type: ClusterIP + port: 80 + +resources: {} + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +ingress: + enabled: false + +env: + configmap: + - name: AZURE_CLIENT_ID + secret: + - name: NUXT_APP_CONFIG_ENDPOINT + values: + - name: ASPNETCORE_ENVIRONMENT + value: Production + +