diff --git a/charts/smartmet-server/Chart.yaml b/charts/smartmet-server/Chart.yaml index 746bd28..89f4d83 100644 --- a/charts/smartmet-server/Chart.yaml +++ b/charts/smartmet-server/Chart.yaml @@ -2,17 +2,18 @@ apiVersion: v2 description: Helm chart for smartmet server home: "file" keywords: - - fmi - - smartmet +- fmi +- smartmet +- smartmet-server # dependencies: # - name: redis # repository: https://charts.bitnami.com/bitnami # version: 18.19.2 -# condition: redis.enabled +# condition: config.redis.enabled maintainers: - - email: admin@weatherproof.fi - name: fmi-build-bot - url: https://github.com/fmi-build-bot +- email: admin@weatherproof.fi + name: fmi-build-bot + url: https://github.com/fmi-build-bot name: smartmet-server type: application -version: 0.1.2 +version: 0.1.6 diff --git a/charts/smartmet-server/templates/deployment.yaml b/charts/smartmet-server/templates/deployment.yaml index bdec872..b0e86ef 100644 --- a/charts/smartmet-server/templates/deployment.yaml +++ b/charts/smartmet-server/templates/deployment.yaml @@ -15,25 +15,29 @@ spec: labels: app: {{ .Release.Name }} spec: - #TODO proper sa template - serviceAccountName: ptrace-sa-v1 + {{- if .Values.serviceAccount.enabled }} + serviceAccountName: {{ default "smartmet-server-serviceaccount" .Values.serviceAccount.name }} + {{- end }} securityContext: runAsNonRoot: true runAsGroup: 0 - # TODO proper pullsecret + {{- if .Values.image.pullSecret }} imagePullSecrets: - - name: fmi-openshift-pull-secret + - name: {{ .Values.image.pullSecret }} + {{- end }} #TODO only if using internal redis initContainers: + {{- if .Values.config.redis.enabled }} - name: wait-for-redis image: busybox command: ['/bin/sh', '-c'] args: - | - until echo quit | telnet {{ default "redis-master.smartmet-server-development" .Values.filesys2smartmet.config.redis.address }} {{ default 6379 .Values.filesys2smartmet.config.redis.port }} ; do + until echo quit | telnet {{ default (printf "redis-master.%s" .Release.Name) .Values.config.redis.address }} {{ default 6379 .Values.config.redis.port }} ; do echo 'waiting for database...' sleep 2 done + {{- end }} containers: - name: {{ .Release.Name }} securityContext: @@ -45,11 +49,11 @@ spec: - SYS_PTRACE resources: requests: - memory: 2Gi - cpu: 0.2 + memory: {{ default "8Gi" .Values.resources.requests.memory }} + cpu: {{ default "1" .Values.resources.requests.cpu }} limits: - memory: 8Gi - cpu: 1 + memory: {{ default "16Gi" .Values.resources.limits.memory }} + cpu: {{ default "2" .Values.resources.limits.cpu }} image: {{ .Values.image.repository }}:{{ .Values.image.tag }} {{- if .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }} @@ -71,52 +75,52 @@ spec: - name: FMINAMES_USER valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: FMINAMES_USER - name: FMINAMES_PASSWORD valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: FMINAMES_PW - name: FMINAMES_HOST valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: FMINAMES_HOST - name: FMINAMES_PORT valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: FMINAMES_PORT - name: FMINAMES_DATABASE valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: FMINAMES_DATABASE - name: GIS_USER valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: GIS_USER - name: GIS_PASSWORD valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: GIS_PW - name: GIS_HOST valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: GIS_HOST - name: GIS_PORT valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: GIS_PORT - name: GIS_DATABASE valueFrom: secretKeyRef: - name: smartmet-server-sealedsecrets + name: {{ .Values.secrets.name }} key: GIS_DATABASE volumeMounts: - name: smartmet-main-configuration diff --git a/charts/smartmet-server/templates/filesys2smartmet/filesys2smartmet-deployment.yaml b/charts/smartmet-server/templates/filesys2smartmet/filesys2smartmet-deployment.yaml index 498c492..00b927a 100644 --- a/charts/smartmet-server/templates/filesys2smartmet/filesys2smartmet-deployment.yaml +++ b/charts/smartmet-server/templates/filesys2smartmet/filesys2smartmet-deployment.yaml @@ -1,3 +1,4 @@ +{{- if .Values.filesys2smartmet.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -15,25 +16,28 @@ spec: labels: app: {{ .Release.Name }} spec: - #TODO SA definition template - serviceAccountName: ptrace-sa-v1 + {{- if .Values.serviceAccount.enabled }} + serviceAccountName: {{ default "smartmet-server-serviceaccount" .Values.serviceAccount.name }} + {{- end }} securityContext: runAsNonRoot: true runAsGroup: 0 - #TODO Pull secret templating + {{- if .Values.image.pullSecret }} imagePullSecrets: - - name: fmi-openshift-pull-secret - #TODO only if using internal redis + - name: {{ .Values.image.pullSecret }} + {{- end }} initContainers: + {{- if .Values.config.redis.enabled }} - name: wait-for-redis image: busybox command: ['/bin/sh', '-c'] args: - | - until echo quit | telnet {{ default "redis-master.{{ .Release.Name }}" .Values.filesys2smartmet.config.redis.address }} {{ default 6379 .Values.filesys2smartmet.config.redis.port }} ; do + until echo quit | telnet {{ default (printf "redis-master.%s" .Release.Name) .Values.config.redis.address }} {{ default 6379 .Values.config.redis.port }} ; do echo 'waiting for database...' sleep 2 done + {{- end }} containers: - name: filesys2smartmet securityContext: @@ -43,11 +47,11 @@ spec: - SYS_PTRACE resources: requests: - memory: 2Gi - cpu: 0.2 + memory: {{ default "8Gi" .Values.resources.requests.memory }} + cpu: {{ default "1" .Values.resources.requests.cpu }} limits: - memory: 8Gi - cpu: 1 + memory: {{ default "16Gi" .Values.resources.limits.memory }} + cpu: {{ default "2" .Values.resources.limits.cpu }} image: {{ .Values.filesys2smartmet.image.repository }}:{{ .Values.filesys2smartmet.image.tag }} {{- if .Values.filesys2smartmet.image.pullPolicy }} imagePullPolicy: {{ .Values.filesys2smartmet.image.pullPolicy }} @@ -55,11 +59,11 @@ spec: command: ["/usr/bin/fmi/filesys2smartmet", "/config/filesys2smartmet.conf", "{{ default 60 .Values.filesys2smartmet.config.loopInterval}}" ] env: - name: REDIS_CONTENT_SERVER_ADDRESS - value: "{{ default "redis-master.{{ .Release.Name }}" .Values.filesys2smartmet.config.redis.address }}" + value: "{{ default "redis-master.{{ .Release.Name }}" .Values.config.redis.address }}" - name: REDIS_CONTENT_SERVER_PORT - value: "{{ default 6379 .Values.filesys2smartmet.config.redis.port }}" + value: "{{ default 6379 .Values.config.redis.port }}" - name: REDIS_CONTENT_SERVER_TABLE_PREFIX - value: "{{ default "smartmet." .Values.filesys2smartmet.config.redis.tablePrefix }}" + value: "{{ default "smartmet." .Values.config.redis.tablePrefix }}" volumeMounts: - name: filesys2smartmet-config mountPath: "/config/filesys2smartmet.conf" @@ -70,17 +74,16 @@ spec: - name: filesys2smartmet-producerdef-config mountPath: "/config/libraries/grid-tools/producerDef.csv" subPath: "producerDef.csv" - {{- if and .Values.pvc.name .Values.pvc.mountPath }} + {{- if and .Values.pvc.name .Values.pvc.mountPath }} - name: {{ .Values.pvc.name }} mountPath: {{ .Values.pvc.mountPath }} - {{- end }} - - volumes: - {{- if and .Values.pvc.name .Values.pvc.claimName }} + {{- end }} + volumes: + {{- if and .Values.pvc.name .Values.pvc.claimName }} - name: {{ .Values.pvc.name }} persistentVolumeClaim: claimName: {{ .Values.pvc.claimName }} - {{- end }} + {{- end }} - name: filesys2smartmet-config configMap: name: filesys2smartmet-config @@ -99,3 +102,4 @@ spec: items: - key: producerdef path: producerDef.csv +{{- end }} \ No newline at end of file diff --git a/charts/smartmet-server/templates/gitsync/wms-gitsync.yaml b/charts/smartmet-server/templates/gitsync/wms-gitsync.yaml new file mode 100644 index 0000000..904f403 --- /dev/null +++ b/charts/smartmet-server/templates/gitsync/wms-gitsync.yaml @@ -0,0 +1,42 @@ +{{- if not .Values.config.plugins.wms.disabled }} +# apiVersion: apps/v1 +# kind: Deployment +# metadata: +# name: {{ .Release.name }}-wms-layer-git-sync +# spec: +# replicas: 1 +# selector: +# matchLabels: +# app: {{ .Release.Name }} +# template: +# metadata: +# labels: +# app: {{ .Release.Name }} +# spec: +# securityContext: +# # Set this to any valid GID, and two things happen: +# # 1) The volume "content-from-git" is group-owned by this GID. +# # 2) This GID is added to each container. +# fsGroup: 0 +# volumes: +# - name: wms-layers +# emptyDir: {} +# containers: +# - name: git-sync +# # This container pulls git data and publishes it into volume +# # "content-from-git". In that volume you will find a symlink +# # "current" (see -dest below) which points to a checked-out copy of +# # the master branch (see -branch) of the repo (see -repo). +# # NOTE: git-sync already runs as non-root. +# image: registry.k8s.io/git-sync/git-sync:v4.0.0 +# args: +# - --repo={{ .Values.config.plugins.wms.gitSync.repository }} +# - --branch={{ .Values.config.plugins.wms.gitSync.branch }} +# - --depth=1 +# - --period={{ .Values.config.plugins.wms.gitSync.period }}s +# - --link=current +# - --root=/wms-layers +# volumeMounts: +# - name: wms-layers +# mountPath: /wms-layers +{{- end }} \ No newline at end of file diff --git a/charts/smartmet-server/templates/radon2smartmet/radon2smartmet-configuration.yaml b/charts/smartmet-server/templates/radon2smartmet/radon2smartmet-configuration.yaml new file mode 100644 index 0000000..f3bf303 --- /dev/null +++ b/charts/smartmet-server/templates/radon2smartmet/radon2smartmet-configuration.yaml @@ -0,0 +1,114 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: radon-to-smartmet-config +data: + configuration: | + ################################################################## + # smartmet-tools-grid : radon2smartmet + ################################################################## + + # This is a configuration file for "radon2smartmet" program. + # The program is used for synchronizing content information + # in the Redis database according to the information stored + # into the Radon database. + + ################################################################## + + # Importing global configuration parameters. There should be + # an environment variable SMARTMET_ENV_FILE that points to + # the global configuration file. The idea is that you can easily + # change your environment by editing this file. + + + # This information is needed for initializing the grid-library. + + smartmet.library.grid-files.configFile = "/config/libraries/grid-files/grid-files.conf" + + + + smartmet : + { + tools : + { + grid : + { + + + radon2smartmet : + { + # The "addFileInfoListWithContent" message can contain max this many records: + + maxMessageSize = 10000 + + + content-source : + { + # There might be different content sources that update information + # in the content server. That's why they should have an unique identifier. + + source-id = 100 + + + # This file contains a list of producer names which content is updated + # to the content server. + + producerFile = "$(RADON_PRODUCERFILE)" + + radon : + { + connection-string = "host=$(RADON_HOST) dbname=$(RADON_DATABASE) user=$(RADON_USER) password=$(RADON_PASSWORD)" + } + + } + + + content-storage : + { + # Content storage type (redis/corba/http) + + type = "redis" + + redis : + { + address = "$(REDIS_CONTENT_SERVER_ADDRESS)" + #address = "127.0.0.1" + port = $(REDIS_CONTENT_SERVER_PORT) + tablePrefix = "$(REDIS_CONTENT_SERVER_TABLE_PREFIX)" + } + + corba : + { + ior = "$(CORBA_CONTENT_SERVER_IOR)" + } + + http : + { + url = "$(HTTP_CONTENT_SERVER_URL)" + } + } + + processing-log : + { + enabled = false + file = "/dev/stdout" + # file = "$(GRID_TOOLS_LOG_DIR)/radon2smartmet_processing.log" + maxSize = 100000000 + truncateSize = 20000000 + } + + debug-log : + { + enabled = true + file = "/dev/stdout" + # file = "$(GRID_TOOLS_LOG_DIR)/radon2smartmet_debug.log" + maxSize = 100000000 + truncateSize = 20000000 + } + + } + + + } + } + } \ No newline at end of file diff --git a/charts/smartmet-server/templates/radon2smartmet/radon2smartmet-deployment.yaml b/charts/smartmet-server/templates/radon2smartmet/radon2smartmet-deployment.yaml new file mode 100644 index 0000000..a4b0c3a --- /dev/null +++ b/charts/smartmet-server/templates/radon2smartmet/radon2smartmet-deployment.yaml @@ -0,0 +1,102 @@ +{{ if .Values.radon2smartmet.enabled}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: radon2smartmet + labels: + app: {{ .Release.Name }} +spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: + app: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }} + spec: + {{- if .Values.serviceAccount.enabled }} + serviceAccountName: {{ default "smartmet-server-serviceaccount" .Values.serviceAccount.name }} + {{- end }} + securityContext: + runAsNonRoot: true + runAsGroup: 0 + {{- if .Values.image.pullSecret }} + imagePullSecrets: + - name: {{ .Values.image.pullSecret }} + {{- end }} + initContainers: + {{- if .Values.config.redis.enabled }} + - name: wait-for-redis + image: busybox + command: ['/bin/sh', '-c'] + args: + - | + until echo quit | telnet {{ default (printf "redis-master.%s" .Release.Name) .Values.config.redis.address }} {{ default 6379 .Values.config.redis.port }} ; do + echo 'waiting for database...' + sleep 2 + done + {{- end }} + containers: + - name: radon2smartmet + securityContext: + runAsGroup: 0 + capabilities: + add: + - SYS_PTRACE + resources: + requests: + memory: {{ default "8Gi" .Values.resources.requests.memory }} + cpu: {{ default "1" .Values.resources.requests.cpu }} + limits: + memory: {{ default "16Gi" .Values.resources.limits.memory }} + cpu: {{ default "2" .Values.resources.limits.cpu }} + image: {{ .Values.radon2smartmet.image.repository }}:{{ .Values.radon2smartmet.image.tag }} + {{- if .Values.radon2smartmet.image.pullPolicy }} + imagePullPolicy: {{ .Values.radon2smartmet.image.pullPolicy }} + {{- end }} + command: ["/usr/local/bin/run.sh", "{{ default 30 .Values.radon2smartmet.config.loopInterval}}" ] + env: + - name: REDIS_CONTENT_SERVER_ADDRESS + value: "{{ default "redis-master.{{ .Release.Name }}" .Values.config.redis.address }}" + - name: REDIS_CONTENT_SERVER_PORT + value: "{{ default 6379 .Values.config.redis.port }}" + - name: REDIS_CONTENT_SERVER_TABLE_PREFIX + value: "{{ default "smartmet." .Values.config.redis.tablePrefix }}" + - name: RADON_USER + valueFrom: + secretKeyRef: + name: smartmet-server-sealedsecrets + key: RADON_USER + - name: RADON_PASSWORD + valueFrom: + secretKeyRef: + name: smartmet-server-sealedsecrets + key: RADON_PASSWORD + - name: RADON_HOST + value: "{{ default "" .Values.radon2smartmet.config.radon.host }}" + - name: RADON_DATABASE + value: "{{ default "" .Values.radon2smartmet.config.radon.database }}" + - name: RADON_PRODUCERFILE + value: "{{ default "/config/libraries/tools-grid/producers.csv" .Values.radon2smartmet.config.radon.producerfile }}" + - name: GRID_FILES_LIBRARY_CONFIG_FILE + value: "{{ default "/config/libraries/grid-files/grid-files.conf" .Values.radon2smartmet.config.gridfiles.configFile }}" + - name: GRID_TOOLS_CONFIG_DIR + value: "/config" + - name: CORBA_CONTENT_SERVER_IOR + value: "" + - name: HTTP_CONTENT_SERVER_URL + value: "" + volumeMounts: + - name: radon-to-smartmet-config + mountPath: "/config/radon-to-smartmet.cfg" + subPath: "radon-to-smartmet.cfg" + volumes: + - name: radon-to-smartmet-config + configMap: + name: radon-to-smartmet-config + items: + - key: configuration + path: radon-to-smartmet.cfg +{{- end }} \ No newline at end of file diff --git a/charts/smartmet-server/values.yaml b/charts/smartmet-server/values.yaml index dc34f3b..d04df85 100644 --- a/charts/smartmet-server/values.yaml +++ b/charts/smartmet-server/values.yaml @@ -1,15 +1,30 @@ # Default values +image: + repository: quay.io/fmi/smartmet-server + pullPolicy: IfNotPresent + tag: 0.1.6 + pullSecret: fmi-openshift-pull-secret + # This applies both image and filesys2smartmet pvc: name: "" mountPath: "" claimName: "" -# TODO image should probably be renamed to smartmet-server? -image: - repository: quay.io/fmi/smartmet-server - pullPolicy: IfNotPresent - tag: 0.1.0 +secrets: + name: smartmet-server-sealedsecrets + +serviceAccount: + enabled: true + name: smartmet-server-serviceaccount + +resources: + requests: + memory: 8Gi + cpu: 1 + limits: + memory: 16Gi + cpu: 2 config: locale: "fi_FI.UTF-8" @@ -39,6 +54,9 @@ config: maxthreads: 5 maxrequeuesize: 50 redis: + # enable local redis + # if disabled must specify remote redis address and port + enabled: true address: "" port: 6379 tablePrefix: "smartmet." @@ -174,54 +192,58 @@ config: # reverse_mapping_function: Reverse mapping function # default_precision: Default precision mappings: - - name: "demo" - mapping_name: "TD-K" - parameter_id_type: 2 - parameter_id: "TD-K" - geometry_id: 1110 - level_id_type: 1 - level_id: 6 - level: "00002" - area_interpolation_method: 1 - time_interpolation_method: 1 - level_interpolation_method: 1 - group_flags: 0 - search_match: "E" - mapping_function: "" - reverse_mapping_function: "" - default_precision: "" + # - name: "demo" + # mapping_name: "TD-K" + # parameter_id_type: 2 + # parameter_id: "TD-K" + # geometry_id: 1110 + # level_id_type: 1 + # level_id: 6 + # level: "00002" + # area_interpolation_method: 1 + # time_interpolation_method: 1 + # level_interpolation_method: 1 + # group_flags: 0 + # search_match: "E" + # mapping_function: "" + # reverse_mapping_function: "" + # default_precision: "" producers: - - name: "demo" - abbreviation: "demo" - title: "demo-title" - description: "demo-desription" - geometryId: 1110 + # - name: "demo" + # abbreviation: "demo" + # title: "demo-title" + # description: "demo-desription" + # geometryId: 1110 logging: target: "stdout" directory: "" filesys2smartmet: + enabled: false image: repository: quay.io/fmi/smartmet-server pullPolicy: IfNotPresent tag: filesys2smartmet-0.1.0 - config: loopInterval: 60 memoryMapper: - enabled: true - redis: - address: "" - port: 6379 - tablePrefix: "smartmet." + enabled: false data: - - url: "/data/" - patterns: - - "*.nc" - - "*.grib" - - "*.grib2" - authentication: - enabled: false - type: "FS" + +# requires RADON_USER and RADON_PASSWORD in sealed secret +radon2smartmet: + enabled: false + image: + repository: quay.io/fmi/smartmet-server + pullPolicy: IfNotPresent + tag: radon2smartmet-0.0.1 + config: + loopInterval: 30 + radon: + host: "" + database: "" + gridfiles: + # TODO clean this + configFile: "/config/libraries/grid-files/grid-files.conf"