897a1bcb by Adam Heath

Merge remote-tracking branch 'k8s-helmfile/um-adam'

2 parents 71e1a5c5 495a2bb5
1 /Dockerfile
2 .*.sw?
3 /build.log
1 .*.sw? 1 .*.sw?
2 /build.log
3 charts/*/charts/*.tgz
......
1 # syntax=docker/dockerfile:1.4
2 # Builds a minimal docker image with openjdk and moqui with various volumes for configuration and persisted data outside the container
3 # NOTE: add components, build and if needed load data before building a docker image with this
4 ARG RUNTIME_IMAGE=eclipse-temurin:11-jdk
5 FROM ${RUNTIME_IMAGE} AS moqui-base
6
7 RUN true \
8 && apt-get update \
9 && apt-get install -y unzip less git \
10 && apt-get clean && rm -rf /var/lib/apt/lists/* \
11 && groupadd -g 1000 moqui \
12 && useradd -u 1000 -g 1000 -G 0 -d /opt/moqui moqui \
13 && mkdir /opt/moqui \
14 && chown moqui:moqui /opt/moqui \
15 && true
16
17 FROM moqui-base AS moqui-jdbc-drivers
18
19 RUN true \
20 && apt-get update \
21 && apt-get install -y libpostgresql-jdbc-java \
22 && apt-get clean && rm -rf /var/lib/apt/lists/* \
23 && true
24
25 # build runs as root; attempting to chown all the copied-in files runs
26 # *very* slow
27 FROM moqui-base AS moqui-build
28
29 WORKDIR /opt/moqui-build
30
31 RUN ["mkdir", "/opt/moqui-scripts"]
32 COPY --from=moqui-builder fix-git-submodules /opt/moqui-scripts/fix-git-submodules
33
34 COPY ./ /opt/moqui-app/
35
36 RUN ["/opt/moqui-scripts/fix-git-submodules", "-start", "/opt/moqui-app"]
37
38 RUN true && set -x \
39 && rm -rf /opt/moqui-build && ln -sf /opt/moqui-app/framework /opt/moqui-build \
40 && rm -rf /opt/moqui-build/runtime && ln -sf /opt/moqui-app/runtime /opt/moqui-build/runtime \
41 && rm -rf /opt/moqui-build/runtime/component && ln -sf /opt/moqui-app/component /opt/moqui-build/runtime/component \
42 && true
43
44 RUN ["./gradlew", "--no-daemon", "--info", "build", "addRuntime"]
45
46 WORKDIR /opt/moqui
47 USER moqui
48 RUN ["unzip", "-o", "/opt/moqui-build/moqui-plus-runtime.war"]
49
50 FROM moqui-base AS moqui-app
51 MAINTAINER Moqui Framework <moqui@googlegroups.com>
52
53 USER moqui
54 WORKDIR /opt/moqui
55
56 COPY --from=moqui-build /opt/moqui/ /opt/moqui/
57 RUN ["ls", "-l", "/opt/moqui/"]
58
59 # create user for search and chown corresponding files
60 #ARG search_name=opensearch
61
62 # This is a fix for previous installs, not needed for new setups.
63 # upgrade fix #RUN if [ -d runtime/opensearch/bin ]; then echo "Installing OpenSearch User"; \
64 # upgrade fix # search_name=opensearch; \
65 # upgrade fix # groupadd -g 1000 opensearch && \
66 # upgrade fix # useradd -u 1000 -g 1000 -G 0 -d /opt/moqui/runtime/opensearch opensearch && \
67 # upgrade fix # chmod 0775 /opt/moqui/runtime/opensearch && \
68 # upgrade fix # chown -R 1000:0 /opt/moqui/runtime/opensearch; \
69 # upgrade fix # elif [ -d runtime/elasticsearch/bin ]; then echo "Installing ElasticSearch User"; \
70 # upgrade fix # search_name=elasticsearch; \
71 # upgrade fix # groupadd -r elasticsearch && \
72 # upgrade fix # useradd --no-log-init -r -g elasticsearch -d /opt/moqui/runtime/elasticsearch elasticsearch && \
73 # upgrade fix # chown -R elasticsearch:elasticsearch runtime/elasticsearch; \
74 # upgrade fix # fi
75
76 # exposed as volumes for configuration purposes
77 RUN ["mkdir", "-p", "/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
78 VOLUME ["/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
79 # exposed as volumes to persist data outside the container, recommended
80 RUN ["mkdir", "-p", "/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db"]
81 VOLUME ["/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db"]
82
83 # Main Servlet Container Port
84 EXPOSE 8080
85 # Not used for external search # # Search HTTP Port
86 # Not used for external search # EXPOSE 9200
87 # Not used for external search # # Search Cluster (TCP Transport) Port
88 # Not used for external search # EXPOSE 9300
89 # Hazelcast Cluster Port
90 EXPOSE 5701
91
92 # this is to run from the war file directly, preferred approach unzips war file in advance
93 # ENTRYPOINT ["java", "-jar", "moqui.war"]
94 ENTRYPOINT ["java", "-cp", ".", "MoquiStart"]
95
96 HEALTHCHECK --interval=30s --timeout=600ms --start-period=120s CMD curl -f -H "X-Forwarded-Proto: https" -H "X-Forwarded-Ssl: on" http://localhost:8080/status || exit 1
97 # specify this as a default parameter if none are specified with docker exec/run, ie run production by default
98 CMD ["port=8080", "conf=conf/MoquiProductionConf.xml"]
99
1 #!/bin/bash
2
3 set -e
4
5 TAG=test-latest
6 APP=moqui-app
7 PUSH_TO=docker://5.161.91.120:31234
8 PREFIX=
9 declare -a images=(moqui-jdbc-drivers moqui-app)
10
11 TOP_DIR="$(cd "$(dirname "$0")"; pwd -P)"
12
13 _build() {
14 for image in "${images[@]}"; do
15 docker buildx build --progress plain --build-context "moqui-builder=$TOP_DIR" -f "${TOP_DIR}/Dockerfile" --tag "${PREFIX}${image}:${TAG}" --target "${image}" "${APP}"
16 done
17 }
18
19 _push() {
20 for image in "${images[@]}"; do
21 echo "Pushing ${PREFIX}${image}:${TAG} to ${PUSH_TO}/${image}:${TAG}"
22 skopeo copy --dest-tls-verify=false "docker-daemon:${PREFIX}${image}:${TAG}" "${PUSH_TO}/${image}:${TAG}"
23 done
24 }
25
26 while [[ $# -gt 0 ]]; do
27 case "$1" in
28 (--app)
29 APP="$2"
30 shift 2
31 ;;
32 (--prefix)
33 PREFIX="$2"
34 shift 2
35 ;;
36 (--push-to)
37 PUSH_TO="$2"
38 shift 2
39 ;;
40 (--tag)
41 TAG="$2"
42 shift 2
43 ;;
44 (*)
45 break
46 ;;
47 esac
48 done
49 case "$1" in
50 (build)
51 _build
52 ;;
53 (push)
54 _push
55 ;;
56 ("")
57 _build
58 _push
59 ;;
60 esac
61
1 apiVersion: elasticsearch.k8s.elastic.co/v1
2 kind: Elasticsearch
3 metadata:
4 name: moqui
5 spec:
6 version: 8.2.3
7 nodeSets:
8 - name: default
9 count: 2
10 config:
11 node.store.allow_mmap: false
12 ---
13 apiVersion: kibana.k8s.elastic.co/v1
14 kind: Kibana
15 metadata:
16 name: moqui
17 spec:
18 version: 8.2.3
19 count: 1
20 elasticsearchRef:
21 name: moqui
22 ---
23
1 #!/bin/sh
2 set -ex
3
4 elasticsearch_timeout=${elasticsearch_timeout:-3}
5
6 check_es() {
7 status="$(curl -o /dev/null -w "%{http_code}" --max-time ${elasticsearch_timeout} -XGET -g -s -k -u "${elasticsearch_user}:${elasticsearch_password}" "${elasticsearch_url}")"
8 if [ "z$status" = z200 ]; then
9 return 0
10 fi
11 return 1
12 }
13
14 while ! check_es; do
15 echo "Waiting for Elasticsearch" 1>&2
16 sleep 1
17 count=5
18 while [ $count -gt 0 ] && ! check_es; do
19 count=$(($count - 1))
20 sleep 1
21 done
22 done
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./elasticsearch.yaml
6
7 configMapGenerator:
8 - name: moqui-elasticsearch-scripts
9 files:
10 - ./es_isready
11 options:
12 disableNameSuffixHash: true
13
1 dependencies:
2 - name: opensearch
3 repository: https://opensearch-project.github.io/helm-charts/
4 version: 2.10.0
5 - name: postgresql
6 repository: https://charts.bitnami.com/bitnami
7 version: 12.1.14
8 digest: sha256:32398ca9a1a4833794b8e26cfdbcf4281951a0fc4caad9951a078bcd0d646b7a
9 generated: "2023-02-08T12:41:35.591551351-06:00"
1 apiVersion: v2
2 name: moqui
3 description: A Helm chart for Kubernetes
4
5 # A chart can be either an 'application' or a 'library' chart.
6 #
7 # Application charts are a collection of templates that can be packaged into versioned archives
8 # to be deployed.
9 #
10 # Library charts provide useful utilities or functions for the chart developer. They're included as
11 # a dependency of application charts to inject those utilities and functions into the rendering
12 # pipeline. Library charts do not define any templates and therefore cannot be deployed.
13 type: application
14
15 # This is the chart version. This version number should be incremented each time you make changes
16 # to the chart and its templates, including the app version.
17 # Versions are expected to follow Semantic Versioning (https://semver.org/)
18 version: 0.0.0
19
20 # This is the version number of the application being deployed. This version number should be
21 # incremented each time you make changes to the application. Versions are not expected to
22 # follow Semantic Versioning. They should reflect the version the application is using.
23 # It is recommended to use it with quotes.
24 appVersion: "latest"
25
26
27 dependencies:
28 - name: opensearch
29 condition: opensearch.enabled
30 repository: https://opensearch-project.github.io/helm-charts/
31 version: "2.10.0"
32 import-values:
33 - child: .
34 parent: opensearch
35 - name: postgresql
36 condition: postgresql.enabled
37 repository: https://charts.bitnami.com/bitnami
38 version: "12.1.14"
39 import-values:
40 - child: .
41 parent: postgresql
No preview for this file type
No preview for this file type
1 #!/bin/sh
2
3 cp -a /usr/share/java/postgresql* /mnt/jdbc-drivers
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./moqui.yaml
6
7 configMapGenerator:
8 - name: moqui-scripts
9 files:
10 - ./copy-jdbc-drivers
11 options:
12 disableNameSuffixHash: true
13
1 ---
2 apiVersion: v1
3 kind: ConfigMap
4 metadata:
5 name: moqui
6 data:
7 instance_purpose: production
8 default_locale: en_US
9 default_time_zone: US/Central
10 database_time_zone: US/Central
11 entity_ds_db_conf: postgres
12 entity_ds_host: postgresql
13 entity_ds_port: "5432"
14 entity_ds_database: moqui
15 entity_ds_schema: public
16 _entity_add_missing_runtime: "true"
17 moqui_load_types: seed,seed-initial,install
18 moqui.conf: "conf/MoquiProductionConf.xml"
19 jetty_threads: "100"
20 ---
21 apiVersion: v1
22 kind: Secret
23 metadata:
24 name: moqui
25 stringData:
26 ---
27 apiVersion: v1
28 kind: PersistentVolumeClaim
29 metadata:
30 name: moqui-log
31 spec:
32 accessModes:
33 - ReadWriteOnce
34 resources:
35 requests:
36 storage: 10Gi
37 ---
38 apiVersion: v1
39 kind: PersistentVolumeClaim
40 metadata:
41 name: moqui-txlog
42 spec:
43 accessModes:
44 - ReadWriteOnce
45 resources:
46 requests:
47 storage: 2Gi
48 ---
49 apiVersion: v1
50 kind: PersistentVolumeClaim
51 metadata:
52 name: moqui-sessions
53 spec:
54 accessModes:
55 - ReadWriteOnce
56 resources:
57 requests:
58 storage: 2Gi
59 ---
60 apiVersion: v1
61 kind: Service
62 metadata:
63 name: moqui
64 spec:
65 type: ClusterIP
66 selector:
67 app: moqui-app
68 ports:
69 - name: http-moqui
70 protocol: TCP
71 port: 8080
72 targetPort: 8080
73 - name: http-hazelcast
74 protocol: TCP
75 port: 5701
76 targetPort: 5701
77 ---
78
79 apiVersion: apps/v1
80 kind: Deployment
81 metadata:
82 name: moqui-app
83 labels:
84 app: moqui-app
85 spec:
86 selector:
87 matchLabels:
88 app: moqui-app
89 template:
90 metadata:
91 labels:
92 app: moqui-app
93 spec:
94 restartPolicy: Always
95 securityContext:
96 runAsUser: 0
97 runAsGroup: 0
98
99 volumes:
100 - name: log
101 persistentVolumeClaim:
102 claimName: moqui-log
103 - name: txlog
104 persistentVolumeClaim:
105 claimName: moqui-txlog
106 - name: txlog-init
107 emptyDir: {}
108 - name: sessions
109 persistentVolumeClaim:
110 claimName: moqui-sessions
111 - name: scripts
112 configMap:
113 name: moqui-scripts
114 defaultMode: 0755
115 - name: lib
116 emptyDir: {}
117
118 initContainers:
119 - name: copy-jdbc-drivers
120 image: moqui-jdbc-drivers:latest
121 imagePullPolicy: IfNotPresent
122 command: ["/scripts/copy-jdbc-drivers"]
123 volumeMounts:
124 - name: scripts
125 mountPath: /scripts
126 - name: lib
127 mountPath: /mnt/jdbc-drivers
128
129 - name: load-moqui
130 image: moqui-app:latest
131 imagePullPolicy: IfNotPresent
132 args: ["load", "conf=$(moqui.conf)", "types=$(moqui_load_types)"]
133 resources:
134 limits:
135 memory: 1Gi
136 requests:
137 memory: 1Gi
138 envFrom:
139 - configMapRef:
140 name: moqui
141 - secretRef:
142 name: moqui
143 env:
144 - name: entity_add_missing_runtime
145 value: "true"
146 volumeMounts:
147 - name: lib
148 mountPath: /opt/moqui/runtime/lib
149 - name: log
150 mountPath: /opt/moqui/runtime/log
151 - name: txlog-init
152 mountPath: /opt/moqui/runtime/txlog
153 - name: sessions
154 mountPath: /opt/moqui/runtime/sessions
155
156 containers:
157 - name: moqui
158 image: moqui-app:latest
159 imagePullPolicy: IfNotPresent
160 args: ["port=8080", "conf=$(moqui.conf)", "threads=$(jetty_threads)"]
161 resources:
162 limits:
163 memory: 1Gi
164 requests:
165 memory: 1Gi
166 envFrom:
167 - configMapRef:
168 name: moqui
169 - secretRef:
170 name: moqui
171 env:
172 - name: entity_add_missing_runtime
173 value: "false"
174 volumeMounts:
175 - name: lib
176 mountPath: /opt/moqui/runtime/lib
177 - name: log
178 mountPath: /opt/moqui/runtime/log
179 - name: txlog
180 mountPath: /opt/moqui/runtime/txlog
181 - name: sessions
182 mountPath: /opt/moqui/runtime/sessions
183
1 {{/*
2 Expand the name of the chart.
3 */}}
4 {{- define "moqui.name" -}}
5 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6 {{- end }}
7
8 {{/*
9 Create a default fully qualified app name.
10 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11 If release name contains chart name it will be used as a full name.
12 */}}
13 {{- define "moqui.fullname" -}}
14 {{- if .Values.fullnameOverride }}
15 {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16 {{- else }}
17 {{- $name := default .Chart.Name .Values.nameOverride }}
18 {{- if contains $name .Release.Name }}
19 {{- .Release.Name | trunc 63 | trimSuffix "-" }}
20 {{- else }}
21 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22 {{- end }}
23 {{- end }}
24 {{- end }}
25
26 {{/*
27 Create chart name and version as used by the chart label.
28 */}}
29 {{- define "moqui.chart" -}}
30 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31 {{- end }}
32
33 {{/*
34 Common labels
35 */}}
36 {{- define "moqui.labels" -}}
37 helm.sh/chart: {{ include "moqui.chart" . }}
38 {{ include "moqui.selectorLabels" . }}
39 {{- if .Chart.AppVersion }}
40 app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41 {{- end }}
42 app.kubernetes.io/managed-by: {{ .Release.Service }}
43 {{- end }}
44
45 {{/*
46 Selector labels
47 */}}
48 {{- define "moqui.selectorLabels" -}}
49 app.kubernetes.io/name: {{ include "moqui.name" . }}
50 app.kubernetes.io/instance: {{ .Release.Name }}
51 {{- end }}
52
53 {{/*
54 Create the name of the service account to use
55 */}}
56 {{- define "moqui.serviceAccountName" -}}
57 {{- if .Values.serviceAccount.create }}
58 {{- default (include "moqui.fullname" .) .Values.serviceAccount.name }}
59 {{- else }}
60 {{- default "default" .Values.serviceAccount.name }}
61 {{- end }}
62 {{- end }}
63
64 {{- define "moqui.opensearch-url" -}}
65 {{- if .Values.opensearch.enabled -}}
66 "https://{{- include "opensearch.masterService" .Subcharts.opensearch }}:{{ .Values.opensearch.httpPort }}"
67 {{- else }}
68 {{- printf "%s" .Values.opensearch.url }}
69 {{- end }}
70 {{- end }}
71
72 {{- define "moqui.image-helper" -}}
73 image: "{{ if .registry }}{{ .registry }}/{{ end }}{{ .repository }}{{ if .tag }}:{{ .tag }}{{ end }}"
74 imagePullPolicy: {{ .pullPolicy }}
75 {{- end }}
76
77 {{- define "moqui.entity_ds_host" -}}
78 {{- if (and (eq .Values.configMap.entity_ds_db_conf "postgres") .Values.postgresql.enabled) }}
79 {{- include "postgresql.primary.svc.headless" .Subcharts.postgresql }}
80 {{- else -}}
81 {{ .Values.configMap.entity_ds_host }}
82 {{- end -}}
83 {{- end }}
84
85 {{- define "moqui.entity_ds_port" -}}
86 {{- if (and (eq .Values.configMap.entity_ds_db_conf "postgres") .Values.postgresql.enabled) }}
87 {{- include "postgresql.service.port" .Subcharts.postgresql }}
88 {{- else -}}
89 {{ .Values.configMap.entity_ds_port }}
90 {{- end -}}
91 {{- end }}
92
93 {{- define "moqui.entity_ds_database" -}}
94 {{- if (and (eq .Values.configMap.entity_ds_db_conf "postgres") .Values.postgresql.enabled) }}
95 {{- include "postgresql.database" .Subcharts.postgresql }}
96 {{- else -}}
97 {{ .Values.configMap.entity_ds_database }}
98 {{- end -}}
99 {{- end }}
100
101 {{- define "moqui.entity_ds_user" -}}
102 {{- if (and (eq .Values.configMap.entity_ds_db_conf "postgres") .Values.postgresql.enabled) }}
103 {{- include "postgresql.username" .Subcharts.postgresql }}
104 {{- else -}}
105 {{ .Values.configMap.entity_ds_user }}
106 {{- end -}}
107 {{- end }}
108
109 {{- define "moqui.entity_ds_password.secret.name" -}}
110 {{- if (and (eq .Values.configMap.entity_ds_db_conf "postgres") .Values.postgresql.enabled) -}}
111 {{- include "postgresql.secretName" .Subcharts.postgresql }}
112 {{- else -}}
113 {{ include "moqui.fullname" . }}-dsauth
114 {{- end -}}
115 {{- end }}
116
117 {{- define "moqui.entity_ds_password.secret.key" -}}
118 {{- if (and (eq .Values.configMap.entity_ds_db_conf "postgres") .Values.postgresql.enabled) -}}
119 password
120 {{- else -}}
121 entity_ds_password
122 {{- end -}}
123 {{- end }}
124
1 apiVersion: v1
2 kind: ConfigMap
3 metadata:
4 name: {{ include "moqui.fullname" . }}
5 labels:
6 {{- include "moqui.labels" . | nindent 4 }}
7 data: {{ .Values.configMap | toYaml | nindent 2 }}
8
1 {{- if .Values.ingress.enabled }}
2 apiVersion: networking.k8s.io/v1
3 kind: Ingress
4 metadata:
5 name: {{ include "moqui.fullname" . }}
6 labels: {{- include "moqui.labels" . | nindent 4 }}
7 annotations: {{ .Values.ingress.annotations | toYaml | nindent 4 }}
8 spec:
9 ingressClassName: {{ .Values.ingress.ingressClassName }}
10 rules:
11 {{- range .Values.ingress.hosts }}
12 - host: {{ . }}
13 http:
14 paths:
15 - path: /
16 pathType: Prefix
17 backend:
18 service:
19 name: {{ include "moqui.fullname" $ }}
20 port:
21 name: http-moqui
22 {{- end }}
23 {{- if .Values.ingress.tls.enabled }}
24 tls:
25 - hosts: {{ .Values.ingress.hosts | toYaml | nindent 8 }}
26 secretName: {{ .Values.ingress.tls.secretName }}
27 {{- end }}
28 {{- end }}
29
1 apiVersion: apps/v1
2 kind: {{ .Values.kind }}
3 metadata:
4 name: {{ include "moqui.fullname" . }}
5 labels:
6 {{- include "moqui.labels" . | nindent 4 }}
7 spec:
8 {{- if not .Values.autoscaling.enabled }}
9 replicas: {{ .Values.replicaCount }}
10 {{- end }}
11 {{- if (eq "StatefulSet" .Values.kind) }}
12 serviceName: {{ include "moqui.fullname" . }}
13 {{- end }}
14 selector:
15 matchLabels:
16 {{- include "moqui.selectorLabels" . | nindent 6 }}
17 template:
18 metadata:
19 {{- with .Values.podAnnotations }}
20 annotations:
21 {{- toYaml . | nindent 8 }}
22 {{- end }}
23 labels:
24 {{- include "moqui.selectorLabels" . | nindent 8 }}
25 spec:
26 {{- with .Values.imagePullSecrets }}
27 imagePullSecrets:
28 {{- toYaml . | nindent 8 }}
29 {{- end }}
30 serviceAccountName: {{ include "moqui.serviceAccountName" . }}
31 securityContext:
32 {{- toYaml .Values.podSecurityContext | nindent 8 }}
33 volumes:
34 - name: runtime-lib
35 emptyDir: {}
36 - name: disable-elasticsearch
37 emptyDir: {}
38 initContainers:
39 {{- if (eq .Values.configMap.entity_ds_db_conf "postgres") }}
40 {{- if .Values.postgresql.jdbcImage.enabled }}
41 - name: postgresql-copy-jdbc
42 {{ include "moqui.image-helper" .Values.postgresql.jdbcImage | nindent 10 }}
43 command:
44 - bash
45 - -cx
46 - cp -a /usr/share/java/*.jar /tmp/runtime-lib
47 volumeMounts:
48 - mountPath: /tmp/runtime-lib
49 name: runtime-lib
50
51 {{- end }}
52 {{- if (.Values.checkDsConnection.enabled) }}
53 - name: postgresql-check-connection
54 {{ include "moqui.image-helper" (coalesce .Values.postgresql.image .Values.checkImage) | nindent 10 }}
55 env:
56 - name: POSTGRES_HOST
57 value: {{ include "moqui.entity_ds_host" . }}
58 - name: POSTGRES_USER
59 value: {{ include "moqui.entity_ds_user" . }}
60 - name: POSTGRES_PORT
61 value: {{ include "moqui.entity_ds_port" . | quote }}
62 command:
63 - bash
64 - -cx
65 - |-
66 until pg_isready -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" -p ${POSTGRES_PORT}; do
67 sleep 5
68 done
69
70 {{- end }}
71 {{- end }}
72
73 {{- define "moqui-container-pod" }}
74 securityContext:
75 {{- toYaml .Values.securityContext | nindent 12 }}
76 {{ include "moqui.image-helper" .Values.image | nindent 10 }}
77 command: ["java", "-server", "-XX:-OmitStackTraceInFastThrow", "-cp", ".", "MoquiStart"]
78 envFrom:
79 - configMapRef:
80 name: {{ include "moqui.fullname" . }}
81 - secretRef:
82 name: {{ include "moqui.fullname" . }}-opensearch
83 env:
84 - name: entity_ds_db_conf
85 value: 'postgres'
86 - name: entity_ds_database
87 value: {{ include "moqui.entity_ds_database" . }}
88 - name: entity_ds_host
89 value: {{ include "moqui.entity_ds_host" . }}
90 - name: entity_ds_port
91 value: {{ include "moqui.entity_ds_port" . | quote }}
92 - name: entity_ds_user
93 value: {{ include "moqui.entity_ds_user" . }}
94 - name: entity_ds_password
95 valueFrom:
96 secretKeyRef:
97 name: {{ include "moqui.entity_ds_password.secret.name" . }}
98 key: {{ include "moqui.entity_ds_password.secret.key" . }}
99 optional: false
100 - name: elasticsearch_url
101 value: {{ include "moqui.opensearch-url" . }}
102 volumeMounts:
103 - mountPath: /opt/moqui/runtime/lib
104 name: runtime-lib
105 - mountPath: /opt/moqui/runtime/elasticsearch
106 name: disable-elasticsearch
107 {{- end }}
108
109 - name: load
110 {{ include "moqui-container-pod" . }}
111 args: ["load"]
112
113 containers:
114 - name: {{ .Chart.Name }}
115 {{ include "moqui-container-pod" . }}
116 args: ["run"]
117
118 ports:
119 - name: http-moqui
120 containerPort: 8080
121 protocol: TCP
122 livenessProbe:
123 httpGet:
124 path: /status
125 port: http-moqui
126 readinessProbe:
127 httpGet:
128 path: /status
129 port: http-moqui
130 startupProbe:
131 httpGet:
132 path: /status
133 port: http-moqui
134 periodSeconds: 10
135 failureThreshold: 3
136 resources:
137 {{- toYaml .Values.resources | nindent 12 }}
138 {{- with .Values.nodeSelector }}
139 nodeSelector:
140 {{- toYaml . | nindent 8 }}
141 {{- end }}
142 {{- with .Values.affinity }}
143 affinity:
144 {{- toYaml . | nindent 8 }}
145 {{- end }}
146 {{- with .Values.tolerations }}
147 itolerations:
148 {{- toYaml . | nindent 8 }}
149 {{- end }}
150
1 {{- if (and (eq .Values.configMap.entity_ds_db_conf "postgres") .Values.postgresql.enabled) }}
2 {{- else }}
3 apiVersion: v1
4 kind: Secret
5 metadata:
6 name: {{ include "moqui.fullname" . }}-dsauth
7 labels:
8 {{- include "moqui.labels" . | nindent 4 }}
9 stringData:
10 entity_ds_password: {{ .Values.configMap.entity_ds_password }}
11 {{- end }}
12
13 apiVersion: v1
14 kind: Secret
15 metadata:
16 name: {{ include "moqui.fullname" . }}-opensearch
17 labels:
18 {{- include "moqui.labels" . | nindent 4 }}
19 stringData:
20 elasticsearch_password: admin
21
1 apiVersion: /v1
2 kind: Service
3 metadata:
4 name: {{ include "moqui.fullname" . }}
5 labels:
6 {{- include "moqui.labels" . | nindent 4 }}
7 spec:
8 type: {{ .Values.service.type }}
9 ports:
10 - port: {{ .Values.service.port }}
11 targetPort: http-moqui
12 protocol: TCP
13 name: http-moqui
14 selector:
15 {{- include "moqui.selectorLabels" . | nindent 4 }}
1 {{- if .Values.virtualService.enabled }}
2 apiVersion: networking.istio.io/v1alpha3
3 kind: VirtualService
4 metadata:
5 name: {{ include "moqui.fullname" . }}
6 labels:
7 {{- include "moqui.labels" . | nindent 4 }}
8 spec:
9 gateways: {{ .Values.virtualService.gateways | toYaml | nindent 4 }}
10 hosts: {{ .Values.virtualService.hosts | toYaml | nindent 4 }}
11 http:
12 - match: {{ .Values.virtualService.match | toYaml | nindent 8 }}
13 route:
14 - destination:
15 port:
16 number: 8080
17 host: {{ include "moqui.fullname" . }}
18 {{- end }}
1 kind: Deployment
2
3 imagePullSecrets: {}
4 image:
5 pullPolicy: IfNotPresent
6 registry: docker.io
7 repository: moqui/moquidemo
8 tag: latest
9
10 configMap:
11 entity_ds_db_conf: "postgres"
12 entity_ds_database: "moqui"
13 entity_ds_host: external-postgres
14 entity_ds_port: "5432"
15 entity_ds_user: "moqui"
16 entity_ds_password: "iuqom"
17 elasticsearch_user: "admin"
18
19 checkDsConnection:
20 enabled: true
21
22 postgresql:
23 enabled: true
24 auth:
25 database: moqui
26 username: moqui
27 password: iuqom
28 checkImage:
29 pullPolicy: IfNotPresent
30 registry: null
31 repository: null
32 tag: latest
33 jdbcImage:
34 enabled: false
35 pullPolicy: IfNotPresent
36 repository: null
37 tag: latest
38
39 opensearch:
40 enabled: true
41 clusterName: foo-opensearch
42 url: "http://127.0.0.1:9200"
43 singleNode: true
44 masterService: ""
45
46 service:
47 type: ClusterIP
48 port: 8080
49 ingress:
50 enabled: false
51 annotations: {}
52 ingressClassName: ""
53 hosts:
54 - moqui.local
55 tls:
56 enabled: false
57 secretName: moqui-tls
58
59 virtualService:
60 enabled: false
61 gateways:
62 - istio-system/ingress-gateway
63 hosts:
64 - moqui.local
65 match:
66 - uri:
67 prefix: "/"
68
69 serviceAccount:
70 create: false
71 name: default
72 podSecurityContext: {}
73 securityContext: {}
74 replicaCount: 1
75 podAnnotations: {}
76 resources: {}
77 nodeSelector: {}
78 affinity: {}
79 tolerations: {}
80 autoscaling:
81 enabled: false
82
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./postgresql.yaml
6
7 configMapGenerator:
8 - name: moqui-postgresql-scripts
9 files:
10 - ./pg_isready
11 options:
12 disableNameSuffixHash: true
13
1 #!/bin/sh
2 set -ex
3
4 # POSTGRES_HOST
5 # POSTGRES_USER
6 # POSTGRES_DATABASE
7 # PGPASSWORD
8
9 check_pg() {
10 pg_isready -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}"
11 }
12
13 check_auth() {
14 psql -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" "${POSTGRES_DATABASE}"
15 }
16
17 loop() {
18 checker="$1"
19 message="$2"
20 while ! $checker; do
21 echo "$message" 1>&2
22 sleep 1
23 count=5
24 while [ $count -gt 0 ] && ! $checker; do
25 count=$(($count - 1))
26 sleep 1
27 done
28 done
29 }
30
31 loop check_pg "Waiting for database to be up"
32 loop check_auth "Waiting for user+password to be active"
1 ---
2 apiVersion: "acid.zalan.do/v1"
3 kind: postgresql
4 metadata:
5 name: moqui-postgresql
6 spec:
7 enableLogicalBackup: true
8 teamId: "moqui"
9 volume:
10 size: 1Gi
11 numberOfInstances: 2
12 users:
13 zalando: # database owner
14 - superuser
15 - createdb
16 moqui:
17 - login
18 databases:
19 moqui: moqui
20 postgresql:
21 version: "14"
22 ---
1 name: test
2 namespace: default
3 app:
4 resources:
5 limits:
6 memory: 1Gi
7 requests:
8 memory: 1Gi
9 images:
10 moqui-app:
11 name: localhost:31234/moqui-app:latest
12 pullPolicy: Always
13 moqui-jdbc-drivers:
14 name: localhost:31234/moqui-jdbc-drivers:latest
15 pullPolicy: Always
16 storage:
17 log:
18 requests: 10Gi
19 storageClassName: null
20 txlog:
21 requests: 2Gi
22 storageClassName: null
23 sessions:
24 requests: 2Gi
25 storageClassName: null
26 elasticsearch:
27 enabled: true
28 version: 8.2.3
29 count: 2
30 resources:
31 limits:
32 memory: 1.5Gi
33 env:
34 - name: ES_JAVA_OPTS
35 value: "-Xms1g -Xmx1g"
36 kibana:
37 count: 1
38 resources:
39 limits:
40 memory: 1Gi
41 postgresql:
42 enabled: true
43 clone: {}
44 numberOfInstances: 2
45 volume:
46 size: 1Gi
47 version: "14"
48 images:
49 wait-for-pg:
50 name: registry.opensource.zalan.do/acid/spilo-14:2.1-p6
51 pullPolicy: IfNotPresent
52
1 #!/bin/bash
2
3 set -ex
4
5 cmd="$1"
6 shift
7 case "$cmd" in
8 (-start)
9 dir="$1"
10 shift
11 find "$dir" -type f -name '.git' -exec "$0" -fix "$dir" '{}' \;
12 ;;
13 (-fix)
14 dir="$1"
15 gitdir_link="$2"
16 gitdir_dir="$(dirname "$gitdir_link")"
17 read gitdir_token gitdir_location < "$gitdir_link"
18 case "$gitdir_location" in
19 (/*)
20 echo "Can't handle absolute gitdir location: $gitdir_location" 1>&2
21 exit 1
22 ;;
23 esac
24 cd "$gitdir_dir"
25 pushd "$gitdir_location"
26 git config --unset core.worktree
27 popd
28 rm .git
29 mv "$gitdir_location" .git
30 ;;
31 esac
32
1 environments:
2 {{ .Environment.Name }}:
3 missingFileHandler: Debug
4 values:
5 - environments/default-values.yaml
6 {{- if ne .Environment.Name "default" }}
7 - environments/{{ .Environment.Name }}-values.yaml
8 {{- end }}
9
10 ---
11 releases:
12 - name: {{ .Values.name }}-moqui-elasticsearch
13 condition: elasticsearch.enabled
14 chart: charts/elasticsearch
15 namespace: {{ .Values.namespace }}
16 values:
17 - namePrefix: {{ .Values.name }}-
18 strategicMergePatches:
19 - apiVersion: elasticsearch.k8s.elastic.co/v1
20 kind: Elasticsearch
21 metadata:
22 name: {{ .Values.name }}-moqui
23 namespace: {{ .Values.namespace }}
24 spec:
25 version: {{ .Values.elasticsearch.version }}
26 - apiVersion: kibana.k8s.elastic.co/v1
27 kind: Kibana
28 metadata:
29 name: {{ .Values.name }}-moqui
30 namespace: {{ .Values.namespace }}
31 spec:
32 count: {{ .Values.elasticsearch.kibana.count }}
33 version: {{ .Values.elasticsearch.version }}
34 elasticsearchRef:
35 name: {{ .Values.name }}-moqui
36 podTemplate:
37 spec:
38 containers:
39 - name: kibana
40 resources: {{ .Values.elasticsearch.kibana.resources | toYaml | nindent 20 }}
41 jsonPatches:
42 - target:
43 group: elasticsearch.k8s.elastic.co
44 version: v1
45 kind: Elasticsearch
46 name: {{ .Values.name }}-moqui
47 namespace: {{ .Values.namespace }}
48 patch:
49 - op: replace
50 path: /spec/nodeSets/0/count
51 value: {{ .Values.elasticsearch.count }}
52 - op: add
53 path: /spec/nodeSets/0/podTemplate
54 value:
55 spec:
56 containers:
57 - name: elasticsearch
58 resources: {{ .Values.elasticsearch.resources | toYaml | nindent 22 }}
59 env: {{ .Values.elasticsearch.env | toYaml | nindent 22 }}
60
61 - name: {{ .Values.name }}-moqui-postgresql
62 condition: postgresql.enabled
63 chart: charts/postgresql
64 namespace: {{ .Values.namespace }}
65 values:
66 - namePrefix: {{ .Values.name }}-
67 strategicMergePatches:
68 - apiVersion: acid.zalan.do/v1
69 kind: postgresql
70 metadata:
71 name: {{ .Values.name }}-moqui-postgresql
72 namespace: {{ .Values.namespace }}
73 spec:
74 teamId: {{ .Values.name }}-moqui
75 volume:
76 size: {{ .Values.postgresql.volume.size | quote }}
77 postgresql:
78 version: {{ .Values.postgresql.version | quote }}
79 {{- if .Values | get "postgresql.clone.uid" nil }}
80 clone:
81 {{ merge .Values.postgresql.clone ( dict "cluster" ( print .Values.name "-moqui-postgresql" ) ) | toYaml | nindent 12 }}
82 {{- end }}
83
84 - name: {{ .Values.name }}-moqui-app
85 chart: charts/moqui
86 namespace: {{ .Values.namespace }}
87 values:
88 - namePrefix: {{ .Values.name }}-
89 jsonPatches:
90 - target:
91 group: apps
92 version: v1
93 kind: Deployment
94 name: {{ .Values.name }}-moqui-app
95 namespace: {{ .Values.namespace }}
96 patch:
97 {{- if .Values.postgresql.enabled }}
98 - op: add
99 path: /spec/template/spec/volumes/-
100 value:
101 name: postgresql-scripts
102 configMap:
103 name: {{ .Values.name }}-moqui-postgresql-scripts
104 defaultMode: 0755
105 - op: add
106 path: /spec/template/spec/initContainers/0
107 value:
108 name: wait-for-pg
109 image: {{ .Values.postgresql.images | get "wait-for-pg.name" }}
110 imagePullPolicy: {{ .Values.postgresql.images | get "wait-for-pg.pullPolicy" }}
111 command: ["/postgresql-scripts/pg_isready"]
112 volumeMounts:
113 - name: postgresql-scripts
114 mountPath: /postgresql-scripts
115 env:
116 - name: POSTGRES_DATABASE
117 value: moqui
118 - name: POSTGRES_HOST
119 value: {{ .Values.name }}-moqui-postgresql
120 - name: POSTGRES_USER
121 valueFrom:
122 secretKeyRef:
123 name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
124 key: username
125 - name: PGPASSWORD
126 valueFrom:
127 secretKeyRef:
128 name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
129 key: password
130 {{- end }}
131 {{- if .Values.elasticsearch.enabled }}
132 - op: add
133 path: /spec/template/spec/volumes/-
134 value:
135 name: elasticsearch-scripts
136 configMap:
137 name: {{ .Values.name }}-moqui-elasticsearch-scripts
138 defaultMode: 0755
139 - op: add
140 path: /spec/template/spec/initContainers/0
141 value:
142 name: wait-for-elasticsearch
143 image: {{ .Values.app.images | get "moqui-app.name" }}
144 imagePullPolicy: {{ .Values.app.images | get "moqui-app.pullPolicy" }}
145 command: ["/elasticsearch-scripts/es_isready"]
146 volumeMounts:
147 - name: elasticsearch-scripts
148 mountPath: /elasticsearch-scripts
149 env:
150 - name: elasticsearch_url
151 value: https://{{ .Values.name }}-moqui-es-http:9200
152 - name: elasticsearch_user
153 value: elastic
154 - name: elasticsearch_password
155 valueFrom:
156 secretKeyRef:
157 name: {{ .Values.name }}-moqui-es-elastic-user
158 key: elastic
159 {{- end }}
160
161 strategicMergePatches:
162 - apiVersion: v1
163 kind: PersistentVolumeClaim
164 metadata:
165 name: {{ .Values.name }}-moqui-log
166 namespace: {{ .Values.namespace }}
167 spec:
168 resources:
169 requests:
170 storage: {{ .Values.storage.log.requests }}
171 {{- if .Values.storage.log.storageClassName }}
172 storageClassName: {{ .Values.storage.log.storageClassName }}
173 {{- end }}
174 - apiVersion: v1
175 kind: PersistentVolumeClaim
176 metadata:
177 name: {{ .Values.name }}-moqui-txlog
178 namespace: {{ .Values.namespace }}
179 spec:
180 resources:
181 requests:
182 storage: {{ .Values.storage.txlog.requests }}
183 {{- if .Values.storage.txlog.storageClassName }}
184 storageClassName: {{ .Values.storage.txlog.storageClassName }}
185 {{- end }}
186 - apiVersion: v1
187 kind: PersistentVolumeClaim
188 metadata:
189 name: {{ .Values.name }}-moqui-sessions
190 namespace: {{ .Values.namespace }}
191 spec:
192 resources:
193 requests:
194 storage: {{ .Values.storage.sessions.requests }}
195 {{- if .Values.storage.sessions.storageClassName }}
196 storageClassName: {{ .Values.storage.sessions.storageClassName }}
197 {{- end }}
198 - apiVersion: v1
199 kind: Service
200 metadata:
201 name: {{ .Values.name }}-moqui
202 namespace: {{ .Values.namespace }}
203 spec:
204 selector:
205 app: {{ .Values.name }}-moqui-app
206 - apiVersion: apps/v1
207 kind: Deployment
208 metadata:
209 name: {{ .Values.name }}-moqui-app
210 namespace: {{ .Values.namespace }}
211 labels:
212 app: {{ .Values.name }}-moqui-app
213 spec:
214 selector:
215 matchLabels:
216 app: {{ .Values.name }}-moqui-app
217 template:
218 metadata:
219 labels:
220 app: {{ .Values.name }}-moqui-app
221 spec:
222 restartPolicy: Always
223 securityContext:
224 runAsUser: 0
225 runAsGroup: 0
226
227 initContainers:
228 - name: copy-jdbc-drivers
229 image: {{ .Values.app.images | get "moqui-jdbc-drivers.name" }}
230 imagePullPolicy: {{ .Values.app.images | get "moqui-jdbc-drivers.pullPolicy" }}
231
232 - name: load-moqui
233 image: {{ .Values.app.images | get "moqui-app.name" }}
234 imagePullPolicy: {{ .Values.app.images | get "moqui-app.pullPolicy" }}
235 env:
236 {{- block "moquideps" . }}
237 {{- if .Values.elasticsearch.enabled }}
238 - name: kibana_host
239 value: {{ .Values.name }}-moqui-kb-http
240 - name: elasticsearch_url
241 value: https://{{ .Values.name }}-moqui-es-http:9200
242 - name: elasticsearch_user
243 value: elastic
244 - name: elasticsearch_password
245 valueFrom:
246 secretKeyRef:
247 name: {{ .Values.name }}-moqui-es-elastic-user
248 key: elastic
249 {{- end }}
250 {{- if .Values.postgresql.enabled }}
251 - name: entity_ds_db_conf
252 value: postgres
253 - name: entity_ds_host
254 value: {{ .Values.name }}-moqui-postgresql
255 - name: entity_ds_port
256 value: "5432"
257 - name: entity_ds_user
258 valueFrom:
259 secretKeyRef:
260 name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
261 key: username
262 - name: entity_ds_password
263 valueFrom:
264 secretKeyRef:
265 name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
266 key: password
267 - name: entity_ds_database
268 value: moqui
269 - name: entity_ds_schema
270 value: public
271 {{- end }}
272 {{- end }}
273
274 containers:
275 - name: moqui
276 image: {{ .Values.app.images | get "moqui-app.name" }}
277 imagePullPolicy: {{ .Values.app.images | get "moqui-app.pullPolicy" }}
278 resources: {{ .Values.app.resources | toYaml | nindent 20 }}
279 env:
280 {{- template "moquideps" . }}
281
282