Commit 226af08e authored by Radu Carpa's avatar Radu Carpa
Browse files

daemons: use local variable for accessing per-component values

This is to homogenize the templates. This way, in a longer term,
it should be easier to create a macros and avoid copy-pasted
code in almost 30 different templates
parent 5ea1218a
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
{{- if gt .Values.abacusAccountCount 0.0 -}}
{{- $rucio_daemon := "abacus-account" }}
{{- $component_values := .Values.abacusAccount }}
{{- $component_count := .Values.abacusAccountCount }}
{{- $app_label := printf "%s-%s" (include "rucio.name" .) $rucio_daemon }}
apiVersion: v1
kind: Secret
@@ -13,7 +15,7 @@ metadata:
type: Opaque
data:
  {{- $common_config := .Values.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := .Values.abacusAccount.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := $component_values.config | default dict | mustToPrettyJson | b64enc }}
  component.json: {{ $component_config | quote }}
---
apiVersion: apps/v1
@@ -27,7 +29,7 @@ metadata:
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.abacusAccountCount }}
  replicas: {{ $component_count }}
  selector:
    matchLabels:
      app: {{ $app_label }}
@@ -56,7 +58,7 @@ spec:
    {{- with .Values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.abacusAccount.podAnnotations }}
    {{- with $component_values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    spec:
@@ -78,7 +80,7 @@ spec:
        secret:
          secretName: {{ .Release.Name }}-rucio-ca-bundle
    {{- end }}
      {{- range $collection := tuple .Values.secretMounts .Values.abacusAccount.secretMounts .Values.additionalSecrets .Values.abacusAccount.additionalSecrets }}
      {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
      {{- range $key, $val := $collection }}
      - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
        secret:
@@ -107,7 +109,7 @@ spec:
            - name: config-component
              mountPath: /opt/rucio/etc/conf.d/20_component.json
              subPath: component.json
            {{- range $collection := tuple .Values.secretMounts .Values.abacusAccount.secretMounts .Values.additionalSecrets .Values.abacusAccount.additionalSecrets }}
            {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
            {{- range $key, $val := $collection }}
            - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
              mountPath: {{ $val.mountPath }}
@@ -128,20 +130,20 @@ spec:
            - name: RUCIO_DAEMON
              value: "{{ $rucio_daemon }}"
            - name: RUCIO_DAEMON_ARGS
              value: "--threads {{ .Values.abacusAccount.threads }}"
{{- with .Values.abacusAccount.resources }}
              value: "--threads {{ $component_values.threads }}"
{{- with $component_values.resources }}
          resources:
{{ toYaml . | trim | indent 12 }}
{{ end }}
{{- with .Values.abacusAccount.nodeSelector }}
{{- with $component_values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.abacusAccount.affinity }}
{{- with $component_values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.abacusAccount.tolerations }}
{{- with $component_values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
+12 −10
Original line number Diff line number Diff line
{{- if gt .Values.abacusCollectionReplicaCount 0.0 -}}
{{- $rucio_daemon := "abacus-collection-replica" }}
{{- $component_values := .Values.abacusCollectionReplica }}
{{- $component_count := .Values.abacusCollectionReplicaCount }}
{{- $app_label := printf "%s-%s" (include "rucio.name" .) $rucio_daemon }}
apiVersion: v1
kind: Secret
@@ -13,7 +15,7 @@ metadata:
type: Opaque
data:
  {{- $common_config := .Values.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := .Values.abacusCollectionReplica.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := $component_values.config | default dict | mustToPrettyJson | b64enc }}
  component.json: {{ $component_config | quote }}
---
apiVersion: apps/v1
@@ -27,7 +29,7 @@ metadata:
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.abacusCollectionReplicaCount }}
  replicas: {{ $component_count }}
  selector:
    matchLabels:
      app: {{ $app_label }}
@@ -56,7 +58,7 @@ spec:
    {{- with .Values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.abacusCollectionReplica.podAnnotations }}
    {{- with $component_values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    spec:
@@ -78,7 +80,7 @@ spec:
        secret:
          secretName: {{ .Release.Name }}-rucio-ca-bundle
    {{- end }}
      {{- range $collection := tuple .Values.secretMounts .Values.abacusCollectionReplica.secretMounts .Values.additionalSecrets .Values.abacusCollectionReplica.additionalSecrets }}
      {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
      {{- range $key, $val := $collection }}
      - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
        secret:
@@ -107,7 +109,7 @@ spec:
            - name: config-component
              mountPath: /opt/rucio/etc/conf.d/20_component.json
              subPath: component.json
            {{- range $collection := tuple .Values.secretMounts .Values.abacusCollectionReplica.secretMounts .Values.additionalSecrets .Values.abacusCollectionReplica.additionalSecrets }}
            {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
            {{- range $key, $val := $collection }}
            - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
              mountPath: {{ $val.mountPath }}
@@ -128,20 +130,20 @@ spec:
            - name: RUCIO_DAEMON
              value: "{{ $rucio_daemon }}"
            - name: RUCIO_DAEMON_ARGS
              value: "--threads {{ .Values.abacusCollectionReplica.threads }}"
{{- with .Values.abacusCollectionReplica.resources }}
              value: "--threads {{ $component_values.threads }}"
{{- with $component_values.resources }}
          resources:
{{ toYaml . | trim | indent 12 }}
{{ end }}
{{- with .Values.abacusCollectionReplica.nodeSelector }}
{{- with $component_values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.abacusCollectionReplica.affinity }}
{{- with $component_values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.abacusCollectionReplica.tolerations }}
{{- with $component_values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
+12 −10
Original line number Diff line number Diff line
{{- if gt .Values.abacusRseCount 0.0 -}}
{{- $rucio_daemon := "abacus-rse" }}
{{- $component_values := .Values.abacusRse }}
{{- $component_count := .Values.abacusRseCount }}
{{- $app_label := printf "%s-%s" (include "rucio.name" .) $rucio_daemon }}
apiVersion: v1
kind: Secret
@@ -13,7 +15,7 @@ metadata:
type: Opaque
data:
  {{- $common_config := .Values.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := .Values.abacusRse.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := $component_values.config | default dict | mustToPrettyJson | b64enc }}
  component.json: {{ $component_config | quote }}
---
apiVersion: apps/v1
@@ -27,7 +29,7 @@ metadata:
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.abacusRseCount }}
  replicas: {{ $component_count }}
  selector:
    matchLabels:
      app: {{ $app_label }}
@@ -56,7 +58,7 @@ spec:
    {{- with .Values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.abacusRse.podAnnotations }}
    {{- with $component_values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    spec:
@@ -78,7 +80,7 @@ spec:
        secret:
          secretName: {{ .Release.Name }}-rucio-ca-bundle
    {{- end }}
      {{- range $collection := tuple .Values.secretMounts .Values.abacusRse.secretMounts .Values.additionalSecrets .Values.abacusRse.additionalSecrets }}
      {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
      {{- range $key, $val := $collection }}
      - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
        secret:
@@ -107,7 +109,7 @@ spec:
            - name: config-component
              mountPath: /opt/rucio/etc/conf.d/20_component.json
              subPath: component.json
            {{- range $collection := tuple .Values.secretMounts .Values.abacusRse.secretMounts .Values.additionalSecrets .Values.abacusRse.additionalSecrets }}
            {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
            {{- range $key, $val := $collection }}
            - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
              mountPath: {{ $val.mountPath }}
@@ -128,20 +130,20 @@ spec:
            - name: RUCIO_DAEMON
              value: "{{ $rucio_daemon }}"
            - name: RUCIO_DAEMON_ARGS
              value: "{{- if .Values.abacusRse.fillHistoryTable }}--enable-history {{ end }}--threads {{ .Values.abacusRse.threads }}"
{{- with .Values.abacusRse.resources }}
              value: "{{- if $component_values.fillHistoryTable }}--enable-history {{ end }}--threads {{ $component_values.threads }}"
{{- with $component_values.resources }}
          resources:
{{ toYaml . | trim | indent 12 }}
{{ end }}
{{- with .Values.abacusRse.nodeSelector }}
{{- with $component_values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.abacusRse.affinity }}
{{- with $component_values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.abacusRse.tolerations }}
{{- with $component_values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
+12 −10
Original line number Diff line number Diff line
{{- if gt .Values.automatixCount 0.0 -}}
{{- $rucio_daemon := "automatix" }}
{{- $component_values := .Values.automatix }}
{{- $component_count := .Values.automatixCount }}
{{- $app_label := printf "%s-%s" (include "rucio.name" .) $rucio_daemon }}
apiVersion: v1
kind: Secret
@@ -13,7 +15,7 @@ metadata:
type: Opaque
data:
  {{- $common_config := .Values.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := .Values.automatix.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := $component_values.config | default dict | mustToPrettyJson | b64enc }}
  component.json: {{ $component_config | quote }}
---
apiVersion: apps/v1
@@ -27,7 +29,7 @@ metadata:
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.automatixCount }}
  replicas: {{ $component_count }}
  selector:
    matchLabels:
      app: {{ $app_label }}
@@ -56,7 +58,7 @@ spec:
    {{- with .Values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.automatix.podAnnotations }}
    {{- with $component_values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    spec:
@@ -81,7 +83,7 @@ spec:
        secret:
          secretName: {{ .Release.Name }}-rucio-ca-bundle-reaper
    {{- end }}
      {{- range $collection := tuple .Values.secretMounts .Values.automatix.secretMounts .Values.additionalSecrets .Values.automatix.additionalSecrets }}
      {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
      {{- range $key, $val := $collection }}
      - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
        secret:
@@ -112,7 +114,7 @@ spec:
            - name: config-component
              mountPath: /opt/rucio/etc/conf.d/20_component.json
              subPath: component.json
            {{- range $collection := tuple .Values.secretMounts .Values.automatix.secretMounts .Values.additionalSecrets .Values.automatix.additionalSecrets }}
            {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
            {{- range $key, $val := $collection }}
            - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
              mountPath: {{ $val.mountPath }}
@@ -137,22 +139,22 @@ spec:
            - name: RUCIO_DAEMON
              value: "{{ $rucio_daemon }}"
            - name: RUCIO_DAEMON_ARGS
              value: "{{- if .Values.automatix.threads }} --threads-per-process {{ .Values.automatix.threads }}{{ end }} {{- if .Values.automatix.inputFile }} --input-file {{ .Values.automatix.inputFile }}{{ end }} {{- if .Values.automatix.sleepTime }} --sleep-time {{ .Values.automatix.sleepTime }}{{ end }}"
              value: "{{- if $component_values.threads }} --threads-per-process {{ $component_values.threads }}{{ end }} {{- if $component_values.inputFile }} --input-file {{ $component_values.inputFile }}{{ end }} {{- if $component_values.sleepTime }} --sleep-time {{ $component_values.sleepTime }}{{ end }}"
            - name: X509_USER_PROXY
              value: "/opt/proxy/x509up"
{{- with .Values.automatix.resources }}
{{- with $component_values.resources }}
          resources:
{{ toYaml . | trim | indent 12 }}
{{ end }}
{{- with .Values.automatix.nodeSelector }}
{{- with $component_values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.automatix.affinity }}
{{- with $component_values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.automatix.tolerations }}
{{- with $component_values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
+12 −10
Original line number Diff line number Diff line
{{- if gt .Values.cacheConsumerCount 0.0 -}}
{{- $rucio_daemon := "cache-consumer" }}
{{- $component_values := .Values.cacheConsumer }}
{{- $component_count := .Values.cacheConsumerCount }}
{{- $app_label := printf "%s-%s" (include "rucio.name" .) $rucio_daemon }}
apiVersion: v1
kind: Secret
@@ -13,7 +15,7 @@ metadata:
type: Opaque
data:
  {{- $common_config := .Values.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := .Values.cacheConsumer.config | default dict | mustToPrettyJson | b64enc }}
  {{- $component_config := $component_values.config | default dict | mustToPrettyJson | b64enc }}
  component.json: {{ $component_config | quote }}
---
apiVersion: apps/v1
@@ -27,7 +29,7 @@ metadata:
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.cacheConsumerCount }}
  replicas: {{ $component_count }}
  selector:
    matchLabels:
      app: {{ $app_label }}
@@ -56,7 +58,7 @@ spec:
    {{- with .Values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    {{- with .Values.cacheConsumer.podAnnotations }}
    {{- with $component_values.podAnnotations }}
        {{- toYaml . | nindent 8 }}
    {{- end }}
    spec:
@@ -70,7 +72,7 @@ spec:
      - name: config-component
        secret:
          secretName: {{ template "rucio.fullname" . }}.config.{{ $rucio_daemon }}
      {{- range $collection := tuple .Values.secretMounts .Values.cacheConsumer.secretMounts .Values.additionalSecrets .Values.cacheConsumer.additionalSecrets }}
      {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
      {{- range $key, $val := $collection }}
      - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
        secret:
@@ -93,7 +95,7 @@ spec:
            - name: config-component
              mountPath: /opt/rucio/etc/conf.d/20_component.json
              subPath: component.json
          {{- range $collection := tuple .Values.secretMounts .Values.cacheConsumer.secretMounts .Values.additionalSecrets .Values.cacheConsumer.additionalSecrets }}
          {{- range $collection := tuple .Values.secretMounts $component_values.secretMounts .Values.additionalSecrets $component_values.additionalSecrets }}
          {{- range $key, $val := $collection }}
            - name: {{ kindIs "int" $key | ternary (coalesce $val.volumeName $val.secretName $val.secretFullName) $key }} 
              mountPath: {{ $val.mountPath }}
@@ -118,20 +120,20 @@ spec:
            - name: RUCIO_DAEMON
              value: "{{ $rucio_daemon }}"
            - name: RUCIO_DAEMON_ARGS
              value: "{{- if .Values.cacheConsumer.threads }} --num-thread {{ .Values.cacheConsumer.threads }} {{ end }}"
{{- with .Values.cacheConsumer.resources }}
              value: "{{- if $component_values.threads }} --num-thread {{ $component_values.threads }} {{ end }}"
{{- with $component_values.resources }}
          resources:
{{ toYaml . | trim | indent 12 }}
{{ end }}
{{- with .Values.cacheConsumer.nodeSelector }}
{{- with $component_values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.cacheConsumer.affinity }}
{{- with $component_values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.cacheConsumer.tolerations }}
{{- with $component_values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
Loading