Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

9.4 KB
Raw Blame
{{- include "manager.logging.validate" . }}
{{- include "manager.otel.validate" . }}
{{- $loggingInlineConfig := .Values.logging.config -}}
{{- $loggingExistingConfigMap := .Values.logging.existingConfigMap -}}
{{- $loggingEnabled := or $loggingInlineConfig $loggingExistingConfigMap -}}
{{- $loggingExternalConfig := $loggingExistingConfigMap -}}
{{- $webserver := .Values.or.webserver | default dict -}}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "manager.fullname" . }}
  labels:
    {{- include "manager.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  {{- with .Values.strategy }}
  strategy:
    {{- if eq .type "Recreate" }}
    type: Recreate
    # Recreate cannot have rollingUpdate settings. Existing deployments may need
    # a merge patch before a server-side apply upgrade (see test/load2-eks/README.md).
    rollingUpdate: null
    {{- else }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "manager.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- if or .Values.podAnnotations $loggingEnabled }}
      annotations:
        {{- with .Values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
        {{- if $loggingInlineConfig }}
        checksum/logging-config: {{ .Values.logging.config | sha256sum | quote }}
        {{- end }}
        {{- if and $loggingExternalConfig .Values.logging.restartToken }}
        logging.openremote.io/restart-token: {{ .Values.logging.restartToken | quote }}
        {{- end }}
      {{- end }}
      labels:
        {{- include "manager.labels" . | nindent 8 }}
        {{- with .Values.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "manager.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: {{ $webserver.listenPort | default 8080 }}
              protocol: TCP
          livenessProbe:
            {{- toYaml .Values.livenessProbe | nindent 12 }}
          readinessProbe:
            {{- toYaml .Values.readinessProbe | nindent 12 }}
          startupProbe:
            {{- toYaml .Values.startupProbe | nindent 12 }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
          env:
            - name: TZ
              value: "{{ .Values.or.timeZone }}"
            - name: OR_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: openremote-secret
                  key: admin-password
            - name: OR_HOSTNAME
              value: "{{ .Values.or.hostname }}"
            - name: OR_SSL_PORT
              value: "{{ .Values.or.port }}"

            {{- range $name, $value := dict
              "OR_WEBSERVER_LISTEN_HOST" $webserver.listenHost
              "OR_WEBSERVER_LISTEN_PORT" $webserver.listenPort
              "OR_WEBSERVER_ALLOWED_ORIGINS" $webserver.allowedOrigins
              "OR_WEBSERVER_ALLOWED_METHODS" $webserver.allowedMethods
              "OR_WEBSERVER_ALLOWED_HEADERS" $webserver.allowedHeaders
              "OR_WEBSERVER_EXPOSED_HEADERS" $webserver.exposedHeaders
              "OR_WEBSERVER_DUMP_REQUESTS" $webserver.dumpRequests
              "OR_WEBSERVER_WORKER_THREADS_MAX" $webserver.workerThreadsMax
              "OR_WEBSERVER_IO_THREADS_MAX" $webserver.ioThreadsMax
              "OR_WEBSERVER_MAX_ENTITY_SIZE" $webserver.maxEntitySize
              "OR_WEBSERVER_MULTIPART_MAX_ENTITY_SIZE" $webserver.multipartMaxEntitySize
            }}
            {{- if and (ne $value nil) (ne (toString $value) "") }}
            - name: {{ $name }}
              {{- /* YAML numbers may be floats; keep integer settings out of scientific notation. */}}
              {{- if kindIs "float64" $value }}
              value: {{ $value | toJson | quote }}
              {{- else }}
              value: {{ $value | quote }}
              {{- end }}
            {{- end }}
            {{- end }}

            - name: OR_FIREBASE_CONFIG_FILE
              value: "{{ .Values.or.firebaseConfigFile }}"

            - name: OR_DEV_MODE
              value: "{{ .Values.or.devMode }}"

            - name: OR_SETUP_RUN_ON_RESTART
              value: "{{ .Values.or.setupRunOnRestart }}"

            - name: OR_DB_VENDOR
              value: "{{ .Values.or.dbVendor }}"
            - name: OR_DB_HOST
              value: "{{ .Values.or.postgresql.host }}"
            - name: OR_DB_PORT
              value: "{{ .Values.or.postgresql.port }}"
            - name: OR_DB_NAME
              value: "{{ .Values.or.postgresql.database }}"
            - name: OR_DB_SCHEMA
              value: "{{ .Values.or.postgresql.schema }}"
            - name: OR_DB_USERNAME
              valueFrom:
                secretKeyRef:
                  name: openremote-secret
                  key: postgresql-username
            - name: OR_DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: openremote-secret
                  key: postgresql-password
            - name: OR_DB_POOL_MIN_SIZE
              value: "{{ .Values.or.postgresql.poolMinSize }}"
            - name: OR_DB_POOL_MAX_SIZE
              value: "{{ .Values.or.postgresql.poolMaxSize }}"
            - name: OR_DB_CONNECTION_TIMEOUT_SECONDS
              value: "{{ .Values.or.postgresql.connectionTimeoutSeconds }}"

            - name: OR_KEYCLOAK_HOST
              value: "{{ .Values.or.keycloak.host }}"
            - name: OR_KEYCLOAK_PORT
              value: "{{ .Values.or.keycloak.port }}"
            - name: OR_KEYCLOAK_PATH
              value: "{{ .Values.or.keycloak.path }}"

            - name: OR_APP_DOCROOT
              value: "{{ .Values.or.appDocroot }}"
            - name: OR_CUSTOM_APP_DOCROOT
              value: "{{ .Values.or.customAppDocroot }}"
            - name: OR_PROVISIONING_DOCROOT
              value: "{{ .Values.or.provisioningDocroot }}"
            - name: OR_ROOT_REDIRECT_PATH
              value: "{{ .Values.or.rootRedirectPath }}"

            - name: OR_MAP_TILES_PATH
              value: "{{ .Values.or.mapTilesPath }}"
            - name: OR_MAP_SETTINGS_PATH
              value: "{{ .Values.or.mapSettingsPath }}"

            - name: OR_IDENTITY_PROVIDER
              value: "{{ .Values.or.identityProvider }}"
            - name: OR_IDENTITY_SESSION_MAX_MINUTES
              value: "{{ .Values.or.identitySessionMaxMinutes }}"
            - name: OR_IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES
              value: "{{ .Values.or.identitySessionOfflineTimeoutMinutes }}"

            - name: OR_METRICS_ENABLED
              value: "{{ .Values.or.metricsEnabled }}"
            - name: OR_METRICS_PORT
              value: "{{ .Values.or.metricsPort }}"

            {{- if .Values.or.otel.enabled }}
            - name: OTEL_JAVAAGENT_ENABLED
              value: "true"
            - name: OTEL_SERVICE_NAME
              value: {{ .Values.or.otel.serviceName | quote }}
            - name: OTEL_TRACES_EXPORTER
              value: "otlp"
            - name: OTEL_EXPORTER_OTLP_ENDPOINT
              value: {{ .Values.or.otel.endpoint | quote }}
            - name: OTEL_EXPORTER_OTLP_PROTOCOL
              value: {{ .Values.or.otel.protocol | quote }}
            - name: OTEL_METRICS_EXPORTER
              value: "none"
            - name: OTEL_LOGS_EXPORTER
              value: "none"
            - name: OTEL_INSTRUMENTATION_COMMON_DB_STATEMENT_SANITIZER_ENABLED
              value: "true"
            {{- end }}

            {{- if $loggingEnabled }}
            - name: OR_LOGGING_CONFIG_FILE
              value: "{{ include "manager.logging.configFilePath" . }}"
            {{- end }}
          {{- with .Values.or.env }}
            {{- toYaml . | nindent 12 }}
          {{- end }}
          volumeMounts:
            {{- if $loggingEnabled }}
            - name: volume-logging-config
              mountPath: /etc/openremote/logging
              readOnly: true
            {{- end }}
            - mountPath: /storage
              name: manager-data
          {{- with .Values.volumeMounts }}
            {{- toYaml . | nindent 12 }}
          {{- end }}
      volumes:
        {{- if $loggingEnabled }}
        - name: volume-logging-config
          configMap:
            name: {{ include "manager.logging.configMapRefName" . }}
            items:
              - key: {{ include "manager.logging.configMapKey" . | quote }}
                path: logging.properties
        {{- end }}
        - name: manager-data
          persistentVolumeClaim:
            claimName: {{ include "manager.persistence.claimName" . }}
      {{- with .Values.volumes }}
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}