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
|
- name: jwt-keys
|
||||||
mountPath: /app/config/jwt
|
mountPath: /app/config/jwt
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
- name: var-cache
|
||||||
|
mountPath: /app/var/cache
|
||||||
|
- name: var-log
|
||||||
|
mountPath: /app/var/log
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.resources.php | nindent 12 }}
|
{{- toYaml .Values.resources.php | nindent 12 }}
|
||||||
- name: nginx
|
- name: nginx
|
||||||
@@ -126,6 +130,30 @@ spec:
|
|||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.resources.nginx | nindent 12 }}
|
{{- toYaml .Values.resources.nginx | nindent 12 }}
|
||||||
initContainers:
|
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
|
- name: copy-public
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
command: ["sh", "-c", "cp -a /app/public/. /public/"]
|
command: ["sh", "-c", "cp -a /app/public/. /public/"]
|
||||||
@@ -141,6 +169,10 @@ spec:
|
|||||||
- name: jwt-keys
|
- name: jwt-keys
|
||||||
secret:
|
secret:
|
||||||
secretName: backend-jwt
|
secretName: backend-jwt
|
||||||
|
- name: var-cache
|
||||||
|
emptyDir: {}
|
||||||
|
- name: var-log
|
||||||
|
emptyDir: {}
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
@@ -182,55 +214,55 @@ kind: Job
|
|||||||
metadata:
|
metadata:
|
||||||
name: backend-migrate
|
name: backend-migrate
|
||||||
namespace: {{ .Values.namespace }}
|
namespace: {{ .Values.namespace }}
|
||||||
|
labels:
|
||||||
|
app: backend
|
||||||
|
app.kubernetes.io/component: console
|
||||||
|
app.kubernetes.io/part-of: backend
|
||||||
|
app.kubernetes.io/name: backend-migrate
|
||||||
annotations:
|
annotations:
|
||||||
helm.sh/hook: pre-install,pre-upgrade
|
argocd.argoproj.io/hook: PreSync
|
||||||
helm.sh/hook-weight: "0"
|
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
|
||||||
helm.sh/hook-delete-policy: before-hook-creation
|
argocd.argoproj.io/sync-wave: "-1"
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: backend
|
||||||
|
app.kubernetes.io/component: console
|
||||||
|
app.kubernetes.io/name: backend-migrate
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
{{- include "backend.migratePodSpec" (dict "root" .) | nindent 6 }}
|
||||||
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 }}
|
|
||||||
---
|
---
|
||||||
{{- if .Values.cronjobs.clearScheduleCache.enabled }}
|
{{- end }}
|
||||||
|
{{- range .Values.cronjobs }}
|
||||||
|
{{- if .enabled }}
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: CronJob
|
kind: CronJob
|
||||||
metadata:
|
metadata:
|
||||||
name: backend-clear-schedule-cache
|
name: backend-{{ .name }}
|
||||||
namespace: {{ .Values.namespace }}
|
namespace: {{ $.Values.namespace }}
|
||||||
|
labels:
|
||||||
|
app: backend
|
||||||
|
app.kubernetes.io/component: console
|
||||||
|
app.kubernetes.io/part-of: backend
|
||||||
|
app.kubernetes.io/name: backend-{{ .name }}
|
||||||
spec:
|
spec:
|
||||||
schedule: {{ .Values.cronjobs.clearScheduleCache.schedule | quote }}
|
schedule: {{ .schedule | quote }}
|
||||||
|
timeZone: {{ $.Values.cronJobTimeZone | quote }}
|
||||||
concurrencyPolicy: Forbid
|
concurrencyPolicy: Forbid
|
||||||
successfulJobsHistoryLimit: 3
|
successfulJobsHistoryLimit: 3
|
||||||
failedJobsHistoryLimit: 3
|
failedJobsHistoryLimit: 3
|
||||||
jobTemplate:
|
jobTemplate:
|
||||||
spec:
|
spec:
|
||||||
activeDeadlineSeconds: 3600
|
activeDeadlineSeconds: {{ .activeDeadlineSeconds | default 3600 }}
|
||||||
template:
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: backend
|
||||||
|
app.kubernetes.io/component: console
|
||||||
|
app.kubernetes.io/name: backend-{{ .name }}
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: OnFailure
|
{{- include "backend.consolePodSpec" (dict "root" $ "job" .) | nindent 10 }}
|
||||||
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 }}
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -74,8 +74,18 @@ migrate:
|
|||||||
jwt:
|
jwt:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
cronJobTimeZone: Europe/Moscow
|
||||||
|
|
||||||
cronjobs:
|
cronjobs:
|
||||||
clearScheduleCache:
|
- name: clear-schedule-cache
|
||||||
enabled: true
|
enabled: true
|
||||||
schedule: "0 */6 * * *"
|
schedule: "0 */6 * * *"
|
||||||
command: ["php", "bin/console", "app:schedule:clear-cache"]
|
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