From ea70b96d0ca3d12ad61fea31bc0cbc1fb8033f0a Mon Sep 17 00:00:00 2001 From: sova-bootstrap Date: Thu, 28 May 2026 12:06:15 +0300 Subject: [PATCH] feat: add docs and cabinet apps, fix data-test chart --- apps/cabinet/Chart.yaml | 5 + apps/cabinet/templates/all.yaml | 180 ++++++++++++++++++++++++++ apps/cabinet/values-test.yaml | 8 ++ apps/cabinet/values.yaml | 59 +++++++++ apps/docs/Chart.yaml | 5 + apps/docs/templates/all.yaml | 63 +++++++++ apps/docs/values-test.yaml | 8 ++ apps/docs/values.yaml | 23 ++++ argocd/apps/test-contour.yaml | 50 +++++++ data/test/templates/db-init-jobs.yaml | 132 ------------------- 10 files changed, 401 insertions(+), 132 deletions(-) create mode 100644 apps/cabinet/Chart.yaml create mode 100644 apps/cabinet/templates/all.yaml create mode 100644 apps/cabinet/values-test.yaml create mode 100644 apps/cabinet/values.yaml create mode 100644 apps/docs/Chart.yaml create mode 100644 apps/docs/templates/all.yaml create mode 100644 apps/docs/values-test.yaml create mode 100644 apps/docs/values.yaml delete mode 100644 data/test/templates/db-init-jobs.yaml diff --git a/apps/cabinet/Chart.yaml b/apps/cabinet/Chart.yaml new file mode 100644 index 0000000..bd3bd28 --- /dev/null +++ b/apps/cabinet/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: cabinet +description: Symfony personal cabinet (LK) +type: application +version: 0.1.0 diff --git a/apps/cabinet/templates/all.yaml b/apps/cabinet/templates/all.yaml new file mode 100644 index 0000000..4cd2806 --- /dev/null +++ b/apps/cabinet/templates/all.yaml @@ -0,0 +1,180 @@ +apiVersion: v1 +kind: Secret +metadata: + name: cabinet-env + namespace: {{ .Values.namespace }} + annotations: + helm.sh/hook: pre-install,pre-upgrade + helm.sh/hook-weight: "-10" + helm.sh/hook-delete-policy: before-hook-creation +type: Opaque +stringData: +{{- range $key, $val := .Values.secrets }} + {{ $key }}: {{ $val | quote }} +{{- end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: cabinet-nginx-config + namespace: {{ .Values.namespace }} +data: + default.conf: | + server { + listen 8080; + server_name _; + root /app/public; + index index.php; + client_max_body_size 108M; + location / { + try_files $uri /index.php$is_args$args; + } + location ~* \.(?:jpg|jpeg|gif|png|ico|css|js|svg|woff2)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + access_log off; + try_files $uri =404; + } + location ~ ^/index\.php(/|$) { + fastcgi_pass 127.0.0.1:9000; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + fastcgi_param HTTP_PROXY ""; + internal; + } + location ~ \.php$ { + return 404; + } + } +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cabinet + namespace: {{ .Values.namespace }} + labels: + app: cabinet + env: test +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: cabinet + template: + metadata: + labels: + app: cabinet + env: test + spec: +{{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} +{{- end }} + containers: + - name: php-fpm + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 9000 + name: fpm + envFrom: + - secretRef: + name: cabinet-env + env: +{{- range $key, $val := .Values.env }} + - name: {{ $key }} + value: {{ $val | quote }} +{{- end }} + volumeMounts: + - name: app-public + mountPath: /app/public + - name: var-cache + mountPath: /app/var/cache + - name: var-log + mountPath: /app/var/log + resources: + {{- toYaml .Values.resources.php | nindent 12 }} + - name: nginx + image: {{ .Values.nginx.image }} + ports: + - containerPort: 8080 + name: http + volumeMounts: + - name: app-public + mountPath: /app/public + readOnly: true + - name: nginx-config + mountPath: /etc/nginx/conf.d/default.conf + subPath: default.conf + 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: cabinet-env + env: +{{- range $key, $val := .Values.env }} + - name: {{ $key }} + value: {{ $val | quote }} +{{- end }} + volumeMounts: + - 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/"] + volumeMounts: + - name: app-public + mountPath: /public + volumes: + - name: app-public + emptyDir: {} + - name: nginx-config + configMap: + name: cabinet-nginx-config + - name: var-cache + emptyDir: {} + - name: var-log + emptyDir: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: cabinet + namespace: {{ .Values.namespace }} +spec: + selector: + app: cabinet + ports: + - name: http + port: 80 + targetPort: 8080 +--- +{{- if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cabinet + namespace: {{ .Values.namespace }} +spec: + ingressClassName: {{ .Values.ingress.className }} + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: cabinet + port: + number: 80 +{{- end }} diff --git a/apps/cabinet/values-test.yaml b/apps/cabinet/values-test.yaml new file mode 100644 index 0000000..f5629a7 --- /dev/null +++ b/apps/cabinet/values-test.yaml @@ -0,0 +1,8 @@ +ingress: + host: cabinet.test.sova.local +image: + tag: cabinet-v1.0.1-test + pullPolicy: IfNotPresent + repository: git.sova.local/sova/cabinet +imagePullSecrets: + - name: gitea-registry diff --git a/apps/cabinet/values.yaml b/apps/cabinet/values.yaml new file mode 100644 index 0000000..fccbadb --- /dev/null +++ b/apps/cabinet/values.yaml @@ -0,0 +1,59 @@ +namespace: sova-test + +image: + repository: sova-cabinet + tag: local-test + pullPolicy: IfNotPresent + +imagePullSecrets: [] + +nginx: + image: nginx:1.27-alpine + +replicaCount: 1 + +ingress: + enabled: true + className: nginx + host: cabinet.test.sova.local + +resources: + php: + requests: + cpu: 100m + memory: 256Mi + limits: + cpu: 500m + memory: 512Mi + nginx: + requests: + cpu: 50m + memory: 64Mi + limits: + cpu: 200m + memory: 128Mi + +env: + APP_ENV: prod + APP_DEBUG: "0" + TRUSTED_PROXIES: "127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" + TRUSTED_HEADERS: '["x-forwarded-for","x-forwarded-host","x-forwarded-proto","x-forwarded-port","x-forwarded-prefix"]' + MIS: http://mis-mock.sova-mocks.svc.cluster.local:8080 + BITRIX24_URL: http://mis-mock.sova-mocks.svc.cluster.local:8080/rest/noop + TECH_MAINTENANCE: "false" + CORS_ALLOW_ORIGIN: "^https?://(cabinet\\.test\\.sova\\.local|localhost)(:[0-9]+)?$" + +secrets: + APP_SECRET: change-me-cabinet-test-secret + DATABASE_URL: postgresql://sova_test:sova_test_pass@postgresql-test.sova-data-test.svc.cluster.local:5432/sova_cabinet_test?serverVersion=16&charset=utf8 + DATABASE_BITRIX_URL: mysql://bitrix_test:bitrix_test_pass@mysql-bitrix-test.sova-data-test.svc.cluster.local:3306/sova_bitrix_test?serverVersion=8.0 + REDIS_URL: redis://:redis_test_pass@redis-test-master.sova-data-test.svc.cluster.local:6379/1 + MAILER_DSN: smtp://mailpit.sova-mocks.svc.cluster.local:1025 + SMSRU_KEY_API: noop + SMSRU_FROM_SOVAMED: noop + SMS4B_TOKEN: noop + SMS4B_FROM_WMTMED: noop + SMARTCAPTCHA_SERVER_KEY: test-key + +migrate: + enabled: false diff --git a/apps/docs/Chart.yaml b/apps/docs/Chart.yaml new file mode 100644 index 0000000..5da1993 --- /dev/null +++ b/apps/docs/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: docs +description: Static documentation site for Sova test contour +type: application +version: 0.1.0 diff --git a/apps/docs/templates/all.yaml b/apps/docs/templates/all.yaml new file mode 100644 index 0000000..8a50891 --- /dev/null +++ b/apps/docs/templates/all.yaml @@ -0,0 +1,63 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: docs + namespace: {{ .Values.namespace }} + labels: + app: docs +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: docs + template: + metadata: + labels: + app: docs + spec: +{{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} +{{- end }} + containers: + - name: docs + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 8080 + name: http + resources: + {{- toYaml .Values.resources | nindent 12 }} +--- +apiVersion: v1 +kind: Service +metadata: + name: docs + namespace: {{ .Values.namespace }} +spec: + selector: + app: docs + ports: + - port: 80 + targetPort: 8080 +--- +{{- if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: docs + namespace: {{ .Values.namespace }} +spec: + ingressClassName: {{ .Values.ingress.className }} + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: docs + port: + number: 80 +{{- end }} diff --git a/apps/docs/values-test.yaml b/apps/docs/values-test.yaml new file mode 100644 index 0000000..2cadbfb --- /dev/null +++ b/apps/docs/values-test.yaml @@ -0,0 +1,8 @@ +ingress: + host: docs.sova.local +image: + tag: docs-v1.0.1-test + pullPolicy: IfNotPresent + repository: git.sova.local/sova/docs +imagePullSecrets: + - name: gitea-registry diff --git a/apps/docs/values.yaml b/apps/docs/values.yaml new file mode 100644 index 0000000..27c867b --- /dev/null +++ b/apps/docs/values.yaml @@ -0,0 +1,23 @@ +namespace: sova-test + +image: + repository: sova-docs + tag: local-test + pullPolicy: IfNotPresent + +imagePullSecrets: [] + +replicaCount: 1 + +ingress: + enabled: true + className: nginx + host: docs.sova.local + +resources: + requests: + cpu: 25m + memory: 32Mi + limits: + cpu: 100m + memory: 64Mi diff --git a/argocd/apps/test-contour.yaml b/argocd/apps/test-contour.yaml index bdd34d6..c185364 100644 --- a/argocd/apps/test-contour.yaml +++ b/argocd/apps/test-contour.yaml @@ -92,3 +92,53 @@ spec: selfHeal: true syncOptions: - CreateNamespace=true +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: docs-test + namespace: argocd +spec: + project: sova + source: + repoURL: ${GITEA_REPO_URL}/sova/sova-deploy.git + targetRevision: main + path: apps/docs + helm: + valueFiles: + - values.yaml + - values-test.yaml + destination: + server: https://kubernetes.default.svc + namespace: sova-test + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: cabinet-test + namespace: argocd +spec: + project: sova + source: + repoURL: ${GITEA_REPO_URL}/sova/sova-deploy.git + targetRevision: main + path: apps/cabinet + helm: + valueFiles: + - values.yaml + - values-test.yaml + destination: + server: https://kubernetes.default.svc + namespace: sova-test + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/data/test/templates/db-init-jobs.yaml b/data/test/templates/db-init-jobs.yaml deleted file mode 100644 index e1abd21..0000000 --- a/data/test/templates/db-init-jobs.yaml +++ /dev/null @@ -1,132 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: postgres-schema-sql - namespace: {{ .Values.namespace }} -data: -{{- range $path, $_ := .Files.Glob "sql/postgres/schema/*.sql" }} - {{ base $path }}: | -{{ $.Files.Get $path | indent 4 }} -{{- end }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: postgres-seed-sql - namespace: {{ .Values.namespace }} -data: -{{- range $path, $_ := .Files.Glob "sql/postgres/seed/*.sql" }} - {{ base $path }}: | -{{ $.Files.Get $path | indent 4 }} -{{- end }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: mysql-schema-sql - namespace: {{ .Values.namespace }} -data: -{{- range $path, $_ := .Files.Glob "sql/mysql-bitrix/schema/*.sql" }} - {{ base $path }}: | -{{ $.Files.Get $path | indent 4 }} -{{- end }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: mysql-seed-sql - namespace: {{ .Values.namespace }} -data: -{{- range $path, $_ := .Files.Glob "sql/mysql-bitrix/seed/*.sql" }} - {{ base $path }}: | -{{ $.Files.Get $path | indent 4 }} -{{- end }} ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: db-init - namespace: {{ .Values.namespace }} -spec: - backoffLimit: 2 - template: - spec: - restartPolicy: OnFailure - initContainers: - - name: wait-pg - image: postgres:16-alpine - command: - - sh - - -c - - | - until pg_isready -h {{ .Values.postgres.host }} -p 5432 -U {{ .Values.postgres.user }}; do sleep 3; done - - name: wait-mysql - image: mysql:8.0 - env: - - name: MYSQL_PWD - value: {{ .Values.mysql.password | quote }} - command: - - sh - - -c - - | - until mysqladmin ping -h {{ .Values.mysql.host }} -u{{ .Values.mysql.user }} --silent; do sleep 3; done - containers: - - name: init - image: postgres:16-alpine - env: - - name: PGPASSWORD - value: {{ .Values.postgres.password | quote }} - - name: MYSQL_PWD - value: {{ .Values.mysql.password | quote }} - command: - - sh - - -c - - | - set -e - echo "=== Phase 1: schema ===" - for f in $(ls /schema/postgres/*.sql 2>/dev/null | sort); do - [ -s "$f" ] || continue - echo "PG schema: $(basename $f)" - psql -h {{ .Values.postgres.host }} -U {{ .Values.postgres.user }} -d postgres -v ON_ERROR_STOP=1 -f "$f" - done - apk add --no-cache mysql-client >/dev/null - for f in $(ls /schema/mysql/*.sql 2>/dev/null | sort); do - [ -s "$f" ] || continue - echo "MySQL schema: $(basename $f)" - mysql -h {{ .Values.mysql.host }} -u{{ .Values.mysql.user }} {{ .Values.mysql.database }} < "$f" - done - echo "=== Phase 2: seed ===" - for f in $(ls /seed/postgres/*.sql 2>/dev/null | sort); do - [ -s "$f" ] || continue - echo "PG seed: $(basename $f)" - psql -h {{ .Values.postgres.host }} -U {{ .Values.postgres.user }} -d postgres -v ON_ERROR_STOP=1 -f "$f" - done - for f in $(ls /seed/mysql/*.sql 2>/dev/null | sort); do - [ -s "$f" ] || continue - echo "MySQL seed: $(basename $f)" - mysql -h {{ .Values.mysql.host }} -u{{ .Values.mysql.user }} {{ .Values.mysql.database }} < "$f" - done - echo "DB init complete" - volumeMounts: - - name: pg-schema - mountPath: /schema/postgres - - name: mysql-schema - mountPath: /schema/mysql - - name: pg-seed - mountPath: /seed/postgres - - name: mysql-seed - mountPath: /seed/mysql - volumes: - - name: pg-schema - configMap: - name: postgres-schema-sql - - name: mysql-schema - configMap: - name: mysql-schema-sql - - name: pg-seed - configMap: - name: postgres-seed-sql - - name: mysql-seed - configMap: - name: mysql-seed-sql -