feat: backend console cronjobs, cache fix, loki datasource
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
{{- define "backend.consolePodSpec" -}}
|
||||
restartPolicy: OnFailure
|
||||
{{- with .root.Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: console
|
||||
image: "{{ .root.Values.image.repository }}:{{ .root.Values.image.tag }}"
|
||||
imagePullPolicy: {{ .root.Values.image.pullPolicy }}
|
||||
command: {{ .job.command | toJson }}
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: backend-env
|
||||
env:
|
||||
- name: JWT_SECRET_KEY
|
||||
value: /app/config/jwt/private.pem
|
||||
- name: JWT_PUBLIC_KEY
|
||||
value: /app/config/jwt/public.pem
|
||||
{{- range $key, $val := .root.Values.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $val | quote }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: jwt-keys
|
||||
mountPath: /app/config/jwt
|
||||
readOnly: true
|
||||
- name: var-cache
|
||||
mountPath: /app/var/cache
|
||||
- name: var-log
|
||||
mountPath: /app/var/log
|
||||
volumes:
|
||||
- name: jwt-keys
|
||||
secret:
|
||||
secretName: backend-jwt
|
||||
- name: var-cache
|
||||
emptyDir: {}
|
||||
- name: var-log
|
||||
emptyDir: {}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "backend.migratePodSpec" -}}
|
||||
restartPolicy: Never
|
||||
{{- with .root.Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: migrate
|
||||
image: "{{ .root.Values.image.repository }}:{{ .root.Values.image.tag }}"
|
||||
imagePullPolicy: {{ .root.Values.image.pullPolicy }}
|
||||
command: ["php", "bin/console", "doctrine:migrations:migrate", "--no-interaction"]
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: backend-env
|
||||
env:
|
||||
- name: JWT_SECRET_KEY
|
||||
value: /app/config/jwt/private.pem
|
||||
- name: JWT_PUBLIC_KEY
|
||||
value: /app/config/jwt/public.pem
|
||||
{{- range $key, $val := .root.Values.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $val | quote }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: jwt-keys
|
||||
mountPath: /app/config/jwt
|
||||
readOnly: true
|
||||
- name: var-cache
|
||||
mountPath: /app/var/cache
|
||||
- name: var-log
|
||||
mountPath: /app/var/log
|
||||
volumes:
|
||||
- name: jwt-keys
|
||||
secret:
|
||||
secretName: backend-jwt
|
||||
- name: var-cache
|
||||
emptyDir: {}
|
||||
- name: var-log
|
||||
emptyDir: {}
|
||||
{{- end -}}
|
||||
@@ -109,6 +109,10 @@ spec:
|
||||
- name: jwt-keys
|
||||
mountPath: /app/config/jwt
|
||||
readOnly: true
|
||||
- name: var-cache
|
||||
mountPath: /app/var/cache
|
||||
- name: var-log
|
||||
mountPath: /app/var/log
|
||||
resources:
|
||||
{{- toYaml .Values.resources.php | nindent 12 }}
|
||||
- name: nginx
|
||||
@@ -126,6 +130,30 @@ spec:
|
||||
resources:
|
||||
{{- toYaml .Values.resources.nginx | nindent 12 }}
|
||||
initContainers:
|
||||
- name: warmup-cache
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
command: ["php", "bin/console", "cache:warmup", "--env=prod"]
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: backend-env
|
||||
env:
|
||||
- name: JWT_SECRET_KEY
|
||||
value: /app/config/jwt/private.pem
|
||||
- name: JWT_PUBLIC_KEY
|
||||
value: /app/config/jwt/public.pem
|
||||
{{- range $key, $val := .Values.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $val | quote }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: jwt-keys
|
||||
mountPath: /app/config/jwt
|
||||
readOnly: true
|
||||
- name: var-cache
|
||||
mountPath: /app/var/cache
|
||||
- name: var-log
|
||||
mountPath: /app/var/log
|
||||
- name: copy-public
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
command: ["sh", "-c", "cp -a /app/public/. /public/"]
|
||||
@@ -141,6 +169,10 @@ spec:
|
||||
- name: jwt-keys
|
||||
secret:
|
||||
secretName: backend-jwt
|
||||
- name: var-cache
|
||||
emptyDir: {}
|
||||
- name: var-log
|
||||
emptyDir: {}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
@@ -182,55 +214,55 @@ kind: Job
|
||||
metadata:
|
||||
name: backend-migrate
|
||||
namespace: {{ .Values.namespace }}
|
||||
labels:
|
||||
app: backend
|
||||
app.kubernetes.io/component: console
|
||||
app.kubernetes.io/part-of: backend
|
||||
app.kubernetes.io/name: backend-migrate
|
||||
annotations:
|
||||
helm.sh/hook: pre-install,pre-upgrade
|
||||
helm.sh/hook-weight: "0"
|
||||
helm.sh/hook-delete-policy: before-hook-creation
|
||||
argocd.argoproj.io/hook: PreSync
|
||||
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
|
||||
argocd.argoproj.io/sync-wave: "-1"
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: backend
|
||||
app.kubernetes.io/component: console
|
||||
app.kubernetes.io/name: backend-migrate
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: migrate
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
command: ["php", "bin/console", "doctrine:migrations:migrate", "--no-interaction"]
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: backend-env
|
||||
env:
|
||||
{{- range $key, $val := .Values.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $val | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- include "backend.migratePodSpec" (dict "root" .) | nindent 6 }}
|
||||
---
|
||||
{{- if .Values.cronjobs.clearScheduleCache.enabled }}
|
||||
{{- end }}
|
||||
{{- range .Values.cronjobs }}
|
||||
{{- if .enabled }}
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: backend-clear-schedule-cache
|
||||
namespace: {{ .Values.namespace }}
|
||||
name: backend-{{ .name }}
|
||||
namespace: {{ $.Values.namespace }}
|
||||
labels:
|
||||
app: backend
|
||||
app.kubernetes.io/component: console
|
||||
app.kubernetes.io/part-of: backend
|
||||
app.kubernetes.io/name: backend-{{ .name }}
|
||||
spec:
|
||||
schedule: {{ .Values.cronjobs.clearScheduleCache.schedule | quote }}
|
||||
schedule: {{ .schedule | quote }}
|
||||
timeZone: {{ $.Values.cronJobTimeZone | quote }}
|
||||
concurrencyPolicy: Forbid
|
||||
successfulJobsHistoryLimit: 3
|
||||
failedJobsHistoryLimit: 3
|
||||
jobTemplate:
|
||||
spec:
|
||||
activeDeadlineSeconds: 3600
|
||||
activeDeadlineSeconds: {{ .activeDeadlineSeconds | default 3600 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: backend
|
||||
app.kubernetes.io/component: console
|
||||
app.kubernetes.io/name: backend-{{ .name }}
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: console
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
command: {{ .Values.cronjobs.clearScheduleCache.command | toJson }}
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: backend-env
|
||||
env:
|
||||
{{- range $key, $val := .Values.env }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $val | quote }}
|
||||
{{- include "backend.consolePodSpec" (dict "root" $ "job" .) | nindent 10 }}
|
||||
---
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -74,8 +74,18 @@ migrate:
|
||||
jwt:
|
||||
enabled: true
|
||||
|
||||
cronJobTimeZone: Europe/Moscow
|
||||
|
||||
cronjobs:
|
||||
clearScheduleCache:
|
||||
- name: clear-schedule-cache
|
||||
enabled: true
|
||||
schedule: "0 */6 * * *"
|
||||
command: ["php", "bin/console", "app:schedule:clear-cache"]
|
||||
- name: sync-doctors
|
||||
enabled: true
|
||||
schedule: "0 3 * * *"
|
||||
command: ["php", "bin/console", "upload:doctors"]
|
||||
- name: sync-reviews
|
||||
enabled: true
|
||||
schedule: "30 3 * * *"
|
||||
command: ["php", "bin/console", "bitrix-update-reviews"]
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: loki-datasource
|
||||
namespace: monitoring
|
||||
labels:
|
||||
grafana_datasource: "1"
|
||||
data:
|
||||
loki-datasource.yaml: |
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://loki.monitoring.svc.cluster.local:3100
|
||||
isDefault: false
|
||||
editable: true
|
||||
Reference in New Issue
Block a user