Skip to content

Commit

Permalink
Opentwins Helm upgrade: connections are now independent of the releas…
Browse files Browse the repository at this point in the history
…e name assigned when installing.
  • Loading branch information
juliarobles committed Nov 28, 2023
1 parent 43c57a7 commit b5f0aaf
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 65 deletions.
21 changes: 21 additions & 0 deletions OpenTwins/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,25 @@ Get the full name of the InfluxDB2 sub chart.
{{- $name := default "influxdb2" .Values.influxdb2.nameOverride }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end -}}
{{- end -}}

{{/*
Get the full name of the MongoDB sub chart.
*/}}
{{- define "opentwins.mongodb.fullname" -}}
{{- if .Values.mongodb.enabled }}
{{- if .Values.mongodb.fullnameOverride }}
{{- .Values.mongodb.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default "mongodb" .Values.mongodb.nameOverride }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end -}}
{{- else }}
{{- if .Values "OpenTwins-MongoDB" "fullnameOverride" }}
{{- .Values "OpenTwins-MongoDB" "fullnameOverride" | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default "mongodb" .Values "OpenTwins-MongoDB" "nameOverride" }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if and .Values.grafana.enabled .Values.influxdb2.enabled }}

apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ .Release.Name }}-influxdb2-grafana-datasource"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
"{{ .Values.grafana.sidecar.datasources.label }}": ""
data:
datasources.yaml: |+
apiVersion: 1
datasources:
- name: opentwins
type: influxdb
access: proxy
url: http://{{ include "opentwins.influxdb2.fullname" . }}:80
isDefault: true
jsonData:
version: Flux
organization: "{{ .Values.influxdb2.adminUser.organization }}"
defaultBucket: "{{ .Values.influxdb2.adminUser.bucket }}"
tlsSkipVerify: true
secureJsonData:
token: "{{ .Values.influxdb2.adminUser.token }}"
{{- end }}
2 changes: 1 addition & 1 deletion OpenTwins/templates/config-maps/cm-telegraf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data:
timeout = "120s"
token = "{{ .Values.influxdb2.adminUser.token }}"
urls = [
"http://{{ include "opentwins.influxdb2.fullname" . }}:1883"
"http://{{ include "opentwins.influxdb2.fullname" . }}:80"
]
{{- end }}

Expand Down
21 changes: 21 additions & 0 deletions OpenTwins/templates/secrets/mongodb-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if or .Values.mongodb.enabled .Values "OpenTwins-MongoDB" "fullnameOverride" }}
{{- $mongoName := include "opentwins.mongodb.fullname" . -}}

apiVersion: v1
kind: Secret
metadata:
name: ditto-mongodb-connection-secret
labels:
app.kubernetes.io/name: {{ template "opentwins.name" . }}
helm.sh/chart: {{ template "opentwins.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
type: Opaque
data:
connectivity-uri: {{ .Values.ditto.dbconfig.connectivity.uri | replace "#{PLACEHOLDER_MONGODB_HOSTNAME}#" $mongoName | b64enc | quote }}
things-uri: {{ .Values.ditto.dbconfig.things.uri | replace "#{PLACEHOLDER_MONGODB_HOSTNAME}#" $mongoName | b64enc | quote }}
thingsSearch-uri: {{ .Values.ditto.dbconfig.thingsSearch.uri | replace "#{PLACEHOLDER_MONGODB_HOSTNAME}#" $mongoName | b64enc | quote }}
policies-uri: {{ .Values.ditto.dbconfig.policies.uri | replace "#{PLACEHOLDER_MONGODB_HOSTNAME}#" $mongoName | b64enc | quote }}

{{- end }}
123 changes: 59 additions & 64 deletions OpenTwins/values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# OpenTwins specific values
##################################################################


# Enabling these persistent volumes or not will depend on how your Kubernetes cluster works.
# In our case, the cluster creates them automatically, so we don't need to activate them.
# In other clusters we have seen that they are not created automatically, so to enable persistence it will be necessary to activate them.
persistentVolumes:
grafana: false
hono: false
Expand Down Expand Up @@ -59,29 +63,30 @@ ditto:
nodePort: 30525
swaggerui:
enabled: false
dittoui:
enabled: false

# ----------------------------------------------
# Do not modify this unless you want to use your own mongodb or ditto mongodb.
# Opentwins can display two different mongodb charts. In case of displaying both, the bitnami one will take precedence.
mongodb:
enabled: false
dbconfig:
connectivity:
uri: mongodb://opentwins-mongodb:27017/connectivity #{{ .Release.Name | tpl }}
things:
uri: mongodb://opentwins-mongodb:27017/things
searchDB:
uri: mongodb://opentwins-mongodb:27017/search
policies:
uri: mongodb://opentwins-mongodb:27017/policies
connectivity:
readinessProbe:
initialDelaySeconds: 30
livenessProbe:
initialDelaySeconds: 80
uriSecret: ditto-mongodb-connection-secret
# ----------------------------------------------

gateway:
config:
authentication:
enablePreAuthentication: true
devops:
devopsPassword: foobar
statusPassword: foobar
#connectivity:
# readinessProbe:
# initialDelaySeconds: 30
# livenessProbe:
# initialDelaySeconds: 80



Expand Down Expand Up @@ -111,38 +116,6 @@ mongodb:



# OpenTwins recommended values for ertis MongoDB
##################################################################
OpenTwins-MongoDB:
enabled: false # Value added by OpenTwins to indicate if this component should be installed or not
nameOverride: mongodb
auth:
enabled: false
securityContext:
enabled: false
persistence:
enabled: false
metadata:
labels:
app: database
selector: mongodb
service:
type: NodePort
nodePort: 30717
spec:
containers:
- name: mongodb
image:
repository: mongo
tag: 4.4.6
# env:
# - name: MONGO_INITDB_ROOT_USERNAME
# value: admin
# - name: MONGO_INITDB_ROOT_PASSWORD
# value: password



# OpenTwins recommended values for Grafana
##################################################################
grafana:
Expand All @@ -154,23 +127,9 @@ grafana:
nodePort: 45718
adminUser: admin
adminPassword: admin
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: opentwins
type: influxdb
access: proxy
url: http://opentwins-influxdb2:80
isDefault: true
jsonData:
version: Flux
organization: "opentwins"
defaultBucket: "default"
tlsSkipVerify: true
secureJsonData:
token: "Hjh3ysMQ6evK=qqpFSYqn-s3JGovJLfHxyCDM=eNNZkdM-uuro93dNtJcodejLYYob2geKQ/29z3Kxui=y6FlL?dZeU9EFRxrYn284V/kZG5==jxLVAMJrYOv?LF79ahwIbhvstMN6gmfQ3DH7/IzUB7VlBZK-cd8aN7YqiFrYRLkBUv7H0QkbqPxgf2dMgCMCwZaLMk9RUeMaBfx2lQ=Mq1EEJJw-Jp!BmpCDnhlc!6D22PaE=Y3sgWWNhRv8oP"

sidecar:
datasources:
enabled: true


# OpenTwins recommended values for InfluxDB2
Expand All @@ -188,7 +147,11 @@ influxdb2:
organization: "opentwins"
bucket: "default"
password: "password"
# ----------------------------------------------
# We have generated this token randomly in this page: https://generate-random.org/api-token-generator
# We recommend to generate one of your own and assign it to this value in your values file.
token: "Hjh3ysMQ6evK=qqpFSYqn-s3JGovJLfHxyCDM=eNNZkdM-uuro93dNtJcodejLYYob2geKQ/29z3Kxui=y6FlL?dZeU9EFRxrYn284V/kZG5==jxLVAMJrYOv?LF79ahwIbhvstMN6gmfQ3DH7/IzUB7VlBZK-cd8aN7YqiFrYRLkBUv7H0QkbqPxgf2dMgCMCwZaLMk9RUeMaBfx2lQ=Mq1EEJJw-Jp!BmpCDnhlc!6D22PaE=Y3sgWWNhRv8oP"
# ----------------------------------------------



Expand Down Expand Up @@ -255,7 +218,7 @@ hono:
addExampleData: false
mongoDBBasedDeviceRegistry:
mongodb:
host: opentwins-mongodb
host: '{{ .Release.Name }}-mongodb' # The values are processed via the 'tpl' function here in Eclipse Hono helm, allowing the inclusion of the release name
port: 27017
dbName: hono
hono:
Expand All @@ -274,4 +237,36 @@ hono:
amqp:
hono:
amqp:
insecurePortEnabled: true
insecurePortEnabled: true



# OpenTwins recommended values for ertis MongoDB
##################################################################
OpenTwins-MongoDB:
enabled: false # Value added by OpenTwins to indicate if this component should be installed or not
nameOverride: mongodb
auth:
enabled: false
securityContext:
enabled: false
persistence:
enabled: false
metadata:
labels:
app: database
selector: mongodb
service:
type: NodePort
nodePort: 30717
spec:
containers:
- name: mongodb
image:
repository: mongo
tag: 4.4.6
# env:
# - name: MONGO_INITDB_ROOT_USERNAME
# value: admin
# - name: MONGO_INITDB_ROOT_PASSWORD
# value: password

0 comments on commit b5f0aaf

Please sign in to comment.