Headless deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Поднимаем для тестирования отдельный Initial builder. | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: frontend-initial-builder-ht-HASH_PAYLOAD | |
namespace: microfrontends | |
spec: | |
selector: | |
matchLabels: | |
app: frontend-initial-builder-ht-HASH_PAYLOAD | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: frontend-initial-builder-ht-HASH_PAYLOAD | |
annotations: | |
commit_sha: CI_COMMIT_SHA | |
spec: | |
imagePullSecrets: | |
- name: image-pull-staging | |
containers: | |
- name: initial-builder-pod | |
imagePullPolicy: Always | |
image: image-repo/frontend-initial-builder:latest | |
resources: | |
requests: | |
cpu: "500m" | |
memory: "300M" | |
limits: | |
cpu: "1000m" | |
memory: "500M" | |
ports: | |
- containerPort: TARGET_PORT | |
env: | |
# Передаем через переменные окружения названия headless service для поиска МКФ: | |
# первый - базовый, который получит весь код на стейджинг. | |
- name: headless_service_1 | |
value: headless-mcf-finder-staging | |
# Второй – дополнительный, который найдет только приложение, которое тестируем. | |
- name: headless_service_2 | |
value: headless-mcf-finder-ht-HASH_PAYLOAD | |
- name: ENVIRONMENT | |
value: staging | |
tolerations: | |
- key: dedicated | |
operator: Equal | |
value: mindbox-worker | |
effect: NoSchedule | |
- key: dedicated | |
operator: Equal | |
value: mindbox-worker | |
effect: PreferNoSchedule | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: frontend-initial-builder-ht-s-HASH_PAYLOAD | |
namespace: microfrontends | |
spec: | |
selector: | |
app: frontend-initial-builder-ht-HASH_PAYLOAD | |
ports: | |
- name: main | |
protocol: TCP | |
port: TARGET_PORT | |
targetPort: TARGET_PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Поднимаем под с кодом МКФ, который хотим протестировать. | |
# В названии пода HASH_PAYLOAD - уникальный хеш, который используется для навигации трафика. | |
# Этот же хеш в домене, по которому будет открываться тестовый проект. | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: hot-testing-HASH_PAYLOAD | |
namespace: microfrontends | |
spec: | |
selector: | |
matchLabels: | |
app: hot-testing-HASH_PAYLOAD | |
replicas: 1 | |
template: | |
metadata: | |
labels: | |
app: hot-testing-HASH_PAYLOAD | |
annotations: | |
commit_sha: CI_COMMIT_SHA | |
spec: | |
imagePullSecrets: | |
- name: image-pull-staging | |
containers: | |
- name: hot-testing | |
imagePullPolicy: Always | |
image: DOCKER_IMAGE | |
resources: | |
requests: | |
cpu: "30m" | |
memory: "200M" | |
limits: | |
cpu: "45m" | |
memory: "300M" | |
ports: | |
- containerPort: TARGET_PORT | |
tolerations: | |
- key: dedicated | |
operator: Equal | |
value: mindbox-worker | |
effect: NoSchedule | |
- key: dedicated | |
operator: Equal | |
value: mindbox-worker | |
effect: PreferNoSchedule | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: hot-testing-service-HASH_PAYLOAD | |
namespace: microfrontends | |
spec: | |
selector: | |
app: hot-testing-HASH_PAYLOAD | |
ports: | |
- name: main | |
protocol: TCP | |
port: TARGET_PORT | |
targetPort: TARGET_PORT | |
--- | |
# Headless service, который надет под с тестируемым приложением. | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: headless-mcf-finder-ht-HASH_PAYLOAD | |
namespace: microfrontends | |
spec: | |
clusterIP: None | |
selector: | |
app: hot-testing-HASH_PAYLOAD | |
ports: | |
- name: main | |
protocol: TCP | |
port: TARGET_PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Чтобы хот-тестинг выглядел как полноценное приложение, | |
# часть трафика перенаправляем на домен со стейджингом. | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: hot-testing-base-service-HASH_PAYLOAD | |
namespace: microfrontends | |
spec: | |
type: ExternalName | |
externalName: BASE_PROJECT_URL | |
ports: | |
- name: main | |
port: 443 | |
protocol: TCP | |
targetPort: 443 | |
--- | |
# Распределяем трафик по подам. | |
apiVersion: traefik.containo.us/v1alpha1 | |
kind: IngressRoute | |
metadata: | |
name: hot-testing-ingressroute-HASH_PAYLOAD | |
namespace: microfrontends | |
spec: | |
entryPoints: | |
- websecure | |
routes: | |
# Весь трафик, который должен обрабатывать тестируемый МКФ, направляем в под, который подняли. | |
# Ищем его по имени с хешем. | |
- match: >- | |
Host(`hot-testing-HASH_PAYLOAD-staging.mindbox.ru`) | |
&& PathPrefix(`/v2_static/PROJECT_FOLDER/`) | |
kind: Rule | |
services: | |
- name: hot-testing-service-HASH_PAYLOAD | |
port: TARGET_PORT | |
# Запросы за метаданными направляем в под с Initial builder, который подняли для теста. | |
# За счет этого мы получаем метаданные, с замененной частью. | |
- match: >- | |
Host(`hot-testing-HASH_PAYLOAD-staging.mindbox.ru`) | |
&& PathPrefix(`/v2_static/initial_builder/`) | |
kind: Rule | |
services: | |
- name: frontend-initial-builder-ht-s-HASH_PAYLOAD | |
port: TARGET_PORT | |
# Весь остальной трафик направляем на обычный домен стейджинга. | |
- match: Host(`hot-testing-HASH_PAYLOAD-staging.mindbox.ru`) | |
kind: Rule | |
services: | |
- name: hot-testing-base-service-HASH_PAYLOAD | |
port: 443 | |
passHostHeader: false | |
tls: | |
options: | |
name: agrade-tls-options | |
namespace: traefik-common |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment