Skip to content

Commit

Permalink
Add Helm Chart to VibraniumDome
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpxchg16 committed Apr 8, 2024
1 parent 9eeb841 commit af896b9
Show file tree
Hide file tree
Showing 25 changed files with 1,268 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: vibraniumdome
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
68 changes: 68 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# VibraniumDome Helm Chart

## Prerequisites
[Helm installed](https://helm.sh/docs/helm/helm_install/)

## Install VibraniumDome Helm Chart
**Note:** you can run it locally on [Minikube](https://minikube.sigs.k8s.io/docs/start/). The default resources in Minikube are low, so when start Minikube, provide higher resources, e.g:

```
minikube start --memory 24000 --cpus 10
```

## Create OPENAI_API_KEY in k8s
```
kubectl create secret generic vibraniumdome-shields-secrets --from-literal=OPENAI_API_KEY=$OPENAI_API_KEY
```

```
git clone git@github.com:genia-dev/vibraniumdome.git
cd vibraniumdome
helm install test-release helm
```

## Check system is running
```
kubectl get pods
```

Should show:

```
NAME READY STATUS RESTARTS AGE
vibraniumdome-app-0 1/1 Running 0 5s
vibraniumdome-app-db-0 1/1 Running 0 5s
vibraniumdome-opensearch-dashboards-0 1/1 Running 0 5s
vibraniumdome-opensearch-node-1-0 1/1 Running 0 5s
vibraniumdome-opensearch-seeder-rnvm6 1/1 Running 0 5s
vibraniumdome-shields-0 1/1 Running 0 5s
vibraniumdome-streamlit-app-0 1/1 Running 0 5s
```

When the `vibraniumdome-opensearch-seeder` job STATUS changed from `Running` to `Completed`, you can access the app.

**Note:** In Minikube mode you need to expose the k8s services to your localhost by:

```
kubectl port-forward service/vibraniumdome-app 3000:3000
```

```
kubectl port-forward service/vibraniumdome-opensearch-dashboards 5601:5601
```

```
kubectl port-forward service/vibraniumdome-shields 5001:5001
```

```
kubectl port-forward service/vibraniumdome-streamlit-app 8501:8501
```

Now you can access the application via http://localhost:3000 and the streamlit application via http://localhost:8501 and send llm interactions via http://localhost:5001 .


## Uninstall VibraniumDome Helm Chart
```
helm uninstall test-release
```
22 changes: 22 additions & 0 deletions helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "vibraniumdome.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "vibraniumdome.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "vibraniumdome.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "vibraniumdome.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "vibraniumdome.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 "vibraniumdome.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 "vibraniumdome.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "vibraniumdome.labels" -}}
helm.sh/chart: {{ include "vibraniumdome.chart" . }}
{{ include "vibraniumdome.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "vibraniumdome.selectorLabels" -}}
app.kubernetes.io/name: {{ include "vibraniumdome.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "vibraniumdome.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "vibraniumdome.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
36 changes: 36 additions & 0 deletions helm/templates/app-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Values.app.name }}
spec:
replicas: {{ .Values.app.replicaCount }}
selector:
matchLabels:
app: {{ .Values.app.name }}
template:
metadata:
labels:
app: {{ .Values.app.name }}
spec:
containers:
- name: {{ .Values.app.name }}
image: "{{ .Values.app.image.repository }}:{{ .Values.app.image.tag }}"
ports:
- containerPort: {{ (index .Values.app.ports 0).containerPort }}
env:
- name: DATABASE_URL
value: {{ .Values.app.environment.DATABASE_URL | quote }}
- name: NEXTAUTH_SECRET
value: {{ .Values.app.environment.NEXTAUTH_SECRET | quote }}
- name: NEXTAUTH_URL
value: {{ .Values.app.environment.NEXTAUTH_URL | quote }}
- name: GOOGLE_CLIENT_ID
value: {{ .Values.app.environment.GOOGLE_CLIENT_ID | quote }}
- name: GOOGLE_CLIENT_SECRET
value: {{ .Values.app.environment.GOOGLE_CLIENT_SECRET | quote }}
- name: OPENSEARCH_JWT_HMAC_SIGNING_KEY
value: {{ .Values.app.environment.OPENSEARCH_JWT_HMAC_SIGNING_KEY | quote }}
- name: OPENSEARCH_DASHBOARD_URL
value: {{ .Values.app.environment.OPENSEARCH_DASHBOARD_URL | quote }}
- name: OPENSEARCH_GOVERNANCE_URL
value: {{ .Values.app.environment.OPENSEARCH_GOVERNANCE_URL | quote }}
11 changes: 11 additions & 0 deletions helm/templates/app-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.app.name }}
spec:
type: ClusterIP
ports:
- port: {{ (index .Values.app.ports 0).containerPort }}
targetPort: {{ (index .Values.app.ports 0).containerPort }}
selector:
app: {{ .Values.app.name }}
27 changes: 27 additions & 0 deletions helm/templates/mysql-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Values.db.name }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Values.db.name }}
template:
metadata:
labels:
app: {{ .Values.db.name }}
spec:
containers:
- name: {{ .Values.db.name }}
image: "{{ .Values.db.image.repository }}:{{ .Values.db.image.tag }}"
env:
- name: MYSQL_ROOT_PASSWORD
value: {{ .Values.db.env.MYSQL_ROOT_PASSWORD | quote }}
- name: MYSQL_ALLOW_EMPTY_PASSWORD
value: {{ .Values.db.env.MYSQL_ALLOW_EMPTY_PASSWORD | quote }}
- name: MYSQL_DATABASE
value: {{ .Values.db.env.MYSQL_DATABASE | quote }}
args: ["--default-authentication-plugin=mysql_native_password"]
ports:
- containerPort: {{ (index .Values.db.ports 0).containerPort }}
11 changes: 11 additions & 0 deletions helm/templates/mysql-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.db.name }}
spec:
type: ClusterIP
ports:
- port: {{ (index .Values.db.ports 0).containerPort }}
targetPort: {{ (index .Values.db.ports 0).containerPort }}
selector:
app: {{ .Values.db.name }}
7 changes: 7 additions & 0 deletions helm/templates/opensearch-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: opensearch-config
data:
opensearch.yml: |
{{ .Values.opensearchConfig.properties | nindent 4 }}
7 changes: 7 additions & 0 deletions helm/templates/opensearch-dashboard-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: opensearch-dashboard-ndjson-config
data:
dashboard.ndjson: |
{{ .Values.opensearchDashboardNdjson.properties | nindent 4 }}
7 changes: 7 additions & 0 deletions helm/templates/opensearch-dashboards-config-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: opensearch-dashboards-config
data:
opensearch_dashboards.yml: |
{{ .Values.opensearchDashboardsConfig.properties | nindent 4 }}
42 changes: 42 additions & 0 deletions helm/templates/opensearch-dashboards-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Values.opensearchDashboards.name }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Values.opensearchDashboards.name }}
template:
metadata:
labels:
app: {{ .Values.opensearchDashboards.name }}
spec:
containers:
- name: {{ .Values.opensearchDashboards.name }}
image: "{{ .Values.opensearchDashboards.image.repository }}:{{ .Values.opensearchDashboards.image.tag }}"
ports:
- containerPort: 5601
env:
- name: "OPENSEARCH_HOSTS"
value: '["https://vibraniumdome-opensearch-node-1:9200"]'
volumeMounts:
- name: opensearch-dashboards-config
mountPath: /usr/share/opensearch-dashboards/config/opensearch_dashboards.yml
subPath: opensearch_dashboards.yml
- name: opensearch-dashboards-data
mountPath: /usr/share/opensearch-dashboards/data
volumes:
- name: opensearch-dashboards-data
emptyDir: {}
- name: opensearch-dashboards-config
configMap:
name: opensearch-dashboards-config
- name: script-volume
configMap:
name: opensearch-seeder-config
- name: opensearch-dashboard-ndjson-config
configMap:
name: opensearch-dashboard-ndjson-config


13 changes: 13 additions & 0 deletions helm/templates/opensearch-dashboards-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.opensearchDashboards.name }}
spec:
type: ClusterIP
ports:
- port: 5601
targetPort: 5601
protocol: TCP
name: http
selector:
app: {{ .Values.opensearchDashboards.name }}
7 changes: 7 additions & 0 deletions helm/templates/opensearch-log4j2-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: opensearch-log4j2-config
data:
log4j2.properties: |
{{ .Values.opensearchLog4j2Config.properties | nindent 4 }}
49 changes: 49 additions & 0 deletions helm/templates/opensearch-node1-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Values.opensearchNode1.name }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Values.opensearchNode1.name }}
template:
metadata:
labels:
app: {{ .Values.opensearchNode1.name }}
spec:
containers:
- name: {{ .Values.opensearchNode1.name }}
image: "{{ .Values.opensearchNode1.image.repository }}:{{ .Values.opensearchNode1.image.tag }}"
ports:
- containerPort: 9200
- containerPort: 9600
env:
{{- range .Values.opensearchNode1.environment }}
- name: {{ .name }}
value: "{{ .value }}"
{{- end }}
volumeMounts:
- name: opensearch-data1
mountPath: /usr/share/opensearch/data
- name: opensearch-config
mountPath: /usr/share/opensearch/config/opensearch-security/opensearch.yml
subPath: opensearch.yml
- name: opensearch-security-config
mountPath: /usr/share/opensearch/config/opensearch-security/config.yml
subPath: config.yml
- name: opensearch-log4j2-config
mountPath: /usr/share/opensearch/config/log4j2.properties
subPath: log4j2.properties
volumes:
- name: opensearch-data1
emptyDir: {}
- name: opensearch-config
configMap:
name: opensearch-config
- name: opensearch-security-config
configMap:
name: opensearch-security-config
- name: opensearch-log4j2-config
configMap:
name: opensearch-log4j2-config
Loading

0 comments on commit af896b9

Please sign in to comment.