Commit 9e5b709a authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

tango-util: charts folder re-organizatio to implement charts and sub-charts

relying on tango-util library.
parent 541b0f4e
Loading
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
apiVersion: v1
appVersion: "0.6.9"
description: A Helm chart for deploying the Mid_CSP.LMC devices on Kubernetes
name: csp-proto
version: 0.2.2
icon: https://www.skatelescope.org/wp-content/uploads/2016/07/09545_NEW_LOGO_2014.png
+0 −1563

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −44
Original line number Diff line number Diff line
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "csp-proto.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "csp-proto.labels" }}
app: {{ template "csp-proto.name" . }}
chart: {{ template "csp-proto.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
system: {{ .Values.system }}
telescope: {{ .Values.telescope }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "csp-proto.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "csp-proto.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
+0 −186
Original line number Diff line number Diff line
{{ if .Values.csplmc.enabled }}

---
# Device Server configurations
apiVersion: v1
kind: ConfigMap
metadata:
  name: "{{ template "csp-proto.name" . }}-configuration"
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "csp-proto.labels" . | indent 4 }}
    component: configurator
    function: deployment
    intent: enabling
    domain: self-configuration
data:
  cspconfig.json:
{{ (tpl (.Files.Glob "data/cspconfig.json").AsConfig . ) | indent 2  }}
  bootstrap.sh: |
    #/bin/sh
    json2tango -w -a -u data/cspconfig.json
    rc=$?
    if [ $rc -eq 0 ]; then
      echo "finished normally."
      exit 0
    else
      if [ $rc -eq 2 ]; then
        echo "finished with an update."
        exit 0
      else
        echo "finished with an ERROR."
        exit $rc
      fi
    fi

---
# run once Job for loading Device Server config
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ template "csp-proto.name" . }}-configurator
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "csp-proto.labels" . | indent 4 }}
    component: configurator
    function: deployment
    intent: enabling
    domain: self-configuration
spec:
  ttlSecondsAfterFinished: 100
  template:
    spec:
      initContainers:
      - name: check-databaseds-ready
        image: "{{ .Values.dsconfig.image.registry }}/{{ .Values.dsconfig.image.image }}:{{ .Values.dsconfig.image.tag }}"
        imagePullPolicy: {{ .Values.dsconfig.image.pullPolicy }}
        command:
          - /usr/local/bin/wait-for-it.sh
          - {{ if .Values.tangoDatabaseDS -}} {{ .Values.tangoDatabaseDS }}:10000 {{- else -}} databaseds-tango-base-{{ .Release.Name }}:10000 {{- end }}
          - --timeout=180
          - --strict
          - --
          - echo databaseds ready
      containers:
      - name: dsconfig
        image: "{{ .Values.dsconfig.image.registry }}/{{ .Values.dsconfig.image.image }}:{{ .Values.dsconfig.image.tag }}"
        imagePullPolicy: {{ .Values.dsconfig.image.pullPolicy }}
        command: # exit code 2 is CONFIG_APPLIED - https://github.com/MaxIV-KitsControls/lib-maxiv-dsconfig/blob/master/dsconfig/utils.py#L11 !!!! this should not be an error !!!!
          - sh
          - data/bootstrap.sh
        env:
        - name: TANGO_HOST
          value: {{ if .Values.tangoDatabaseDS -}} {{ .Values.tangoDatabaseDS }}:10000 {{- else -}} databaseds-tango-base-{{ .Release.Name }}:10000 {{- end }}
        volumeMounts:
          - name: configuration
            mountPath: data
            readOnly: true
      volumes:
        - name: configuration
          configMap:
            name: "{{ template "csp-proto.name" . }}-configuration"
      restartPolicy: Never

{{- $global := . }}
{{- range $deviceserver := .Values.deviceServers }}

---
# giving a dummy Service entry ensures that the single pod is DNS addressable
apiVersion: v1
kind: Service
metadata:
  name: {{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}
  namespace: {{ $global.Release.Namespace }}
  labels:
    {{- include "csp-proto.labels" $global | indent 4 }}
    component: {{ $deviceserver.name }}
    function: {{ $deviceserver.function }}
    domain: {{ $deviceserver.domain }}
    subsystem: {{ $global.Values.subsystem }}
    intent: production
spec:
  clusterIP: None
  ports:
  - name: dummy # Actually, no port is needed.
    port: 1234
    targetPort: 1234
  selector:
    subsystem: {{ $global.Values.subsystem }}
    component: {{ $deviceserver.name }}

---
# Single Pod separate statefulset per Device Server
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: {{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}
  namespace: {{ $global.Release.Namespace }}
  labels:
    {{- include "csp-proto.labels" $global | indent 4 }}
    component: {{ $deviceserver.name }}
    function: {{ $deviceserver.function }}
    domain: {{ $deviceserver.domain }}
    subsystem: {{ $global.Values.subsystem }}
    intent: production 
spec:
  selector:
    matchLabels:
      component: {{ $deviceserver.name }}
      subsystem: {{ $global.Values.subsystem }}
  serviceName: {{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}
  replicas: 1
  template:
    metadata:
      labels:
        {{- include "csp-proto.labels" $global | indent 8 }}
        component: {{ $deviceserver.name }}
        function: {{ $deviceserver.function }}
        domain: {{ $deviceserver.domain }}
        subsystem: {{ $global.Values.subsystem }}
        intent: production
        cspServer: {{$deviceserver.name}}
    spec:
      initContainers:
      - name: check-databaseds-ready
        image: {{ $global.Values.dsconfig.image.registry }}/{{ $global.Values.dsconfig.image.image }}:{{ $global.Values.dsconfig.image.tag }}
        imagePullPolicy: {{ $global.Values.dsconfig.image.pullPolicy }}
        # 'tango_admin --check-device' will exit 0 once databaseds is alive and the dsconfig job is complete
        command:
          - retry
          - --max=10
          - --
          - tango_admin
          - --check-device
          - mid_csp/elt/master
        env:
        - name: TANGO_HOST
          value: {{ if $global.Values.tangoDatabaseDS -}} {{ $global.Values.tangoDatabaseDS }}:10000 {{- else -}} databaseds-tango-base-{{ $global.Release.Name }}:10000 {{- end }}
      containers:
      - name: deviceserver
        image: "{{ $global.Values.csplmc.image.registry }}/{{ $global.Values.csplmc.image.image }}:{{ $global.Values.csplmc.image.tag }}"
        imagePullPolicy: {{ $global.Values.csplmc.image.pullPolicy }}
        command:
          - sh
        args:
{{ toYaml $deviceserver.args | indent 10 }}
        env:
        - name: TANGO_HOST
          value: {{ if $global.Values.tangoDatabaseDS -}} {{ $global.Values.tangoDatabaseDS }}:10000 {{- else -}} databaseds-tango-base-{{ $global.Release.Name }}:10000 {{- end }}
        resources:
{{ toYaml $global.Values.resources | indent 10 }}
{{- with $global.Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with $global.Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with $global.Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
{{- end }}

{{- end }} # end of range

{{ end }}
+0 −81
Original line number Diff line number Diff line
# Default values for csp-proto.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

display: ":0"
xauthority: "~/.Xauthority"

system: csp
subsystem: csp-lmc
telescope: SKA-mid

csplmc:
  enabled: true
  image:
    registry: nexus.engageska-portugal.pt/ska-docker
    image: mid-csp-lmc
    tag: 0.6.9-dev
    pullPolicy: IfNotPresent

deviceServers:
  - name: midcapabilitymonitor
    function: csp-capability-monitoring
    domain: csp-monitoring
    args:
      - "-c"
      - "/venv/bin/python /app/csp_lmc_mid/MidCspCapabilityMonitor.py monitor"
  - name: midcspmaster
    function: csp-central-control
    domain: csp-monitoring
    args:
      - "-c"
      - "retry --max=20 -- tango_admin --ping-device mid_csp_cbf/sub_elt/master &&\
         retry --max=5 -- tango_admin --ping-device mid_csp/capability_monitor/search_beams &&\
         /venv/bin/python /app/csp_lmc_mid/MidCspMaster.py master"
  - name: midcspsubarray01
    function: csp-subarray-observation
    domain: subarray
    args:
      - "-c"
      - "retry --max=10 -- tango_admin --ping-device mid_csp/elt/master &&\
         retry --max=10 -- tango_admin --ping-device mid_csp_cbf/sub_elt/subarray_01 &&\
         /venv/bin/python /app/csp_lmc_mid/MidCspSubarray.py subarray1"
  - name: midcspsubarray02
    function: csp-subarray-observation
    domain: subarray
    args:
      - "-c"
      - "retry --max=10 -- tango_admin --ping-device mid_csp/elt/master &&\
         retry --max=10 -- tango_admin --ping-device mid_csp_cbf/sub_elt/subarray_02 &&\
         /venv/bin/python /app/csp_lmc_mid/MidCspSubarray.py subarray2"
  - name: midcspsubarray03
    function: csp-subarray-observation
    domain: subarray
    args:
      - "-c"
      - "retry --max=10 -- tango_admin --ping-device mid_csp/elt/master &&\
         retry --max=10 -- tango_admin --ping-device mid_csp_cbf/sub_elt/subarray_03 &&\
         /venv/bin/python /app/csp_lmc_mid/MidCspSubarray.py subarray3"

dsconfig:
  image:
    registry: nexus.engageska-portugal.pt/ska-docker
    image: tango-dsconfig
    tag: 1.2.5.1
    pullPolicy: IfNotPresent

nodeSelector: {}

affinity: {}

tolerations: []

resources:
  requests:
    cpu: 150m     # 150m = 0.15 CPU
    memory: 128Mi # 128Mi = 0.12 GB mem
    ephemeral-storage: 256Mi
  limits:
    cpu: 250m     # 250m = 0.25 CPU
    memory: 256Mi # 256Mi = 0.25 GB mem
    ephemeral-storage: 512Mi
Loading