Files
lasuite-docs/bin/Tiltfile
T
Manuel Raynaud d6793f2117 ✨(loadtest) add the grafana dashboards of the load-test campaign
To see what is happening in the cluster we added grafana dashboards
using all the metrics introduced previsouly
2026-09-23 12:06:05 +02:00

139 lines
5.6 KiB
Python

load('ext://uibutton', 'cmd_button', 'bool_input', 'location')
load('ext://namespace', 'namespace_create', 'namespace_inject')
namespace_create('impress')
docker_build(
'localhost:5001/impress-backend:latest',
context='..',
dockerfile='../Dockerfile',
only=['./src/backend', './src/mail', './docker'],
target = 'backend-production',
build_args={'DOCKER_USER': '1000:1000'},
live_update=[
sync('../src/backend', '/app'),
run(
'pip install -r /app/requirements.txt',
trigger=['./api/requirements.txt']
)
]
)
docker_build(
'localhost:5001/impress-y-provider:latest',
context='..',
dockerfile='../src/frontend/servers/y-provider/Dockerfile',
only=['./src/frontend/', './docker/', './.dockerignore'],
target = 'y-provider',
build_args={'DOCKER_USER': '1000:1000'},
live_update=[
sync('../src/frontend/servers/y-provider/src', '/home/frontend/servers/y-provider/src'),
]
)
docker_build(
'localhost:5001/impress-frontend:latest',
context='..',
dockerfile='../src/frontend/Dockerfile',
only=['./src/frontend', './docker', './.dockerignore'],
target = 'impress',
build_args={'DOCKER_USER': '1000:1000'},
live_update=[
sync('../src/frontend', '/home/frontend'),
]
)
docker_build(
'localhost:5001/impress-yhub:latest',
context='..',
dockerfile='../src/yhub-server/Dockerfile',
only=['./src/yhub-server', './docker', './.dockerignore'],
target = 'yhub',
build_args={'DOCKER_USER': '1000:1000'},
live_update=[
sync('../src/yhub-server', '/app'),
]
)
k8s_resource('impress-docs-backend-migrate', resource_deps=['dev-backend-postgres'])
k8s_resource('impress-docs-backend-createsuperuser', resource_deps=['impress-docs-backend-migrate'])
k8s_resource('impress-docs-yhub-init-db', resource_deps=['dev-backend-postgres', 'valkey-yhub'])
k8s_resource('dev-backend-keycloak', resource_deps=['dev-backend-keycloak-pg'])
k8s_resource('impress-docs-backend', resource_deps=['impress-docs-backend-migrate', 'valkey-docs', 'dev-backend-keycloak', 'dev-backend-postgres', 'dev-backend-minio:statefulset'])
k8s_resource('impress-docs-celery-worker', resource_deps=['valkey-docs'])
k8s_resource('impress-docs-yhub', resource_deps=['valkey-yhub'])
k8s_resource('impress-docs-yhub-worker', resource_deps=['valkey-yhub'])
# The Prometheus Operator carries the CRDs of its release, and the Prometheus
# it runs (a workload of its own kind, whose pods the operator creates). The
# ServiceMonitors of the application are a resource apart, applied once the
# operator is up: their kind does not exist before its CRDs do, and nothing of
# the application waits for them. The kind is a regular expression, matched
# anywhere in the name: anchored, or it takes the PrometheusRule too.
k8s_kind('^Prometheus$', pod_readiness='ignore')
k8s_resource('prometheus-operator', objects=[
'alertmanagerconfigs.monitoring.coreos.com:customresourcedefinition',
'alertmanagers.monitoring.coreos.com:customresourcedefinition',
'podmonitors.monitoring.coreos.com:customresourcedefinition',
'probes.monitoring.coreos.com:customresourcedefinition',
'prometheusagents.monitoring.coreos.com:customresourcedefinition',
'prometheuses.monitoring.coreos.com:customresourcedefinition',
'prometheusrules.monitoring.coreos.com:customresourcedefinition',
'scrapeconfigs.monitoring.coreos.com:customresourcedefinition',
'servicemonitors.monitoring.coreos.com:customresourcedefinition',
'thanosrulers.monitoring.coreos.com:customresourcedefinition',
])
k8s_resource('prometheus-prometheus', objects=[
'prometheus-prometheus:ingress',
], resource_deps=['prometheus-operator'], links=[
'https://docs-prometheus.127.0.0.1.nip.io/targets',
])
# Grafana, with the dashboards of the load-test campaign
# (src/loadtest/dashboards) as ConfigMaps its sidecar loads
k8s_resource('prometheus-grafana', objects=[
'prometheus-grafana:ingress',
'dashboard-users:configmap',
'dashboard-collaboration:configmap',
'dashboard-backend:configmap',
'dashboard-django:configmap',
'dashboard-valkey:configmap',
], resource_deps=['prometheus-prometheus'], links=[
'https://docs-grafana.127.0.0.1.nip.io/dashboards',
])
k8s_resource(new_name='impress-docs-monitors', objects=[
'impress-docs-backend:servicemonitor',
'impress-docs-yhub:servicemonitor',
'impress-docs-yhub-worker:servicemonitor',
'valkey-docs:servicemonitor',
'valkey-yhub:servicemonitor',
], resource_deps=['prometheus-operator'])
# the valkey chart leaves its objects without a namespace, and the CRDs of the
# prometheus release only come with --include-crds
k8s_yaml(namespace_inject(local('cd ../src/helm && helmfile -n impress -e dev template --include-crds .'), 'impress'))
migration = '''
set -eu
# get k8s pod name from tilt resource name
POD_NAME="$(tilt get kubernetesdiscovery impress-backend -ojsonpath='{.status.pods[0].name}')"
kubectl -n impress exec "$POD_NAME" -- python manage.py makemigrations
'''
cmd_button('Make migration',
argv=['sh', '-c', migration],
resource='impress-backend',
icon_name='developer_board',
text='Run makemigration',
)
pod_migrate = '''
set -eu
# get k8s pod name from tilt resource name
POD_NAME="$(tilt get kubernetesdiscovery impress-backend -ojsonpath='{.status.pods[0].name}')"
kubectl -n impress exec "$POD_NAME" -- python manage.py migrate --no-input
'''
cmd_button('Migrate db',
argv=['sh', '-c', pod_migrate],
resource='impress-backend',
icon_name='developer_board',
text='Run database migration',
)