Skip to content
Snippets Groups Projects
Commit 179e8a60 authored by Matteo Di Carlo's avatar Matteo Di Carlo
Browse files
parent 82f2b038
No related branches found
No related tags found
No related merge requests found
{{ if .Values.itango.enabled }} {{- if .Values.itango.enabled }}
{{ $default_tango_host := printf "%s-%s" "databaseds-tango-base-" .Release.Name }} {{- $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) . }} {{- $tango_host := tpl (coalesce .Values.global.tango_host .Values.tango_host $default_tango_host | toString) . }}
{{ $dsconfig := coalesce .Values.global.dsconfig .Values.dsconfig}} {{- $dsconfig := coalesce .Values.global.dsconfig .Values.dsconfig}}
{{ $tries := coalesce .Values.global.tries 10}} {{- $tries := coalesce .Values.global.tries 10}}
{{ $sleep := coalesce .Values.global.sleep 5}} {{- $sleep := coalesce .Values.global.sleep 5}}
--- ---
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
...@@ -16,10 +16,10 @@ metadata: ...@@ -16,10 +16,10 @@ metadata:
function: {{ .Values.itango.function }} function: {{ .Values.itango.function }}
domain: {{ .Values.itango.domain }} domain: {{ .Values.itango.domain }}
intent: {{ .Values.itango.intent }} intent: {{ .Values.itango.intent }}
{{ if or (.Values.global.annotations) (.Values.annotations) }} {{- if or (.Values.global.annotations) (.Values.annotations) }}
annotations: annotations:
{{ toYaml (coalesce .Values.global.annotations .Values.annotations) | indent 4 }} {{ toYaml (coalesce .Values.global.annotations .Values.annotations) | indent 4 }}
{{ end }} {{- end }}
spec: spec:
initContainers: initContainers:
- name: check-dependencies-0 - name: check-dependencies-0
...@@ -68,4 +68,4 @@ spec: ...@@ -68,4 +68,4 @@ spec:
{{ toYaml . | indent 4 }} {{ toYaml . | indent 4 }}
{{- end }} {{- end }}
{{ end }} {{- end }}
\ No newline at end of file
{{- if not .Values.global.operator }}
{{ if .Values.tangodb.enabled }} {{ if .Values.tangodb.enabled }}
{{ if .Values.tangodb.use_pv }} {{ if .Values.tangodb.use_pv }}
...@@ -53,3 +54,4 @@ spec: ...@@ -53,3 +54,4 @@ spec:
{{ end }} {{ end }}
{{ end }} {{ end }}
{{- end }}
\ No newline at end of file
{{ if .Values.tangodb.enabled }} {{- if .Values.tangodb.enabled }}
{{- if not .Values.global.operator }}
--- ---
apiVersion: v1 apiVersion: v1
...@@ -159,4 +160,5 @@ spec: ...@@ -159,4 +160,5 @@ spec:
{{ toYaml . | indent 8 }} {{ toYaml . | indent 8 }}
{{- end }} {{- end }}
{{ end }} {{- end }}
\ No newline at end of file {{- end }}
\ No newline at end of file
...@@ -17,19 +17,15 @@ Parameters are: ...@@ -17,19 +17,15 @@ Parameters are:
- local (the local chart) - local (the local chart)
*/}} */}}
{{ define "ska-tango-util.deviceserver-pvc.tpl" }} {{- define "ska-tango-util.deviceserver-pvc.tpl" }}
{{- /* replace with "if and .volume (not .volume.existingClaimName)" for Helm >= 3.10 */}}
---
{{/* replace with "if and .volume (not .volume.existingClaimName)" for Helm >= 3.10 */}}
{{- if .volume }} {{- if .volume }}
{{- if not .volume.existingClaimName }} {{- if not .volume.existingClaimName }}
{{- $volume_name := .volume.name }}
{{ $volume_name := .volume.name }} {{- $volume_path := .volume.mountPath }}
{{ $volume_path := .volume.mountPath }} {{- $volume_size := coalesce .volume.storage "250Mi" }}
{{ $volume_size := coalesce .volume.storage "250Mi" }} {{- $labels := coalesce .local.Values.global.labels .local.Values.labels "label:none" }}
{{ $labels := coalesce .local.Values.global.labels .local.Values.labels "label:none" }} {{- $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
{{ $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
--- ---
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
...@@ -38,16 +34,16 @@ metadata: ...@@ -38,16 +34,16 @@ metadata:
namespace: {{ .local.Release.Namespace }} namespace: {{ .local.Release.Namespace }}
labels: labels:
{{ toYaml $labels | indent 4 }} {{ toYaml $labels | indent 4 }}
{{ if $annotations }} {{- if $annotations }}
annotations: annotations:
{{ toYaml $annotations | indent 4 }} {{ toYaml $annotations | indent 4 }}
{{ end }} {{- end }}
spec: spec:
{{ if (coalesce .local.Values.global.minikube .local.Values.minikube false) }} {{- if (coalesce .local.Values.global.minikube .local.Values.minikube false) }}
storageClassName: standard storageClassName: standard
{{ else }} {{- else }}
storageClassName: nfss1 storageClassName: nfss1
{{ end }} {{- end }}
accessModes: accessModes:
- ReadWriteMany - ReadWriteMany
resources: resources:
...@@ -55,7 +51,6 @@ spec: ...@@ -55,7 +51,6 @@ spec:
storage: {{ $volume_size }} storage: {{ $volume_size }}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
...@@ -64,10 +59,10 @@ metadata: ...@@ -64,10 +59,10 @@ metadata:
{{ toYaml $labels | indent 4 }} {{ toYaml $labels | indent 4 }}
name: {{ $volume_name | toString }}-admin-{{ .local.Release.Name }} name: {{ $volume_name | toString }}-admin-{{ .local.Release.Name }}
namespace: {{ .local.Release.Namespace }} namespace: {{ .local.Release.Namespace }}
{{ if $annotations }} {{- if $annotations }}
annotations: annotations:
{{ toYaml $annotations | indent 4 }} {{ toYaml $annotations | indent 4 }}
{{ end }} {{- end }}
spec: spec:
replicas: 1 replicas: 1
selector: 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" }} {{ define "ska-tango-util.multidevice-config.tpl" }}
--- {{- $labels := coalesce .local.Values.global.labels .local.Values.labels "label: none" }}
{{ $labels := coalesce .local.Values.global.labels .local.Values.labels "label: none" }} {{- $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
{{ $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }} {{- $deviceserver := .deviceserver }}
{{ $deviceserver := .deviceserver }} {{- $deviceserver_name := tpl (coalesce .name .deviceserver.name | toString) .local }}
{{ $deviceserver_name := tpl (coalesce .name .deviceserver.name | toString) .local }} {{- $chart := .local }}
{{ $chart := .local }} {{- if not .local.Values.global.operator }}
--- ---
# Device Server configuration # Device Server configuration
...@@ -22,7 +22,6 @@ metadata: ...@@ -22,7 +22,6 @@ metadata:
annotations: annotations:
{{ toYaml $annotations | indent 4 }} {{ toYaml $annotations | indent 4 }}
data: data:
{{- if not .local.Values.global.operator }}
configuration.json: | configuration.json: |
{ {
"servers": { "servers": {
...@@ -115,42 +114,8 @@ data: ...@@ -115,42 +114,8 @@ data:
exit $rc exit $rc
fi fi
fi fi
{{- end }}
{{ $deviceserver.server.name }}.py: | {{ $deviceserver.server.name }}.py: |
import importlib {{- $context := dict "deviceserver" $deviceserver "DEBUG" $chart.Values.global.DEBUG }}
import importlib.util {{- include "ska-tango-util.entrypoints-script.tpl" $context | nindent 4}}
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 }}
{{- end }} {{- end }} # multidevice-config.tpl
\ No newline at end of file
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
...@@ -7,7 +7,6 @@ Parameters: ...@@ -7,7 +7,6 @@ Parameters:
- instance (of the device server) - instance (of the device server)
*/}} */}}
{{ define "ska-tango-util.operator-svc.tpl" }} {{ define "ska-tango-util.operator-svc.tpl" }}
---
{{- $labels := coalesce .local.Values.global.labels .local.Values.labels "label:none" }} {{- $labels := coalesce .local.Values.global.labels .local.Values.labels "label:none" }}
{{- $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }} {{- $annotations := coalesce .local.Values.global.annotations .local.Values.annotations }}
{{- $default_tango_host := printf "%s-%s:10000" "databaseds-tango-base-" .local.Release.Name }} {{- $default_tango_host := printf "%s-%s:10000" "databaseds-tango-base-" .local.Release.Name }}
...@@ -31,10 +30,10 @@ metadata: ...@@ -31,10 +30,10 @@ metadata:
function: {{ $deviceserver.function }} function: {{ $deviceserver.function }}
domain: {{ $deviceserver.domain }} domain: {{ $deviceserver.domain }}
subsystem: {{ $chart.Values.subsystem }} subsystem: {{ $chart.Values.subsystem }}
{{ if $annotations }} {{- if $annotations }}
annotations: annotations:
{{ toYaml $annotations | indent 4 }} {{ toYaml $annotations | indent 4 }}
{{ end }} {{- end }}
spec: spec:
{{- if or ($chart.Values.global.minikube) ($chart.Values.global.exposeAllDS) ($deviceserver.exposeDS) }} {{- if or ($chart.Values.global.minikube) ($chart.Values.global.exposeAllDS) ($deviceserver.exposeDS) }}
enableLoadBalancer: true enableLoadBalancer: true
...@@ -43,24 +42,19 @@ spec: ...@@ -43,24 +42,19 @@ spec:
image: "{{ tpl ($deviceserver.image.registry | toString) $chart }}/{{ tpl ($deviceserver.image.image | toString) $chart }}:{{ tpl ($deviceserver.image.tag | toString) $chart }}" 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 }} imagePullPolicy: {{ tpl ($deviceserver.image.pullPolicy | toString) $chart }}
args: "{{ $safe_instance | toString }}" args: "{{ $safe_instance | toString }}"
{{- if hasKey $deviceserver "volume" }}
volumes: volumes:
- name: configuration
configMap:
name: {{$deviceserver_name | toString }}-{{ $chart.Release.Name }}-dsconfig-json
{{ if hasKey $deviceserver "volume" }}
- name: volume-data - name: volume-data
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{ $deviceserver.volume.existingClaimName | default (printf "%s-pvc-%s" $deviceserver.volume.name $chart.Release.Name) }} claimName: {{ $deviceserver.volume.existingClaimName | default (printf "%s-pvc-%s" $deviceserver.volume.name $chart.Release.Name) }}
{{ end }} {{- end }}
{{- with $deviceserver.volume }}
volumeMounts: volumeMounts:
- name: configuration
mountPath: data
readOnly: true
{{ with $deviceserver.volume }}
- name: volume-data - name: volume-data
mountPath: {{ .mountPath }} mountPath: {{ .mountPath }}
readOnly: {{ (hasKey . "readOnly" | ternary .readOnly true) }}{{/* https://github.com/helm/helm/issues/3308 */}} readOnly: {{ (hasKey . "readOnly" | ternary .readOnly true) }}{{/* https://github.com/helm/helm/issues/3308 */}}
{{ end }} {{- end }}
dsname: "{{ $deviceserver_name }}"
config: | config: |
{ {
"servers": { "servers": {
...@@ -138,9 +132,11 @@ spec: ...@@ -138,9 +132,11 @@ spec:
} }
{{- $_ := unset $deviceserver "tmp_start_instance" }} {{- $_ := unset $deviceserver "tmp_start_instance" }}
{{- if $deviceserver.command }} {{- if $deviceserver.command }}
script: "{{ $deviceserver.command }}" command: "{{ $deviceserver.command }}"
{{- else }} {{- 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 }} {{- end }}
{{- if ($deviceserver.depends_on) }} {{- if ($deviceserver.depends_on) }}
dependsOn: dependsOn:
...@@ -178,10 +174,8 @@ spec: ...@@ -178,10 +174,8 @@ spec:
{{- with $chart.Values.tolerations }} {{- with $chart.Values.tolerations }}
tolerations: tolerations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }}
{{ end }} ## if has
{{ end }} # range instances {{- end }}
{{- end }} ## if has
{{ end }} # ska-tango-util.operator-svc.tpl {{- 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