Skip to content

Commit

Permalink
Adding Helm chart for Quesma demo (#1105)
Browse files Browse the repository at this point in the history
Adding helm chart for Quesma demo on k8s.

More details in
[README.md](https://github.com/QuesmaOrg/quesma/blob/aa05036c8497f0d648a20a1f22a71a56c59241b7/helm-chart/README.md)
  • Loading branch information
mieciu authored Dec 13, 2024
1 parent 9e47844 commit 80216be
Show file tree
Hide file tree
Showing 22 changed files with 745 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ bin/.running-docker-compose
docs/public/node_modules
docs/public/docs/.vitepress/cache/deps
docs/public/docs/.vitepress/dist
helm-chart/quesma-demo/values.yaml
60 changes: 60 additions & 0 deletions helm-chart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Quesma Helm Chart
=================

This Helm Chart runs Quesma demo on Kubernetes cluster. It has been tested on Minikube and is not intended for production use.
* it assumes that you already have your ClickHouse/Hydrolix cluster up and running.
* it installs Quesma along with minimal instance of Elasticsearch and Kibana.

1. Create values.yaml file based on the template file:
```shell
cp quesma-demo/values.template.yaml quesma-demo/values.yaml
```
2. Fill in the values in `values.yaml` file in the `config.quesmaConfigurationYaml` section.
This section is mapped directly to the quesma configuration file.
3. Install the chart:
```shell
helm install quesma-demo quesma-demo/ -f quesma-demo/values.yaml
```
4. Profit!

This installs `quesma-demo` helm chart from `quesma-demo/` directory.

You can access the services by setting up a minikube tunnel:
```
minikube tunnel
```
**Note:** This command will block the terminal, so you will need to keep that terminal window open all the time if you
want to access the services exposed in k8s cluster.
Then follow to:
* http://127.0.0.1:30560 Kibana
* http://127.0.0.1:30999 Quesma Admin UI
* http://127.0.0.1:30808 Quesma frontend connector (Elasticsearch API in this case)
Sometimes `minikube tunnel` doesn't work, in that case you can use `kubectl port-forward` command to forward the ports to your local machine.
```bash
kubectl port-forward svc/kibana 30560:5601
kubectl port-forward svc/quesma-ext-admin 30999:9999
kubectl port-forward svc/quesma-ext-frontend 30808:8080
```
And then access the aforementioned URLs in your browser. You also need to keep the terminal process up.

You can remove it anytime with
```bash
helm uninstall quesma-demo
```

If you make any changes to the chart you can upgrade it with
```bash
helm upgrade quesma-demo quesma-demo/ -f quesma-demo/values.yaml
```
Optionally, add `--force` flag if you made no changes in k8s object definitions but need (want? :|) to reapply the chart.


### Local development

Make sure you have `helm` and `minikube` installed (both can be installed with `brew install helm minikube`).
Make sure you have local k8s cluster running (`minikube (start|status|stop|delete)`) before installing the chart.



23 changes: 23 additions & 0 deletions helm-chart/quesma-demo/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
24 changes: 24 additions & 0 deletions helm-chart/quesma-demo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: quesma-demo
description: A Helm chart for deploying Quesma MVP Demo with minimal Elasticsearch and Kibana

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.0.1

# 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
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 1.0.2
Empty file.
22 changes: 22 additions & 0 deletions helm-chart/quesma-demo/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 "quesma.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 its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "quesma.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "quesma.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 "quesma.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-chart/quesma-demo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "quesma.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 "quesma.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 "quesma.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "quesma.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "quesma.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
52 changes: 52 additions & 0 deletions helm-chart/quesma-demo/templates/aux-elasticsearch-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch
labels:
app: elasticsearch
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.1
ports:
- containerPort: 9200
name: http
- containerPort: 9300
name: transport
env:
- name: discovery.type
value: "single-node"
- name: xpack.security.enabled
value: "false"
- name: ES_JAVA_OPTS
value: "-Xmx2G"
resources:
limits:
memory: "4Gi"
requests:
memory: "2Gi"
livenessProbe:
httpGet:
path: /
port: 9200
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 5
readinessProbe:
httpGet:
path: /
port: 9200
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
17 changes: 17 additions & 0 deletions helm-chart/quesma-demo/templates/aux-elasticsearch-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: elasticsearch
labels:
app: elasticsearch
spec:
ports:
- name: http
port: 9200
targetPort: 9200
{{/* - name: transport*/}}
{{/* port: 9300*/}}
{{/* targetPort: 9300*/}}
selector:
app: elasticsearch
type: ClusterIP
43 changes: 43 additions & 0 deletions helm-chart/quesma-demo/templates/aux-kibana-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: kibana
labels:
app: kibana
spec:
replicas: 1
selector:
matchLabels:
app: kibana
template:
metadata:
labels:
app: kibana
spec:
containers:
- name: kibana
image: docker.elastic.co/kibana/kibana:8.11.1
ports:
- containerPort: 5601
name: http
env:
- name: ELASTICSEARCH_HOSTS
value: '["http://{{ include "quesma.fullname" . }}:{{ .Values.service.port }}"]'
- name: XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY
value: 'QUESMAQUESMAQUESMAQUESMAQUESMAQUESMAQUESMAQUESMA'
livenessProbe:
httpGet:
path: /api/status
port: 5601
initialDelaySeconds: 120
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 5
readinessProbe:
httpGet:
path: /api/status
port: 5601
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
14 changes: 14 additions & 0 deletions helm-chart/quesma-demo/templates/aux-kibana-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: kibana
labels:
app: kibana
spec:
ports:
- port: 5601
targetPort: 5601
nodePort: 30560
selector:
app: kibana
type: NodePort
10 changes: 10 additions & 0 deletions helm-chart/quesma-demo/templates/configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: quesma-first-config
labels:
app: {{ .Release.Name }}-quesma
data:
quesma-config.yaml: |
# Quesma configuration file is rendered here based on `values.yaml` file
{{ .Values.config.quesmaConfigurationYaml | toYaml | nindent 6 }}
Loading

0 comments on commit 80216be

Please sign in to comment.