From 39e539dcabfd2449ded46b1db17bd2b839ff8372 Mon Sep 17 00:00:00 2001 From: subochev Date: Thu, 26 Mar 2026 13:22:52 +0300 Subject: [PATCH] =?UTF-8?q?DEVX-178:=20[BE]=20=D0=A0=D0=B0=D0=B7=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D1=82=D1=8C=20endpoint=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B4=D0=B0=D1=87=D0=B8=20=D0=B8=D0=BD=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D1=84=D0=B5=D0=B9=D0=BD-=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20gradle/maven?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build-frontend.yml | 88 +++++++++++++++ devspc/devspace-api/templates/ingress.yaml | 2 +- devspc/devspace-api/values.yaml | 1 + devspc/devspace-selfkit-ui/Chart.yaml | 10 ++ .../templates/deployment.yaml | 106 ++++++++++++++++++ .../templates/ingress.yaml | 19 ++++ .../templates/service.yaml | 12 ++ devspc/devspace-selfkit-ui/values.yaml | 16 +++ 8 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 devspc/devspace-selfkit-ui/Chart.yaml create mode 100644 devspc/devspace-selfkit-ui/templates/deployment.yaml create mode 100644 devspc/devspace-selfkit-ui/templates/ingress.yaml create mode 100644 devspc/devspace-selfkit-ui/templates/service.yaml create mode 100644 devspc/devspace-selfkit-ui/values.yaml diff --git a/.gitea/workflows/build-frontend.yml b/.gitea/workflows/build-frontend.yml index c03046a..d819508 100644 --- a/.gitea/workflows/build-frontend.yml +++ b/.gitea/workflows/build-frontend.yml @@ -18,6 +18,11 @@ on: description: 'Версия образа' required: true type: number + prefix: + description: 'Префикс URL' + required: true + type: string + default: 'devspace-ui' jobs: deploy-dev: name: 'Deploy to dev' @@ -38,6 +43,89 @@ jobs: run: | npm install npm run build + cat > entrypoint.sh << EOF + #!/bin/sh + set -e + # Применяем переменные окружения к шаблону конфига + envsubst '${PREFIX}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf + # Запускаем nginx с переданными аргументами + exec "$@" + EOF + cat > default.conf.template << EOF + server { + listen 80; + server_name localhost; + + # Префикс из переменной окружения (по умолчанию devspace-ui) + set $prefix ${PREFIX:-devspace-ui}; + + # Редирект с /$prefix на /$prefix/ + location = /$prefix { + return 301 /$prefix/; + } + + # Отдача статики по префиксу + location /$prefix/ { + alias /usr/share/nginx/html/; + autoindex off; + try_files $uri =404; + } + + # Health check (всегда 200) + location /health { + access_log off; + return 200 "OK\n"; + add_header Content-Type text/plain; + } + + # Все остальные пути — 404 + location / { + return 404; + } + } + EOF + cat > Dockerfile << EOF + FROM nginx:stable-alpine + + # Установка gettext для envsubst (уже есть в alpine, но для ясности) + RUN apk add --no-cache gettext + + # Удаляем дефолтный конфиг + RUN rm /etc/nginx/conf.d/default.conf + + # Создаём папку для шаблонов + WORKDIR /etc/nginx/templates + + # Копируем шаблон конфигурации + COPY default.conf.template /etc/nginx/templates/default.conf.template + + # Копируем entrypoint-скрипт + COPY entrypoint.sh /entrypoint.sh + RUN chmod +x /entrypoint.sh + + # Копируем статические файлы + COPY ./dist /usr/share/nginx/html + + EXPOSE 80 + + ENTRYPOINT ["/entrypoint.sh"] + CMD ["nginx", "-g", "daemon off;"] + EOF + - name: Publishing docker + uses: https://git.binom.pw/otp/devops/docker@main + with: + image-name: "otp/${{ github.event.inputs.repo_path }}" + tags: ${{ github.event.inputs.version }} + - name: Kuebrnetus config + run: | + echo '${{ secrets.KUBE_CONFIG }}' > ./ku.yaml + - name: "Install Helm" + uses: azure/setup-helm@v4.3.0 + - name: 'Clone Helms' + uses: https://github.com/actions/checkout@v4 + with: + repository: otp/devex + path: 'helms' - name: 'Cleanup' if: always() shell: bash diff --git a/devspc/devspace-api/templates/ingress.yaml b/devspc/devspace-api/templates/ingress.yaml index 2b13ae8..cb76bd1 100644 --- a/devspc/devspace-api/templates/ingress.yaml +++ b/devspc/devspace-api/templates/ingress.yaml @@ -10,7 +10,7 @@ spec: - host: {{tpl $.Values.ingress.host .}} http: paths: - - path: /devspace-api/ + - path: {{$.Values.ingress.prefix | default '/'}} pathType: Prefix backend: service: diff --git a/devspc/devspace-api/values.yaml b/devspc/devspace-api/values.yaml index 6a5a039..28efc07 100644 --- a/devspc/devspace-api/values.yaml +++ b/devspc/devspace-api/values.yaml @@ -13,6 +13,7 @@ image: version: '' ingress: host: 'ui.devx.kube.xx' + prefix: '/devspace-api/' s3: url: 'https://s3.binom.pw' accessKey: 'U4onOIzgYuCqsU1cMIhu' diff --git a/devspc/devspace-selfkit-ui/Chart.yaml b/devspc/devspace-selfkit-ui/Chart.yaml new file mode 100644 index 0000000..9f8c7bd --- /dev/null +++ b/devspc/devspace-selfkit-ui/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v2 +name: devspace-selfkit-ui +description: KuberService +home: https://tlsys.ru/ +icon: https://lk.tlsys.org/favicon.png +keywords: + - test +type: application +version: "9.9.9" +appVersion: "9.9.9" diff --git a/devspc/devspace-selfkit-ui/templates/deployment.yaml b/devspc/devspace-selfkit-ui/templates/deployment.yaml new file mode 100644 index 0000000..b3447c0 --- /dev/null +++ b/devspc/devspace-selfkit-ui/templates/deployment.yaml @@ -0,0 +1,106 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: "{{$.Release.Name}}-{{$.Chart.Name}}" + annotations: + devspace.isb/name: {{ $.Values.repository.name | quote }} + devspace.isb/branch: {{ $.Values.repository.branch | quote }} + rollme: {{ .Release.Revision | quote }} + labels: + {{- if $.Values.labels}} + {{- toYaml $.Values.labels | nindent 4 }} + {{- end}} + app.kubernetes.io/name: {{$.Chart.Name}} + app.kubernetes.io/instance: {{ $.Release.Name }} + app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }} +spec: + {{- if not $.Values.autoscaling.enabled }} + {{ if $.Values.replicaCount }} + replicas: {{ $.Values.replicaCount }} + {{ else }} + replicas: 1 + {{end}} + {{- end }} + selector: + matchLabels: + app.kubernetes.io/name: {{$.Chart.Name}} + app.kubernetes.io/instance: {{ $.Release.Name }} + template: + metadata: + annotations: + rollme: {{ .Release.Revision | quote }} + {{- with $.Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app.kubernetes.io/name: {{$.Chart.Name}} + app.kubernetes.io/instance: {{ $.Release.Name }} +{{/* app.kubernetes.io/version: {{ $.Chart.AppVersion | quote }}*/}} + spec: + {{- with $.Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{ if $.Values.serviceAccount }} + serviceAccountName: {{ $.Values.serviceAccount.name }} + {{ end }} + volumes: + - name: application-properties-volume + configMap: + name: {{$.Release.Name}}-{{$.Chart.Name}}-main-config + items: + - key: application.yaml + path: application.yaml + securityContext: + {{- toYaml $.Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ $.Chart.Name }} + securityContext: + {{- toYaml $.Values.securityContext | nindent 12 }} + image: "{{ $.Values.image.name }}:{{ $.Values.image.version }}" + imagePullPolicy: {{ $.Values.image.pullPolicy }} + env: + - name: SPRING_CONFIG_ADDITIONAL_LOCATION + value: "file:/opt/app/config/application.yaml" + - name: PREFIX + value: "{{$.Values.ingress.prefix}}" + volumeMounts: + - mountPath: '/opt/app/config' + name: application-properties-volume + ports: + - name: http + containerPort: {{ $.Values.port }} + protocol: TCP + - name: management + containerPort: {{ $.Values.managementPort }} + protocol: TCP + livenessProbe: + httpGet: + path: '/actuator/health/liveness' + port: management + initialDelaySeconds: 20 + periodSeconds: 10 + readinessProbe: + httpGet: + path: '/actuator/health/readiness' + port: management + initialDelaySeconds: 25 + periodSeconds: 10 + {{- if $.Values.resources}} + resources: + {{- toYaml $.Values.resources | nindent 12}} + {{- else}} + resources: { } + {{end}} + {{- with $.Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $.Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $.Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} \ No newline at end of file diff --git a/devspc/devspace-selfkit-ui/templates/ingress.yaml b/devspc/devspace-selfkit-ui/templates/ingress.yaml new file mode 100644 index 0000000..cb76bd1 --- /dev/null +++ b/devspc/devspace-selfkit-ui/templates/ingress.yaml @@ -0,0 +1,19 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{$.Release.Name}}-{{$.Chart.Name}} + namespace: {{$.Release.Namespace}} + annotations: + traefik.ingress.kubernetes.io/router.middlewares: {{$.Release.Namespace}}-{{$.Release.Name}}-cors@kubernetescrd +spec: + rules: + - host: {{tpl $.Values.ingress.host .}} + http: + paths: + - path: {{$.Values.ingress.prefix | default '/'}} + pathType: Prefix + backend: + service: + name: "{{ $.Release.Name }}-{{ $.Chart.Name }}" + port: + number: {{ $.Values.port }} \ No newline at end of file diff --git a/devspc/devspace-selfkit-ui/templates/service.yaml b/devspc/devspace-selfkit-ui/templates/service.yaml new file mode 100644 index 0000000..a8c06f9 --- /dev/null +++ b/devspc/devspace-selfkit-ui/templates/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: "{{$.Release.Name}}-{{$.Chart.Name}}" +spec: + selector: + app.kubernetes.io/name: {{$.Chart.Name}} + app.kubernetes.io/instance: {{ $.Release.Name }} + ports: + - protocol: TCP + port: {{$.Values.port}} # порт, по которуму сервис будет доступен внутри кластера + targetPort: {{$.Values.port}} # порт, на котором слушает ваше приложение внутри контейнера \ No newline at end of file diff --git a/devspc/devspace-selfkit-ui/values.yaml b/devspc/devspace-selfkit-ui/values.yaml new file mode 100644 index 0000000..c647a7c --- /dev/null +++ b/devspc/devspace-selfkit-ui/values.yaml @@ -0,0 +1,16 @@ +replicaCount: 1 +autoscaling: + enabled: false +labels: [] +securityContext: + privileged: false +port: 80 +managementPort: 80 +imagePullSecrets: null +image: + name: null + pullPolicy: Always + version: '' +ingress: + host: 'ui.devx.kube.xx' + prefix: '/devspace-ui/' \ No newline at end of file