Skip to content
Snippets Groups Projects
Commit 179e8a60 authored by Matteo Di Carlo's avatar Matteo Di Carlo
Browse files
parent 82f2b038
Branches
Tags
No related merge requests found
{{ if .Values.itango.enabled }}
{{ $default_tango_host := printf "%s-%s" "databaseds-tango-base-" .Release.Name }}
{{ $tango_host := tpl (coalesce .Values.global.tango_host .Values.tango_host $default_tango_host | toString) . }}
{{ $dsconfig := coalesce .Values.global.dsconfig .Values.dsconfig}}
{{ $tries := coalesce .Values.global.tries 10}}
{{ $sleep := coalesce .Values.global.sleep 5}}
{{- if .Values.itango.enabled }}
{{- $default_tango_host := printf "%s-%s" "databaseds-tango-base-" .Release.Name }}
{{- $tango_host := tpl (coalesce .Values.global.tango_host .Values.tango_host $default_tango_host | toString) . }}
{{- $dsconfig := coalesce .Values.global.dsconfig .Values.dsconfig}}
{{- $tries := coalesce .Values.global.tries 10}}
{{- $sleep := coalesce .Values.global.sleep 5}}
---
apiVersion: v1
kind: Pod
......@@ -16,10 +16,10 @@ metadata:
function: {{ .Values.itango.function }}
domain: {{ .Values.itango.domain }}
intent: {{ .Values.itango.intent }}
{{ if or (.Values.global.annotations) (.Values.annotations) }}
{{- if or (.Values.global.annotations) (.Values.annotations) }}
annotations:
{{ toYaml (coalesce .Values.global.annotations .Values.annotations) | indent 4 }}
{{ end }}
{{- end }}
spec:
initContainers:
- name: check-dependencies-0
......@@ -68,4 +68,4 @@ spec:
{{ toYaml . | indent 4 }}
{{- end }}
{{ end }}
{{- end }}
\ No newline at end of file
{{- if not .Values.global.operator }}
{{ if .Values.tangodb.enabled }}
{{ if .Values.tangodb.use_pv }}
......@@ -53,3 +54,4 @@ spec:
{{ end }}
{{ end }}
{{- end }}
\ No newline at end of file
{{ if .Values.tangodb.enabled }}
{{- if .Values.tangodb.enabled }}
{{- if not .Values.global.operator }}
---
apiVersion: v1
......@@ -159,4 +160,5 @@ spec:
{{ toYaml . | indent 8 }}
{{- end }}
{{ end }}
\ No newline at end of file
{{- end }}
{{- end }}
\ No newline at end of file
......@@ -17,19 +17,15 @@ Parameters are:
- local (the local chart)
*/}}
{{ define "ska-tango-util.deviceserver-pvc.tpl" }}
---
{{/* replace with "if and .volume (not .volume.existingClaimName)" for Helm >= 3.10 */}}
{{- define "ska-tango-util.deviceserver-pvc.tpl" }}
{{- /* replace with "if and .volume (not .volume.existingClaimName)" for Helm >= 3.10 */}}
{{- if .volume }}
{{- if not .volume.existingClaimName }}
{{ $volume_name := .volume.name }}
{{ $volume_path := .volume.mountPath }}
{{ $volume_size := coalesce .volume.storage "250Mi" }}
{{ $labels := coalesce .local.Values.global.labels .local.Values.labels "label:none" }}
{{ $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
{{- $volume_name := .volume.name }}
{{- $volume_path := .volume.mountPath }}
{{- $volume_size := coalesce .volume.storage "250Mi" }}
{{- $labels := coalesce .local.Values.global.labels .local.Values.labels "label:none" }}
{{- $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
---
apiVersion: v1
kind: PersistentVolumeClaim
......@@ -38,16 +34,16 @@ metadata:
namespace: {{ .local.Release.Namespace }}
labels:
{{ toYaml $labels | indent 4 }}
{{ if $annotations }}
{{- if $annotations }}
annotations:
{{ toYaml $annotations | indent 4 }}
{{ end }}
{{- end }}
spec:
{{ if (coalesce .local.Values.global.minikube .local.Values.minikube false) }}
{{- if (coalesce .local.Values.global.minikube .local.Values.minikube false) }}
storageClassName: standard
{{ else }}
{{- else }}
storageClassName: nfss1
{{ end }}
{{- end }}
accessModes:
- ReadWriteMany
resources:
......@@ -55,7 +51,6 @@ spec:
storage: {{ $volume_size }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
......@@ -64,10 +59,10 @@ metadata:
{{ toYaml $labels | indent 4 }}
name: {{ $volume_name | toString }}-admin-{{ .local.Release.Name }}
namespace: {{ .local.Release.Namespace }}
{{ if $annotations }}
{{- if $annotations }}
annotations:
{{ toYaml $annotations | indent 4 }}
{{ end }}
{{- end }}
spec:
replicas: 1
selector:
......
{{- /*
tango-util.entrypoints-script.tpl
Parameters:
- deviceserver (the deviceserver entire yaml tag)
- DEBUG (number: activate debugpy at this port; leave empty otherwise)
*/}}
{{- define "ska-tango-util.entrypoints-script.tpl" }}
#!/usr/bin/env python
import importlib
import importlib.util
from tango.server import run
classes = []
{{- range $entrypoint := .deviceserver.entrypoints }}
splitted_name = str(" {{ $entrypoint.name }} ").split(sep='.')
module_name = ".".join(splitted_name[:-1])
{{- if $entrypoint.path }}
spec = importlib.util.spec_from_file_location(module_name.strip(), "{{ $entrypoint.path }}")
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
myclass = getattr(mod, splitted_name[-1].strip())
if not myclass in classes:
classes.append(myclass)
{{- else }}
mod = importlib.import_module(module_name.strip())
myclass = getattr(mod, splitted_name[-1].strip())
if not myclass in classes:
classes.append(myclass)
{{- end }}
{{- end }}
def main(args=None, **kwargs):
{{ if .DEBUG }}import debugpy; debugpy.listen({{ .DEBUG }}){{ end }}
return run(classes=(classes), args=args, **kwargs)
if __name__ == '__main__':
main()
{{- end }}
\ No newline at end of file
{{ define "ska-tango-util.multidevice-config.tpl" }}
---
{{ $labels := coalesce .local.Values.global.labels .local.Values.labels "label: none" }}
{{ $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
{{ $deviceserver := .deviceserver }}
{{ $deviceserver_name := tpl (coalesce .name .deviceserver.name | toString) .local }}
{{ $chart := .local }}
{{- $labels := coalesce .local.Values.global.labels .local.Values.labels "label: none" }}
{{- $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
{{- $deviceserver := .deviceserver }}
{{- $deviceserver_name := tpl (coalesce .name .deviceserver.name | toString) .local }}
{{- $chart := .local }}
{{- if not .local.Values.global.operator }}
---
# Device Server configuration
......@@ -22,7 +22,6 @@ metadata:
annotations:
{{ toYaml $annotations | indent 4 }}
data:
{{- if not .local.Values.global.operator }}
configuration.json: |
{
"servers": {
......@@ -115,42 +114,8 @@ data:
exit $rc
fi
fi
{{- end }}
{{ $deviceserver.server.name }}.py: |
import importlib
import importlib.util
from tango.server import run
classes = []
{{- range $entrypoint := $deviceserver.entrypoints }}
splitted_name = str(" {{ $entrypoint.name }} ").split(sep='.')
module_name = ".".join(splitted_name[:-1])
{{- if $entrypoint.path }}
spec = importlib.util.spec_from_file_location(module_name.strip(), "{{ $entrypoint.path }}")
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
myclass = getattr(mod, splitted_name[-1].strip())
if not myclass in classes:
classes.append(myclass)
{{- else }}
mod = importlib.import_module(module_name.strip())
myclass = getattr(mod, splitted_name[-1].strip())
if not myclass in classes:
classes.append(myclass)
{{- $context := dict "deviceserver" $deviceserver "DEBUG" $chart.Values.global.DEBUG }}
{{- include "ska-tango-util.entrypoints-script.tpl" $context | nindent 4}}
{{- end }}
{{- end }}
def main(args=None, **kwargs):
{{ if $chart.Values.global.DEBUG }}import debugpy; debugpy.listen({{ $chart.Values.global.DEBUG }}){{ end }}
return run(classes=(classes), args=args, **kwargs)
if __name__ == '__main__':
main()
{{ end }} # multidevice-config.tpl
{{- end }} # multidevice-config.tpl
\ No newline at end of file
......@@ -7,7 +7,6 @@ Parameters:
- instance (of the device server)
*/}}
{{ define "ska-tango-util.operator-svc.tpl" }}
---
{{- $labels := coalesce .local.Values.global.labels .local.Values.labels "label:none" }}
{{- $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
{{- $default_tango_host := printf "%s-%s:10000" "databaseds-tango-base-" .local.Release.Name }}
......@@ -31,10 +30,10 @@ metadata:
function: {{ $deviceserver.function }}
domain: {{ $deviceserver.domain }}
subsystem: {{ $chart.Values.subsystem }}
{{ if $annotations }}
{{- if $annotations }}
annotations:
{{ toYaml $annotations | indent 4 }}
{{ end }}
{{- end }}
spec:
{{- if or ($chart.Values.global.minikube) ($chart.Values.global.exposeAllDS) ($deviceserver.exposeDS) }}
enableLoadBalancer: true
......@@ -43,24 +42,19 @@ spec:
image: "{{ tpl ($deviceserver.image.registry | toString) $chart }}/{{ tpl ($deviceserver.image.image | toString) $chart }}:{{ tpl ($deviceserver.image.tag | toString) $chart }}"
imagePullPolicy: {{ tpl ($deviceserver.image.pullPolicy | toString) $chart }}
args: "{{ $safe_instance | toString }}"
{{- if hasKey $deviceserver "volume" }}
volumes:
- name: configuration
configMap:
name: {{$deviceserver_name | toString }}-{{ $chart.Release.Name }}-dsconfig-json
{{ if hasKey $deviceserver "volume" }}
- name: volume-data
persistentVolumeClaim:
claimName: {{ $deviceserver.volume.existingClaimName | default (printf "%s-pvc-%s" $deviceserver.volume.name $chart.Release.Name) }}
{{ end }}
{{- end }}
{{- with $deviceserver.volume }}
volumeMounts:
- name: configuration
mountPath: data
readOnly: true
{{ with $deviceserver.volume }}
- name: volume-data
mountPath: {{ .mountPath }}
readOnly: {{ (hasKey . "readOnly" | ternary .readOnly true) }}{{/* https://github.com/helm/helm/issues/3308 */}}
{{ end }}
{{- end }}
dsname: "{{ $deviceserver_name }}"
config: |
{
"servers": {
......@@ -138,9 +132,11 @@ spec:
}
{{- $_ := unset $deviceserver "tmp_start_instance" }}
{{- if $deviceserver.command }}
script: "{{ $deviceserver.command }}"
command: "{{ $deviceserver.command }}"
{{- else }}
script: "/data/{{ $deviceserver.server.name }}.py"
script: |
{{- $context := dict "deviceserver" $deviceserver "DEBUG" $chart.Values.global.DEBUG }}
{{- include "ska-tango-util.entrypoints-script.tpl" $context | nindent 4 }}
{{- end }}
{{- if ($deviceserver.depends_on) }}
dependsOn:
......@@ -178,10 +174,8 @@ spec:
{{- with $chart.Values.tolerations }}
tolerations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{ end }} ## if has
{{ end }} # range instances
{{ end }} # ska-tango-util.operator-svc.tpl
{{- end }}
{{- end }} ## if has
{{- end }} # range instances
{{- end }} # ska-tango-util.operator-svc.tpl
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment