Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ hs_err_pid*

.idea/*

*.iml
*.iml

helm/thingsboard/profiles
20 changes: 3 additions & 17 deletions helm/thingsboard/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,7 @@ apiVersion: v2
name: thingsboard
description: A Helm chart for Thingsboard
type: application
version: 0.1.1
appVersion: 3.4.0
version: 0.2.0
appVersion: 4.1.0
icon: https://avatars.githubusercontent.com/u/24291394?s=200&v=4
home: https://github.com/thingsboard/thingsboard-ce-k8s/
dependencies:
- name: postgresql-ha
version: 8.5.2
repository: https://charts.bitnami.com/bitnami
- name: cassandra
version: 9.1.8
repository: https://charts.bitnami.com/bitnami
condition: cassandra.enabled
- name: kafka
version: 15.3.4
repository: https://charts.bitnami.com/bitnami
- name: redis
version: 16.4.5
repository: https://charts.bitnami.com/bitnami
home: https://github.com/thingsboard/thingsboard-ce-k8s/
26 changes: 9 additions & 17 deletions helm/thingsboard/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,9 @@ limitations under the License.

*/}}

{{/*
Fetch PostgreSQL pgpool service name from Bitnami's postgresql-ha sub-chart, with regard to it's nameOverride value
https://stackoverflow.com/questions/49142353/helm-getting-subchart-service-names
*/}}
{{- define "thingsboard.pgpoolservicename" -}}
{{/*
This fails with Helm 3.3.x and 3.4.x, it only works with Helm 3.5.0+:
{{- include "postgresql-ha.pgpool" (mustMerge (dict "Chart" (dict "Name" "postgresql-ha") "Values" (index .Values "postgresql-ha")) (deepCopy .)) }}
For helm 3.4- we need to work it around:
*/}}
{{- $deepDictCopy := dict }}
{{- $_ := deepCopy . | mustMerge $deepDictCopy }}
{{- $_ := unset $deepDictCopy "Chart" }}
{{- include "postgresql-ha.pgpool" (mustMerge (dict "Chart" (dict "Name" "postgresql-ha") "Values" (index .Values "postgresql-ha")) (deepCopy $deepDictCopy)) }}
{{- end -}}

{{/*
Set the value of cassandra initdb configmap
/*}}
*/}}
{{- if .Values.cassandra.enabled }}
{{- $_ := set .Values.cassandra "initDBConfigMap" "{{ .Release.Name }}-cassandra-init-db" }}
{{- end }}
Expand Down Expand Up @@ -89,14 +73,18 @@ Selector labels
{{- define "thingsboard.selectorLabels" -}}
app.kubernetes.io/name: {{ include "thingsboard.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/part-of: Thingsboard
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- define "thingsboard.selectorLabels-node" -}}
app.kubernetes.io/name: {{ include "thingsboard.name" . }}-node
app.kubernetes.io/instance: {{ .Release.Name }}-node

{{- end }}
{{- define "thingsboard.selectorLabels-mqtt" -}}
app.kubernetes.io/name: {{ include "thingsboard.name" . }}-mqtt
app.kubernetes.io/instance: {{ .Release.Name }}-mqtt

{{- end }}
{{- define "thingsboard.selectorLabels-http" -}}
app.kubernetes.io/name: {{ include "thingsboard.name" . }}-http
Expand All @@ -114,6 +102,10 @@ app.kubernetes.io/instance: {{ .Release.Name }}-jsexecutor
app.kubernetes.io/name: {{ include "thingsboard.name" . }}-webui
app.kubernetes.io/instance: {{ .Release.Name }}-webui
{{- end }}
{{- define "thingsboard.selectorLabels-rule-engine" -}}
app.kubernetes.io/name: {{ include "thingsboard.name" . }}-rule-engine
app.kubernetes.io/instance: {{ .Release.Name }}-rule-engine
{{- end }}

{{/*
Create the name of the service account to use
Expand Down
14 changes: 14 additions & 0 deletions helm/thingsboard/templates/cache-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ if and .Values.redis.enabled (not .Values.global.monolith) }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-cache-config
labels:
name: {{ .Release.Name }}-cache-config
{{- include "thingsboard.labels" . | nindent 4 }}
data:
# Make sure that the value does not contain the port (:6379).
CACHE_TYPE: redis
REDIS_HOST: {{ .Values.redis.host | quote }}
REDIS_PORT: {{ .Values.redis.port | quote }}
{{- end }}
12 changes: 12 additions & 0 deletions helm/thingsboard/templates/cassandra-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.cassandra.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-cassandra-secret
labels:
{{- include "thingsboard.labels" . | nindent 4 }}
type: kubernetes.io/basic-auth
stringData:
username: "{{ .Values.cassandra.dbUser.user }}"
password: "{{ .Values.cassandra.dbUser.password }}"
{{- end }}
3 changes: 2 additions & 1 deletion helm/thingsboard/templates/coap-transport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

{{ if and .Values.coap.enabled (not .Values.global.monolith) }}
apiVersion: apps/v1
kind: {{ .Values.coap.kind }}
metadata:
Expand Down Expand Up @@ -100,3 +100,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions helm/thingsboard/templates/component-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
{{ if not .Values.global.monolith }}

{{ $values := .Values -}}
{{- $releaseName := .Release.Name -}}
Expand All @@ -39,3 +40,4 @@ spec:
app.kubernetes.io/name: thingsboard-{{ $component }}
---
{{ end }}
{{ end }}
2 changes: 1 addition & 1 deletion helm/thingsboard/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{{- $fullname := include "thingsboard.fullname" . -}}
{{- $releaseName := .Release.Name -}}
{{- $labels := include "thingsboard.labels" . -}}
{{- range tuple "node" "mqtt" "http" "coap" "jsexecutor" -}}
{{- range tuple "node" "ruleEngine" "mqtt" "http" "coap" "jsexecutor" -}}
{{- $component := . -}}
{{- $componentvalues := index $values $component -}}
{{- if $componentvalues.autoscaling.enabled }}
Expand Down
7 changes: 2 additions & 5 deletions helm/thingsboard/templates/http-transport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

{{ if and .Values.http.enabled (not .Values.global.monolith) }}
apiVersion: apps/v1
kind: {{ .Values.http.kind }}
metadata:
Expand Down Expand Up @@ -59,10 +59,6 @@ spec:
env:
- name: TB_SERVICE_ID
value: "tb-http-transport"
- name: TB_QUEUE_TYPE
value: "kafka"
- name: HTTP_BIND_ADDRESS
value: "0.0.0.0"
- name: HTTP_BIND_PORT
value: "{{ .Values.http.port.number }}"
- name: HTTP_REQUEST_TIMEOUT
Expand Down Expand Up @@ -108,3 +104,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
68 changes: 15 additions & 53 deletions helm/thingsboard/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: nginx
{{- with .Values.ingress.tls }}
tls:
- hosts:
Expand All @@ -43,89 +44,50 @@ spec:
- host: {{ . | quote }}
http:
paths:
- path: /api/v1/.*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-http
port:
number: {{ $values.http.service.port }}
- path: /api/.*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
port:
number: {{ $values.node.service.port }}
- path: /swagger.*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
port:
number: {{ $values.node.service.port }}
- path: /webjars.*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
port:
number: {{ $values.node.service.port }}
- path: /v2/.*
{{- if $values.global.monolith }}
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
port:
number: {{ $values.node.service.port }}
- path: /v3/.*
{{- else }}
- path: /api/v1/.*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
name: {{ $releaseName }}-http
port:
number: {{ $values.node.service.port }}
number: {{ $values.http.service.port }}
- path: /static/rulenode/.*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
port:
number: {{ $values.node.service.port }}
- path: /assets/help/.*/rulenode/.*
- path: /static/*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
port:
number: {{ $values.node.service.port }}
- path: /oauth2/.*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
port:
number: {{ $values.node.service.port }}
- path: /login/oauth2/.*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-node
name: {{ $releaseName }}-webui
port:
number: {{ $values.node.service.port }}
- path: /
number: {{ $values.webui.service.port }}
- path: /index.html
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-webui
port:
number: {{ $values.webui.service.port }}
- path: /.*
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: {{ $releaseName }}-webui
name: {{ $releaseName }}-node
port:
number: {{ $values.webui.service.port }}
number: {{ $values.node.service.port }}
{{- end }}
{{- end }}
{{- end }}
31 changes: 26 additions & 5 deletions helm/thingsboard/templates/initializedb-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

{{ if .Values.node.initDb }}
apiVersion: batch/v1
kind: Job
metadata:
Expand All @@ -28,10 +28,8 @@ spec:
- name: '{{ .Release.Name }}-container-registry'
initContainers:
- name: check-db-ready
image: postgres:{{ index .Values "postgresql-ha" "postgresqlImage" "tag" }}
command: ['sh', '-c',
'until pg_isready -h {{ include "thingsboard.pgpoolservicename" . }} -p {{ index .Values "postgresql-ha" "pgpool" "containerPort" }};
do echo waiting for database; sleep 2; done;']
image: busybox:latest
command: ['sh', '-c', 'echo -e "Checking for the availability of PostgreSQL Server deployment"; while ! nc -z {{ .Values.database.host }} {{ .Values.database.port }}; do sleep 1; printf "-"; done; echo -e " >> PostgreSQL Server has started";']
containers:
- name: init-db
envFrom:
Expand All @@ -51,6 +49,28 @@ spec:
value: "true"
- name: LOAD_DEMO
value: "{{ .Values.node.loadDemo }}"
- name: SPRING_DATASOURCE_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-database-secret
key: username
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-database-secret
key: password
{{- if .Values.cassandra.enabled }}
- name: CASSANDRA_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-cassandra-secret
key: username
- name: CASSANDRA_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-cassandra-secret
key: password
{{- end }}
restartPolicy: Never
volumes:
- name: '{{ .Release.Name }}-node-config'
Expand All @@ -61,3 +81,4 @@ spec:
path: thingsboard.conf
- key: logback
path: logback.xml
{{ end }}
14 changes: 12 additions & 2 deletions helm/thingsboard/templates/js-executor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

{{ if and .Values.jsexecutor.enabled (not .Values.global.monolith) }}
apiVersion: apps/v1
kind: {{ .Values.jsexecutor.kind }}
metadata:
Expand Down Expand Up @@ -53,6 +53,9 @@ spec:
{{- toYaml .Values.jsexecutor.securityContext | nindent 12 }}
image: "{{ .Values.jsexecutor.image.server | default .Values.global.image.server }}/{{ .Values.jsexecutor.image.repository }}:{{ .Values.jsexecutor.image.tag | default .Values.global.image.tag }}"
imagePullPolicy: {{ .Values.jsexecutor.image.pullPolicy | default .Values.global.image.pullPolicy}}
ports:
- containerPort: {{ .Values.jsexecutor.port.http }}
name: http
env:
- name: REMOTE_JS_EVAL_REQUEST_TOPIC
value: "js_eval.requests"
Expand All @@ -61,7 +64,7 @@ spec:
- name: TB_QUEUE_KAFKA_REPLICATION_FACTOR
value: "{{ .Values.kafka.offsetsTopicReplicationFactor }}"
- name: LOGGER_LEVEL
value: "info"
value: "error"
- name: LOG_FOLDER
value: "logs"
- name: LOGGER_FILENAME
Expand All @@ -72,6 +75,12 @@ spec:
value: "1000"
- name: NODE_OPTIONS
value: "--max-old-space-size=200"
livenessProbe:
httpGet:
path: /livenessProbe
port: http
initialDelaySeconds: 360
timeoutSeconds: 10
resources:
{{- toYaml .Values.jsexecutor.resources | nindent 12 }}
{{- with .Values.jsexecutor.jsexecutorSelector }}
Expand All @@ -86,3 +95,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Loading