Skip to content

Commit d98b0b8

Browse files
committed
Added inital helm chart.
1 parent bbb8d52 commit d98b0b8

20 files changed

+928
-0
lines changed

deploy/helm/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

deploy/helm/Chart.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v2
2+
name: openblocks
3+
description: A Helm chart for Kubernetes for installing openblocks
4+
5+
type: application
6+
# Chart version (change every time you make changes to the chart)
7+
version: 0.1.0
8+
9+
# Openblocks version
10+
appVersion: "latest"
11+
12+
# Dependencies needed for Openblocks deployment
13+
dependencies:
14+
- condition: redis.enabled
15+
name: redis
16+
repository: https://charts.bitnami.com/bitnami
17+
version: 17.0.10
18+
- condition: mongodb.enabled
19+
name: mongodb
20+
repository: https://charts.bitnami.com/bitnami
21+
version: 13.6.2
22+

deploy/helm/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Openblocks
2+
3+
Openblocks is a developer-friendly open-source low code platform to build internal apps within minutes.
4+
5+
[Overview of Openblocks](https://docs.openblocks.dev/)
6+
7+
## Introduction
8+
9+
This chart bootstraps an Openblocks deployment on a [Kubernetes](https://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
10+
11+
## Prerequisites
12+
13+
- Kubernetes 1.19+
14+
- Helm 3.2.0+
15+
- PV provisioner support in the underlying infrastructure
16+
- Bitnami helm chart repository (if mongodb and/or redis is installed)
17+
18+
## Installing the Chart
19+
20+
To install the chart with the release name `my-openblocks` into namespace `openblocks`:
21+
22+
```bash
23+
# If installing mongodb and/or redis, add bitnami chart repository and update chart dependenices
24+
$ helm repo add bitnami https://charts.bitnami.com/bitnami
25+
$ helm dependency update
26+
27+
# Install the chart
28+
$ helm install -n openblocks my-openblocks .
29+
```
30+
31+
## Uninstalling the Chart
32+
33+
To uninstall/delete the `my-openblocks` deployment from namespace `openblocks`:
34+
35+
```bash
36+
$ helm delete -n openblocks my-openblocks
37+
```
38+
39+
## Parameters
40+
41+
### Redis
42+
43+
| Name | Description | Value |
44+
| ------------------------------------ | --------------------------------------------------------------------------- | ---------------- |
45+
| `redis.enabled` | Install our own instance of redis | `true` |
46+
| `redis.externalUrl` | External Redis URL used when `redis.enabled` is `false` | `""` |
47+
48+
All available parameters can be found in [Bitnami Redis Chart](https://github.com/bitnami/charts/tree/main/bitnami/redis/#parameters)
49+
50+
### MongoDB
51+
52+
| Name | Description | Value |
53+
| ------------------------------------ | --------------------------------------------------------------------------- | ---------------- |
54+
| `mongodb.enabled` | Install our own instance of mongo database | `true` |
55+
| `mongodb.externalUrl` | External mongo database connection string when `mongodb.enabled` is `false` | `""` |
56+
57+
All available parameters can be found in [Bitnami MongoDB Chart](https://github.com/bitnami/charts/tree/main/bitnami/mongodb/#parameters)
58+
59+
### Openblocks server api-service
60+
61+
| Name | Description | Value |
62+
| --------------------------------------- | --------------------------------------------------------------------------- | ---------------- |
63+
| `apiService.config.userId` | User ID of user running Openblocks server application in container | `9001` |
64+
| `apiService.config.groupId` | Group ID of user running Openblocks server application in container | `9001` |
65+
| `apiService.config.corsAllowedDomains` | CORS allowed domains | `*` |
66+
| `apiService.config.encryption.password` | Encryption password | `openblocks.dev` |
67+
| `apiService.config.encryption.salt` | Encryption salt | `openblocks.dev` |
68+
| `apiService.config.enableUserSignUp` | Enable users signing up to openblocks via login page | `true` |
69+
| `apiService.config.nodeServiceUrl` | URL to node-service server if using external Openblocks server | |
70+
71+
### Openblocks server node-service
72+
73+
| Name | Description | Value |
74+
| --------------------------------------- | --------------------------------------------------------------------------- | ---------------- |
75+
| `nodeService.config.userId` | User ID of user running Openblocks service application in container | `9001` |
76+
| `nodeService.config.groupId` | Group ID of user running Openblocks service application in container | `9001` |
77+
| `nodeService.config.apiServiceUrl` | URL to api-service server if using external Openblocks server | |
78+
79+
### Openblocks frontend (client)
80+
81+
| Name | Description | Value |
82+
| --------------------------------------- | --------------------------------------------------------------------------- | ---------------- |
83+
| `frontend.config.userId` | User ID of nginx user running Openblocks client application in container | `9001` |
84+
| `frontend.config.groupId` | Group ID of nginx user running Openblocks client application in container | `9001` |
85+
| `frontend.config.apiServiceUrl` | URL to api-service server if using external Openblocks server | `""` |
86+
| `frontend.config.nodeServiceUrl` | URL to node-service server if using external Openblocks server | |
87+

deploy/helm/templates/_helpers.tpl

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "openblocks.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "openblocks.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
28+
*/}}
29+
{{- define "openblocks.namespace" -}}
30+
{{- if .Values.global -}}
31+
{{- if .Values.global.namespaceOverride }}
32+
{{- .Values.global.namespaceOverride -}}
33+
{{- else -}}
34+
{{- .Release.Namespace -}}
35+
{{- end -}}
36+
{{- else -}}
37+
{{- .Release.Namespace -}}
38+
{{- end }}
39+
{{- end -}}
40+
41+
42+
{{/*
43+
Create chart name and version as used by the chart label.
44+
*/}}
45+
{{- define "openblocks.chart" -}}
46+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
47+
{{- end }}
48+
49+
{{/*
50+
Common labels
51+
*/}}
52+
{{- define "openblocks.labels" -}}
53+
helm.sh/chart: {{ include "openblocks.chart" . }}
54+
{{ include "openblocks.selectorLabels" . }}
55+
{{- if .Chart.AppVersion }}
56+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
57+
{{- end }}
58+
app.kubernetes.io/managed-by: {{ .Release.Service }}
59+
{{- end }}
60+
61+
{{/*
62+
Selector labels
63+
*/}}
64+
{{- define "openblocks.selectorLabels" -}}
65+
app.kubernetes.io/name: {{ include "openblocks.name" . }}
66+
app.kubernetes.io/instance: {{ .Release.Name }}
67+
{{- end }}
68+
69+
{{/*
70+
Create the name of the service account to use
71+
*/}}
72+
{{- define "openblocks.serviceAccountName" -}}
73+
{{- if .Values.serviceAccount.create }}
74+
{{- default (include "openblocks.fullname" .) .Values.serviceAccount.name }}
75+
{{- else }}
76+
{{- default "default" .Values.serviceAccount.name }}
77+
{{- end }}
78+
{{- end }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- $nameSpace := include "openblocks.namespace" . -}}
2+
{{- $name := include "openblocks.fullname" . -}}
3+
{{- $openblocksDatabase := first .Values.mongodb.auth.databases -}}
4+
apiVersion: v1
5+
kind: ConfigMap
6+
metadata:
7+
name: {{ include "openblocks.fullname" . }}-api-service
8+
labels:
9+
{{- include "openblocks.labels" . | nindent 4 }}
10+
{{- with .Values.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
data:
15+
{{- if .Values.redis.enabled }}
16+
REDIS_URL: "redis://{{ $name }}-redis-master.{{ $nameSpace }}.svc.cluster.local:6379"
17+
{{- else }}
18+
REDIS_URL: {{- .Values.redis.externalUrl | quote }}
19+
{{- end }}
20+
{{- if .Values.apiService.nodeServiceUrl }}
21+
JS_EXECUTOR_URI: {{ .Values.apiService.nodeServiceUrl | quote }}
22+
{{- else }}
23+
JS_EXECUTOR_URI: "http://{{ $name }}-node-service:{{ .Values.nodeService.service.port }}"
24+
{{- end }}
25+
PUID: {{ .Values.apiService.config.userId | default "9001" | quote }}
26+
PGID: {{ .Values.apiService.config.groupId | default "9001" | quote }}
27+
CORS_ALLOWED_DOMAINS: {{ .Values.apiService.config.corsAllowedDomains | default "*" | quote }}
28+
ENABLE_USER_SIGN_UP: {{ .Values.apiService.config.enableUserSignUp | default "true" | quote }}
29+
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "openblocks.fullname" . }}-api-service
5+
labels:
6+
{{- include "openblocks.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.apiService.autoscaling.enabled }}
9+
replicas: {{ .Values.apiService.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "openblocks.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
{{- with .Values.podAnnotations }}
17+
annotations:
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
labels:
21+
{{- include "openblocks.selectorLabels" . | nindent 8 }}
22+
spec:
23+
{{- with .Values.imagePullSecrets }}
24+
imagePullSecrets:
25+
{{- toYaml . | nindent 8 }}
26+
{{- end }}
27+
serviceAccountName: {{ include "openblocks.serviceAccountName" . }}
28+
securityContext:
29+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
30+
{{- if .Values.mongodb.enabled }}
31+
initContainers:
32+
- name: {{ .Chart.Name }}-wait-for-mongo
33+
image: curlimages/curl:7.87.0
34+
command:
35+
- /bin/sh
36+
args:
37+
- -ec
38+
- |
39+
echo "Wait for mongo database to be ready"
40+
while [[ $(curl --connect-timeout 2 -sw '%{http_code}' 'http://{{ .Values.mongodb.service.nameOverride }}:27017' -o /dev/null) -ne 200 ]]; do
41+
sleep 1;
42+
echo ' still waiting...';
43+
done;
44+
echo 'Connection with MongoDB established.'
45+
{{- end }}
46+
containers:
47+
- name: {{ .Chart.Name }}
48+
securityContext:
49+
{{- toYaml .Values.securityContext | nindent 12 }}
50+
image: "{{ .Values.apiService.image.repository }}:{{ .Values.apiService.image.tag | default .Chart.AppVersion }}"
51+
imagePullPolicy: {{ .Values.apiService.image.pullPolicy }}
52+
envFrom:
53+
- configMapRef:
54+
name: {{ include "openblocks.fullname" . }}-api-service
55+
- secretRef:
56+
name: {{ include "openblocks.fullname" . }}-api-service
57+
ports:
58+
- name: openblocks-api
59+
containerPort: 8080
60+
protocol: TCP
61+
livenessProbe:
62+
initialDelaySeconds: 30
63+
httpGet:
64+
path: /actuator/health
65+
port: openblocks-api
66+
readinessProbe:
67+
initialDelaySeconds: 30
68+
httpGet:
69+
path: /actuator/health
70+
port: openblocks-api
71+
resources:
72+
{{- toYaml .Values.resources | nindent 12 }}
73+
{{- with .Values.nodeSelector }}
74+
nodeSelector:
75+
{{- toYaml . | nindent 8 }}
76+
{{- end }}
77+
{{- with .Values.affinity }}
78+
affinity:
79+
{{- toYaml . | nindent 8 }}
80+
{{- end }}
81+
{{- with .Values.tolerations }}
82+
tolerations:
83+
{{- toYaml . | nindent 8 }}
84+
{{- end }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{- if .Values.apiService.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2beta1
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "openblocks.fullname" . }}-api-service
6+
labels:
7+
{{- include "openblocks.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "openblocks.fullname" . }}-api-service
13+
minReplicas: {{ .Values.apiService.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.apiService.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.apiService.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
targetAverageUtilization: {{ .Values.apiService.autoscaling.targetCPUUtilizationPercentage }}
21+
{{- end }}
22+
{{- if .Values.apiService.autoscaling.targetMemoryUtilizationPercentage }}
23+
- type: Resource
24+
resource:
25+
name: memory
26+
targetAverageUtilization: {{ .Values.apiService.autoscaling.targetMemoryUtilizationPercentage }}
27+
{{- end }}
28+
{{- end }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- $nameSpace := include "openblocks.namespace" . -}}
2+
{{- $mongoUser := first .Values.mongodb.auth.usernames -}}
3+
{{- $mongoPassword := first .Values.mongodb.auth.passwords -}}
4+
{{- $mongoServicename := .Values.mongodb.service.nameOverride -}}
5+
{{- $openblocksDatabase := first .Values.mongodb.auth.databases -}}
6+
apiVersion: v1
7+
kind: Secret
8+
type: Opaque
9+
metadata:
10+
name: {{ include "openblocks.fullname" . }}-api-service
11+
labels:
12+
{{- include "openblocks.labels" . | nindent 4 }}
13+
{{- with .Values.annotations }}
14+
annotations:
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
stringData:
18+
{{- if .Values.mongodb.enabled }}
19+
MONGODB_URI: "mongodb://{{ $mongoUser }}:{{ $mongoPassword }}@{{ $mongoServicename }}.{{ $nameSpace }}.svc.cluster.local/{{ $openblocksDatabase }}?retryWrites=true&ssl=false"
20+
{{- else }}
21+
MONGODB_URI: {{- .Values.mongodb.externalUrl | quote }}
22+
{{- end }}
23+
ENCRYPTION_PASSWORD: {{ .Values.apiService.config.encryption.password | default "openblocks.dev" | quote }}
24+
ENCRYPTION_SALT: {{ .Values.apiService.config.encryption.salt | default "openblocks.dev" | quote }}
25+

0 commit comments

Comments
 (0)