helmfile.yaml 9.15 KB
environments:
  {{ .Environment.Name }}:
    missingFileHandler: Debug
    values:
      - environments/default-values.yaml
      {{- if ne .Environment.Name "default" }}
      - environments/{{ .Environment.Name }}-values.yaml
      {{- end }}

---
releases:
  - name: {{ .Values.name }}-moqui-elasticsearch
    condition: elasticsearch.enabled
    chart: charts/elasticsearch
    namespace: {{ .Values.namespace }}
    values:
      - namePrefix: {{ .Values.name }}-
    strategicMergePatches:
      - apiVersion: elasticsearch.k8s.elastic.co/v1
        kind: Elasticsearch
        metadata:
          name: {{ .Values.name }}-moqui
          namespace: {{ .Values.namespace }}
        spec:
          version: {{ .Values.elasticsearch.version }}
      - apiVersion: kibana.k8s.elastic.co/v1
        kind: Kibana
        metadata:
          name: {{ .Values.name }}-moqui
          namespace: {{ .Values.namespace }}
        spec:
          count: {{ .Values.elasticsearch.kibana.count }}
          version: {{ .Values.elasticsearch.version }}
          elasticsearchRef:
            name: {{ .Values.name }}-moqui
          podTemplate:
            spec:
              containers:
                - name: kibana
                  resources: {{ .Values.elasticsearch.kibana.resources | toYaml | nindent 20 }}
    jsonPatches:
      - target:
          group: elasticsearch.k8s.elastic.co
          version: v1
          kind: Elasticsearch
          name: {{ .Values.name }}-moqui
          namespace: {{ .Values.namespace }}
        patch:
          - op: replace
            path: /spec/nodeSets/0/count
            value: {{ .Values.elasticsearch.count }}
          - op: add
            path: /spec/nodeSets/0/podTemplate
            value:
              spec:
                containers:
                  - name: elasticsearch
                    resources: {{ .Values.elasticsearch.resources | toYaml | nindent 22 }}
                    env: {{ .Values.elasticsearch.env | toYaml | nindent 22 }}

  - name: {{ .Values.name }}-moqui-postgresql
    condition: postgresql.enabled
    chart: charts/postgresql
    namespace: {{ .Values.namespace }}
    values:
      - namePrefix: {{ .Values.name }}-
    strategicMergePatches:
      - apiVersion: acid.zalan.do/v1
        kind: postgresql
        metadata:
          name: {{ .Values.name }}-moqui-postgresql
          namespace: {{ .Values.namespace }}
        spec:
          teamId: {{ .Values.name }}-moqui
          volume:
            size: {{ .Values.postgresql.volume.size | quote }}
          postgresql:
            version: {{ .Values.postgresql.version | quote }}
          {{- if .Values | get "postgresql.clone.uid" nil }}
          clone:
            {{ merge .Values.postgresql.clone ( dict "cluster" ( print .Values.name "-moqui-postgresql" ) ) | toYaml | nindent 12 }}
          {{- end }}

  - name: {{ .Values.name }}-moqui-app
    chart: charts/moqui
    namespace: {{ .Values.namespace }}
    values:
      - namePrefix: {{ .Values.name }}-
        images:
         - name: moqui-app
           newName: localhost:31234/moqui-app
           newTag: test-latest
         - name: moqui-jdbc-drivers
           newName: localhost:31234/moqui-jdbc-drivers
           newTag: test-latest
    jsonPatches:
      - target:
          group: apps
          version: v1
          kind: Deployment
          name: {{ .Values.name }}-moqui-app
          namespace: {{ .Values.namespace }}
        patch:
          {{- if .Values.postgresql.enabled }}
          - op: add
            path: /spec/template/spec/volumes/-
            value:
              name: postgresql-scripts
              configMap:
                name: {{ .Values.name }}-moqui-postgresql-scripts
                defaultMode: 0755
          - op: add
            path: /spec/template/spec/initContainers/-
            value:
              name: wait-for-pg
              image: registry.opensource.zalan.do/acid/spilo-14:2.1-p6
              command: ["/postgresql-scripts/pg_isready"]
              volumeMounts:
                - name: postgresql-scripts
                  mountPath: /postgresql-scripts
              env:
                - name: POSTGRES_HOST
                  value: {{ .Values.name }}-moqui-postgresql
                - name: POSTGRES_USER
                  valueFrom:
                    secretKeyRef:
                      name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
                      key: username
          {{- end }}
          {{- if .Values.elasticsearch.enabled }}
          - op: add
            path: /spec/template/spec/volumes/-
            value:
              name: elasticsearch-scripts
              configMap:
                name: {{ .Values.name }}-moqui-elasticsearch-scripts
                defaultMode: 0755
          - op: add
            path: /spec/template/spec/initContainers/-
            value:
              name: wait-for-elasticsearch
              image: localhost:31234/moqui-app:test-latest
              command: ["/elasticsearch-scripts/es_isready"]
              volumeMounts:
                - name: elasticsearch-scripts
                  mountPath: /elasticsearch-scripts
              env:
                - name: elasticsearch_url
                  value: https://{{ .Values.name }}-moqui-es-http:9200
                - name: elasticsearch_user
                  value: elastic
                - name: elasticsearch_password
                  valueFrom:
                    secretKeyRef:
                      name: {{ .Values.name }}-moqui-es-elastic-user
                      key: elastic
          {{- end }}

    strategicMergePatches:
      - apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: {{ .Values.name }}-moqui-log
          namespace: {{ .Values.namespace }}
        spec:
          resources:
            requests:
              storage: {{ .Values.storage.log.requests }}
          {{- if .Values.storage.log.storageClassName }}
          storageClassName: {{ .Values.storage.log.storageClassName }}
          {{- end }}
      - apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: {{ .Values.name }}-moqui-txlog
          namespace: {{ .Values.namespace }}
        spec:
          resources:
            requests:
              storage: {{ .Values.storage.txlog.requests }}
          {{- if .Values.storage.txlog.storageClassName }}
          storageClassName: {{ .Values.storage.txlog.storageClassName }}
          {{- end }}
      - apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: {{ .Values.name }}-moqui-sessions
          namespace: {{ .Values.namespace }}
        spec:
          resources:
            requests:
              storage: {{ .Values.storage.sessions.requests }}
          {{- if .Values.storage.sessions.storageClassName }}
          storageClassName: {{ .Values.storage.sessions.storageClassName }}
          {{- end }}
      - apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: {{ .Values.name }}-moqui-app
          namespace: {{ .Values.namespace }}
          labels:
            app: {{ .Values.name }}-moqui-app
        spec:
          selector:
            matchLabels:
              app: {{ .Values.name }}-moqui-app
          template:
            metadata:
              labels:
                app: {{ .Values.name }}-moqui-app
            spec:
              restartPolicy: Always
              securityContext:
                runAsUser: 0
                runAsGroup: 0

              containers:
                - name: moqui
                  env:
                    {{- if .Values.elasticsearch.enabled }}
                    - name: kibana_host
                      value: {{ .Values.name }}-moqui-kb-http
                    - name: elasticsearch_url
                      value: https://{{ .Values.name }}-moqui-es-http:9200
                    - name: elasticsearch_user
                      value: elastic
                    - name: elasticsearch_password
                      valueFrom:
                        secretKeyRef:
                          name: {{ .Values.name }}-moqui-es-elastic-user
                          key: elastic
                    {{- end }}
                    {{- if .Values.postgresql.enabled }}
                    - name: entity_ds_db_conf
                      value: postgres
                    - name: entity_ds_host
                      value: {{ .Values.name }}-moqui-postgresql
                    - name: entity_ds_port
                      value: "5432"
                    - name: entity_ds_user
                      valueFrom:
                        secretKeyRef:
                          name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
                          key: username
                    - name: entity_ds_password
                      valueFrom:
                        secretKeyRef:
                          name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
                          key: password
                    - name: entity_ds_database
                      value: moqui
                    - name: entity_ds_schema
                      value: public
                    {{- end }}