Commit c76300ac authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

CT-147: Align csp-proto to last skampi csp-proto.

parent 911e8127
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,5 +2,5 @@ apiVersion: v1
appVersion: "0.6.9"
description: A Helm chart for deploying the Mid_CSP.LMC devices on Kubernetes
name: csp-proto
version: 0.1.1
version: 0.2.0
icon: https://www.skatelescope.org/wp-content/uploads/2016/07/09545_NEW_LOGO_2014.png
+12 −0
Original line number Diff line number Diff line
@@ -6,6 +6,18 @@ Expand the name of the chart.
{{- 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).
+69 −30
Original line number Diff line number Diff line
@@ -5,17 +5,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
  name: "csp-proto-configuration-json-{{ template "csp-proto.name" . }}-{{ .Release.Name }}"
  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
    /usr/local/bin/wait-for-it.sh databaseds-tango-base-{{ .Release.Name }}:10000 \
      --timeout=30 \
      --strict \
      -- json2tango -w -a -u data/cspconfig.json
    json2tango -w -a -u data/cspconfig.json
    rc=$?
    if [ $rc -eq 0 ]; then
      echo "finished normally."
@@ -35,12 +38,29 @@ data:
apiVersion: batch/v1
kind: Job
metadata:
  name: midcsplmc-configurator-{{ template "csp-proto.name" . }}-{{ .Release.Name }}
  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 }}"
@@ -50,7 +70,7 @@ spec:
          - data/bootstrap.sh
        env:
        - name: TANGO_HOST
          value: databaseds-tango-base-{{ .Release.Name }}:10000
          value: {{ if .Values.tangoDatabaseDS -}} {{ .Values.tangoDatabaseDS }}:10000 {{- else -}} databaseds-tango-base-{{ .Release.Name }}:10000 {{- end }}
        volumeMounts:
          - name: configuration
            mountPath: data
@@ -58,7 +78,7 @@ spec:
      volumes:
        - name: configuration
          configMap:
            name: "csp-proto-configuration-json-{{ template "csp-proto.name" . }}-{{ .Release.Name }}"
            name: "{{ template "csp-proto.name" . }}-configuration"
      restartPolicy: Never

{{- $global := . }}
@@ -69,13 +89,15 @@ spec:
apiVersion: v1
kind: Service
metadata:
  name: midcsplmc-{{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
  name: {{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}
  namespace: {{ $global.Release.Namespace }}
  labels:
    app: midcsplmc-{{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
    chart: {{ template "csp-proto.chart" $global }}
    release: {{ $global.Release.Name }}
    heritage: {{ $global.Release.Service }}
    {{- 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:
@@ -83,39 +105,56 @@ spec:
    port: 1234
    targetPort: 1234
  selector:
    app: midcsplmc-{{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
    chart: {{ template "csp-proto.chart" $global }}
    release: {{ $global.Release.Name }}
    subsystem: {{ $global.Values.subsystem }}
    component: {{ $deviceserver.name }}

---
# Single Pod separate statefulset per Device Server
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: midcsplmc-{{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
  name: {{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}
  namespace: {{ $global.Release.Namespace }}
  labels:
    app: midcsplmc-{{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
    chart: {{ template "csp-proto.chart" $global }}
    release: {{ $global.Release.Name }}
    heritage: {{ $global.Release.Service }}
    {{- 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:
      app: midcsplmc-{{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
      chart: {{ template "csp-proto.chart" $global }}
      release: {{ $global.Release.Name }}
  serviceName: midcsplmc-{{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
      component: {{ $deviceserver.name }}
      subsystem: {{ $global.Values.subsystem }}
  serviceName: {{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}
  replicas: 1
  template:
    metadata:
      labels:
        app: midcsplmc-{{ template "csp-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
        chart: {{ template "csp-proto.chart" $global }}
        release: {{ $global.Release.Name }}
        heritage: {{ $global.Release.Service }}
        {{- 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 }}"
@@ -126,7 +165,7 @@ spec:
{{ toYaml $deviceserver.args | indent 10 }}
        env:
        - name: TANGO_HOST
          value: databaseds-tango-base-{{ $global.Release.Name }}:10000
          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 }}
+12 −1
Original line number Diff line number Diff line
@@ -5,7 +5,18 @@ Expand the name of the chart.
{{- define "cbf-proto.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "cbf-proto.labels" }}
app: {{ template "cbf-proto.name" . }}
chart: {{ template "cbf-proto.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
system: {{ .Values.system }}
subsystem: {{ .Values.subsystem }}
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).
+66 −30
Original line number Diff line number Diff line
@@ -4,17 +4,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
  name: "mid-cbf-configuration-json-{{ template "cbf-proto.name" . }}-{{ .Release.Name }}"
  name: "{{ template "cbf-proto.name" . }}-configuration"
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "cbf-proto.labels" . | indent 4 }}
    component: configurator
    function: deployment
    intent: enabling
    domain: self-configuration
data:
  midcbfconfig.json:
{{ (tpl (.Files.Glob "data/midcbfconfig.json").AsConfig . ) | indent 2  }}
  bootstrap.sh: |
    #/bin/sh
    /usr/local/bin/wait-for-it.sh databaseds-tango-base-{{ .Release.Name }}:10000 \
      --timeout=30 \
      --strict \
      -- json2tango -w -a -u data/midcbfconfig.json
    json2tango -w -a -u data/midcbfconfig.json
    rc=$?
    if [ $rc -eq 0 ]; then
      echo "finished normally."
@@ -34,12 +37,29 @@ data:
apiVersion: batch/v1
kind: Job
metadata:
  name: mid-cbf-configurator-{{ template "cbf-proto.name" . }}-{{ .Release.Name }}
  name: {{ template "cbf-proto.name" . }}-configurator
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "cbf-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 }}"
@@ -49,7 +69,7 @@ spec:
          - data/bootstrap.sh
        env:
        - name: TANGO_HOST
          value: databaseds-tango-base-{{ .Release.Name }}:10000
          value: {{ if .Values.tangoDatabaseDS -}} {{ .Values.tangoDatabaseDS }}:10000 {{- else -}} databaseds-tango-base-{{ .Release.Name }}:10000 {{- end }}
        volumeMounts:
          - name: configuration
            mountPath: data
@@ -57,7 +77,7 @@ spec:
      volumes:
        - name: configuration
          configMap:
            name: "mid-cbf-configuration-json-{{ template "cbf-proto.name" . }}-{{ .Release.Name }}"
            name: "{{ template "cbf-proto.name" . }}-configuration"
      restartPolicy: Never

{{- $global := . }}
@@ -68,13 +88,14 @@ spec:
apiVersion: v1
kind: Service
metadata:
  name: mid-cbf-{{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
  name: {{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}
  namespace: {{ $global.Release.Namespace }}
  labels:
    app: mid-cbf-{{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
    chart: {{ template "cbf-proto.chart" $global }}
    release: {{ $global.Release.Name }}
    heritage: {{ $global.Release.Service }}
    {{- include "cbf-proto.labels" $global | indent 4 }}
    component: {{ $deviceserver.name }}
    function: {{ $deviceserver.function }}
    domain: {{ $deviceserver.domain }}
    intent: production 
spec:
  clusterIP: None
  ports:
@@ -82,39 +103,54 @@ spec:
    port: 1234
    targetPort: 1234
  selector:
    app: mid-cbf-{{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
    chart: {{ template "cbf-proto.chart" $global }}
    release: {{ $global.Release.Name }}
    subsystem: {{ $global.Values.subsystem }}
    component: {{ $deviceserver.name }}

---
# Single Pod separate statefulset per Device Server
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mid-cbf-{{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
  name: {{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}
  namespace: {{ $global.Release.Namespace }}
  labels:
    app: mid-cbf-{{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
    chart: {{ template "cbf-proto.chart" $global }}
    release: {{ $global.Release.Name }}
    heritage: {{ $global.Release.Service }}
    {{- include "cbf-proto.labels" $global | indent 4 }}
    component: {{ $deviceserver.name }}
    function: {{ $deviceserver.function }}
    domain: {{ $deviceserver.domain }}
    intent: production 
spec:
  selector:
    matchLabels:
      app: mid-cbf-{{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
      chart: {{ template "cbf-proto.chart" $global }}
      release: {{ $global.Release.Name }}
  serviceName: mid-cbf-{{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
      component: {{ $deviceserver.name }}
      subsystem: {{ $global.Values.subsystem }}
  serviceName: {{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}
  replicas: 1
  template:
    metadata:
      labels:
        app: mid-cbf-{{ template "cbf-proto.name" $global }}-{{ $deviceserver.name }}-{{ $global.Release.Name }}
        chart: {{ template "cbf-proto.chart" $global }}
        release: {{ $global.Release.Name }}
        heritage: {{ $global.Release.Service }}
        {{- include "cbf-proto.labels" $global | indent 8 }}
        component: {{ $deviceserver.name }}
        function: {{ $deviceserver.function }}
        domain: {{ $deviceserver.domain }}
        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_cbf/sub_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.midcbfmcs.image.registry }}/{{ $global.Values.midcbfmcs.image.image }}:{{ $global.Values.midcbfmcs.image.tag }}"
@@ -125,7 +161,7 @@ spec:
{{ toYaml $deviceserver.args | indent 10 }}
        env:
        - name: TANGO_HOST
          value: databaseds-tango-base-{{ $global.Release.Name }}:10000
          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 }}
Loading