From b142cee9f1548a23e51851dcc90c608392886a21 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Mon, 18 Aug 2025 10:33:58 +0200 Subject: [PATCH 01/12] [created] ingress with tailscale class --- k8s/preprod-ingress.yaml | 32 ++++++++++++++++++++++++++++++++ k8s/test-ingress.yaml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 k8s/preprod-ingress.yaml create mode 100644 k8s/test-ingress.yaml diff --git a/k8s/preprod-ingress.yaml b/k8s/preprod-ingress.yaml new file mode 100644 index 00000000..67313761 --- /dev/null +++ b/k8s/preprod-ingress.yaml @@ -0,0 +1,32 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: preprod-ingress + namespace: preprod +spec: + ingressClassName: tailscale + rules: + - host: preprod + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: frontend + port: + number: 80 + - path: /logicway + pathType: Prefix + backend: + service: + name: logicway + port: + number: 8000 + - path: /route-engine + pathType: Prefix + backend: + service: + name: route-engine + port: + number: 8001 diff --git a/k8s/test-ingress.yaml b/k8s/test-ingress.yaml new file mode 100644 index 00000000..254762a4 --- /dev/null +++ b/k8s/test-ingress.yaml @@ -0,0 +1,32 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: test-ingress + namespace: test +spec: + ingressClassName: tailscale + rules: + - host: test + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: frontend + port: + number: 80 + - path: /logicway + pathType: Prefix + backend: + service: + name: logicway + port: + number: 8000 + - path: /route-engine + pathType: Prefix + backend: + service: + name: route-engine + port: + number: 8001 From 8fc42dce959ec916e935ade9650d951c50f8e8e1 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Mon, 18 Aug 2025 11:15:34 +0200 Subject: [PATCH 02/12] [changed] host form generic --- k8s/preprod-ingress.yaml | 2 +- k8s/test-ingress.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/k8s/preprod-ingress.yaml b/k8s/preprod-ingress.yaml index 67313761..848981e5 100644 --- a/k8s/preprod-ingress.yaml +++ b/k8s/preprod-ingress.yaml @@ -6,7 +6,7 @@ metadata: spec: ingressClassName: tailscale rules: - - host: preprod + - host: preprod-logicway http: paths: - path: / diff --git a/k8s/test-ingress.yaml b/k8s/test-ingress.yaml index 254762a4..d57e7891 100644 --- a/k8s/test-ingress.yaml +++ b/k8s/test-ingress.yaml @@ -6,7 +6,7 @@ metadata: spec: ingressClassName: tailscale rules: - - host: test + - host: test-logicway http: paths: - path: / From 5011133d0cfe5a4aa7b4f8b45125ddf085ac3e91 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Mon, 18 Aug 2025 12:19:58 +0200 Subject: [PATCH 03/12] [changed_minor] added host name --- k8s/preprod-ingress.yaml | 7 ++++--- k8s/test-ingress.yaml | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/k8s/preprod-ingress.yaml b/k8s/preprod-ingress.yaml index 848981e5..ea5a9291 100644 --- a/k8s/preprod-ingress.yaml +++ b/k8s/preprod-ingress.yaml @@ -1,13 +1,14 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: preprod-ingress + name: ingress namespace: preprod + annotations: + tailscale.com/hostname: logicway-preprod spec: ingressClassName: tailscale rules: - - host: preprod-logicway - http: + - http: paths: - path: / pathType: Prefix diff --git a/k8s/test-ingress.yaml b/k8s/test-ingress.yaml index d57e7891..e051591d 100644 --- a/k8s/test-ingress.yaml +++ b/k8s/test-ingress.yaml @@ -1,13 +1,14 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: test-ingress + name: ingress namespace: test + annotations: + tailscale.com/hostname: logicway-test spec: ingressClassName: tailscale rules: - - host: test-logicway - http: + - http: paths: - path: / pathType: Prefix From 738c002924c06bd033b5566616a985a684fd226a Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Mon, 18 Aug 2025 13:53:59 +0200 Subject: [PATCH 04/12] [changed] path ref --- k8s/base/configmap.yaml | 6 +++--- k8s/base/secret.yaml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/k8s/base/configmap.yaml b/k8s/base/configmap.yaml index f307055a..c18a3c91 100644 --- a/k8s/base/configmap.yaml +++ b/k8s/base/configmap.yaml @@ -6,6 +6,6 @@ data: DB_NAME: "logicway" DB_HOST: "postgres" DB_PORT: "5432" - ROUTE_ENGINE_URL: "http://route-engine:8001" - REACT_APP_LOGICWAY_URL: "http://192.168.49.2:30001" - REACT_APP_ROUTE_ENGINE_URL: "http://192.168.49.2:30001/routing/proxy_route_engine" + ROUTE_ENGINE_URL: "/route-engine" + REACT_APP_LOGICWAY_URL: "/logicway" + REACT_APP_ROUTE_ENGINE_URL: "/route-engine" diff --git a/k8s/base/secret.yaml b/k8s/base/secret.yaml index 42b86c6c..8ba4354a 100644 --- a/k8s/base/secret.yaml +++ b/k8s/base/secret.yaml @@ -6,5 +6,5 @@ type: Opaque data: SECRET_KEY: ZGphbmdvLWluc2VjdXJlLW5tbGFjMmhAaSheLWlyeF9ibnRxKzglKCsqdmp6b3YrJUA5cmZ1c2Ird2d6cw== # base64("django-secret-key") ROUTE_ENGINE_SECRET_KEY : ZGphbmdvLWluc2VjdXJlLWllaXJnNyZrLTJ5Mzc9ZV51MSg9KjQhdSMxKHBlQDh2JClicHQxJnpwX2s5KiQlYzNe - DB_USER: cG9zdGdyZXM= # base64 - DB_PASSWORD: cG9zdGdyZXM= # base64 + DB_USER: cG9zdGdyZXM= + DB_PASSWORD: cG9zdGdyZXM= From 4110f1c138e9dc9fbc493e8865da32c48ff7be30 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Mon, 18 Aug 2025 14:13:07 +0200 Subject: [PATCH 05/12] [added] pathRewrite --- k8s/test-ingress.yaml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/k8s/test-ingress.yaml b/k8s/test-ingress.yaml index e051591d..b7befd85 100644 --- a/k8s/test-ingress.yaml +++ b/k8s/test-ingress.yaml @@ -17,17 +17,10 @@ spec: name: frontend port: number: 80 - - path: /logicway + - path: /logicway(/|$)(.*) pathType: Prefix backend: service: name: logicway port: number: 8000 - - path: /route-engine - pathType: Prefix - backend: - service: - name: route-engine - port: - number: 8001 From 180457959902c952e456b22c5c5d5ea3f51e50a4 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Tue, 19 Aug 2025 20:29:42 +0200 Subject: [PATCH 06/12] [try] with traefik class name --- k8s/test-ingress.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/k8s/test-ingress.yaml b/k8s/test-ingress.yaml index b7befd85..570fef3c 100644 --- a/k8s/test-ingress.yaml +++ b/k8s/test-ingress.yaml @@ -1,14 +1,15 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: ingress + name: test-ingress namespace: test annotations: - tailscale.com/hostname: logicway-test + traefik.ingress.kubernetes.io/rewrite-target: /$2 spec: - ingressClassName: tailscale + ingressClassName: traefik rules: - - http: + - host: "logicway-test.taile241c6.ts.net" + http: paths: - path: / pathType: Prefix @@ -23,4 +24,4 @@ spec: service: name: logicway port: - number: 8000 + number: 8000 \ No newline at end of file From 3546689f2b0d91d1a070587fbe8f67a6e652a314 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Wed, 20 Aug 2025 19:54:02 +0200 Subject: [PATCH 07/12] [changed_minor] make route_engine config more dev --- route_engine/route_engine/asgi.py | 2 +- route_engine/route_engine/settings/dev.py | 1 + route_engine/route_engine/wsgi.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/route_engine/route_engine/asgi.py b/route_engine/route_engine/asgi.py index 3eabb93f..c3b13b3e 100644 --- a/route_engine/route_engine/asgi.py +++ b/route_engine/route_engine/asgi.py @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'route_engine.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'route_engine.settings.dev') application = get_asgi_application() diff --git a/route_engine/route_engine/settings/dev.py b/route_engine/route_engine/settings/dev.py index ca1dd3cb..043eaba1 100644 --- a/route_engine/route_engine/settings/dev.py +++ b/route_engine/route_engine/settings/dev.py @@ -3,3 +3,4 @@ DEBUG = True ALLOWED_HOSTS = ['*'] +CORS_ALLOW_ALL_ORIGINS = True diff --git a/route_engine/route_engine/wsgi.py b/route_engine/route_engine/wsgi.py index a01b5bdd..fc985441 100644 --- a/route_engine/route_engine/wsgi.py +++ b/route_engine/route_engine/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'route_engine.settings.prod') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'route_engine.settings.dev') application = get_wsgi_application() From 46fd78681a372f361109dc03596ef570374d0fe0 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Thu, 21 Aug 2025 11:33:38 +0200 Subject: [PATCH 08/12] [created] test and preprod env for k8s with tailscale access + [refactoring] --- .github/workflows/django-linter.yml | 5 +- k8s/README.md | 37 +------ k8s/preprod-env/configmap.yaml | 12 +++ .../services/frontend-service.yaml | 15 +++ .../services/logicway-service.yaml | 18 ++++ .../services/postgres-service.yaml | 12 +++ .../services/route-engine-service.yaml | 14 +++ k8s/preprod-ingress.yaml | 33 ------ k8s/test-env/configmap.yaml | 12 +++ k8s/test-env/services/frontend-service.yaml | 15 +++ k8s/test-env/services/logicway-service.yaml | 18 ++++ k8s/test-env/services/postgres-service.yaml | 15 +++ .../services/route-engine-service.yaml | 14 +++ k8s/test-ingress.yaml | 27 ----- logicway/logicway/asgi.py | 2 +- poetry.lock | 100 +++++++++++++++--- pyproject.toml | 11 +- 17 files changed, 243 insertions(+), 117 deletions(-) create mode 100644 k8s/preprod-env/configmap.yaml create mode 100644 k8s/preprod-env/services/frontend-service.yaml create mode 100644 k8s/preprod-env/services/logicway-service.yaml create mode 100644 k8s/preprod-env/services/postgres-service.yaml create mode 100644 k8s/preprod-env/services/route-engine-service.yaml delete mode 100644 k8s/preprod-ingress.yaml create mode 100644 k8s/test-env/configmap.yaml create mode 100644 k8s/test-env/services/frontend-service.yaml create mode 100644 k8s/test-env/services/logicway-service.yaml create mode 100644 k8s/test-env/services/postgres-service.yaml create mode 100644 k8s/test-env/services/route-engine-service.yaml delete mode 100644 k8s/test-ingress.yaml diff --git a/.github/workflows/django-linter.yml b/.github/workflows/django-linter.yml index 7a4c2d02..2beae63c 100644 --- a/.github/workflows/django-linter.yml +++ b/.github/workflows/django-linter.yml @@ -16,9 +16,8 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install ruff==0.0.285 + poetry install --with dev - name: Run linter with auto-fix run: | - ruff check --fix . --format=github + poetry run ruff check --fix . --format=github diff --git a/k8s/README.md b/k8s/README.md index 5f55691f..2034c53f 100644 --- a/k8s/README.md +++ b/k8s/README.md @@ -3,14 +3,10 @@ ## Setup and Configuration ### Prerequisites -- Ensure you have [kubectl](https://kubernetes.io/docs/tasks/tools/) installed and configured. +- Ensure you have [kubectl](https://kubernetes.io/docs/tasks/tools/) and [k3s](https://docs.k3s.io/installation) installed and configured. - Ensure you have [Helm](https://helm.sh/docs/intro/install/) installed. ### Local Kubernetes Cluster Setup -#### Install Minikube -```bash -minikube start -``` ## Rolling Update and Rollback @@ -56,34 +52,3 @@ kubectl apply -f k8s/base/morouting/logicway-servicemonitor.yaml -n monitoring ```bash kubectl --namespace monitoring port-forward svc/prometheus-operated 9090:9090 ``` - -## Remote machine deployment - -#### Prerequisites -```bash -git clone https://github.com/LogicWayTeam/LogicWaySolution.git -cd LogicWaySolution -``` - -#### Apply all manifests -```bash -kubectl apply -f k8s/ -``` - -#### Check the status -```bash -kubectl get all -``` - ---- - -#### Access from the client machine (SSH tunnel) -```bash -ssh -L 8000:192.168.49.2:30001 -L 3000:192.168.49.2:30000 devops@logicway-k8s.taile241c6.ts.net -``` - -#### Access from the browser -Open your browser and go to `http://localhost:3000`. You should see the LogicWay application running. - - - diff --git a/k8s/preprod-env/configmap.yaml b/k8s/preprod-env/configmap.yaml new file mode 100644 index 00000000..b75f2ba5 --- /dev/null +++ b/k8s/preprod-env/configmap.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: app-config + namespace: preprod +data: + DB_NAME: "logicway" + DB_HOST: "postgres" + DB_PORT: "5432" + ROUTE_ENGINE_URL: "http://route-engine.preprod.svc.cluster.local" + REACT_APP_LOGICWAY_URL: "http://logicway-preprod.taile241c6.ts.net" + REACT_APP_ROUTE_ENGINE_URL: "http://logicway-preprod.taile241c6.ts.net/routing/proxy_route_engine" diff --git a/k8s/preprod-env/services/frontend-service.yaml b/k8s/preprod-env/services/frontend-service.yaml new file mode 100644 index 00000000..d116ed36 --- /dev/null +++ b/k8s/preprod-env/services/frontend-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: frontend + namespace: preprod + annotations: + tailscale.com/expose: "true" + tailscale.com/hostname: "frontend-preprod" +spec: + selector: + app: frontend + ports: + - port: 80 + targetPort: 80 + type: ClusterIP diff --git a/k8s/preprod-env/services/logicway-service.yaml b/k8s/preprod-env/services/logicway-service.yaml new file mode 100644 index 00000000..0f552bb9 --- /dev/null +++ b/k8s/preprod-env/services/logicway-service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: logicway + labels: + app: logicway + namespace: ppreprod + annotations: + tailscale.com/expose: "true" + tailscale.com/hostname: "logicway-preprod" +spec: + selector: + app: logicway + ports: + - name: http-django-8000 + port: 80 + targetPort: 8000 + type: ClusterIP diff --git a/k8s/preprod-env/services/postgres-service.yaml b/k8s/preprod-env/services/postgres-service.yaml new file mode 100644 index 00000000..4ff600ee --- /dev/null +++ b/k8s/preprod-env/services/postgres-service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: postgres + namespace: preprod +spec: + selector: + app: postgres + ports: + - port: 5432 + targetPort: 5432 + type: ClusterIP diff --git a/k8s/preprod-env/services/route-engine-service.yaml b/k8s/preprod-env/services/route-engine-service.yaml new file mode 100644 index 00000000..53ad5ca7 --- /dev/null +++ b/k8s/preprod-env/services/route-engine-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: route-engine + labels: + app: route-engine +spec: + selector: + app: route-engine + ports: + - name: http-django-8001 + port: 80 + targetPort: 8001 + type: ClusterIP diff --git a/k8s/preprod-ingress.yaml b/k8s/preprod-ingress.yaml deleted file mode 100644 index ea5a9291..00000000 --- a/k8s/preprod-ingress.yaml +++ /dev/null @@ -1,33 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: ingress - namespace: preprod - annotations: - tailscale.com/hostname: logicway-preprod -spec: - ingressClassName: tailscale - rules: - - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: frontend - port: - number: 80 - - path: /logicway - pathType: Prefix - backend: - service: - name: logicway - port: - number: 8000 - - path: /route-engine - pathType: Prefix - backend: - service: - name: route-engine - port: - number: 8001 diff --git a/k8s/test-env/configmap.yaml b/k8s/test-env/configmap.yaml new file mode 100644 index 00000000..cf270392 --- /dev/null +++ b/k8s/test-env/configmap.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: app-config + namespace: test +data: + DB_NAME: "logicway" + DB_HOST: "postgres" + DB_PORT: "5432" + ROUTE_ENGINE_URL: "http://route-engine.test.svc.cluster.local" + REACT_APP_LOGICWAY_URL: "http://logicway-test.taile241c6.ts.net" + REACT_APP_ROUTE_ENGINE_URL: "http://logicway-test.taile241c6.ts.net/routing/proxy_route_engine" diff --git a/k8s/test-env/services/frontend-service.yaml b/k8s/test-env/services/frontend-service.yaml new file mode 100644 index 00000000..86d58031 --- /dev/null +++ b/k8s/test-env/services/frontend-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: frontend + namespace: test + annotations: + tailscale.com/expose: "true" + tailscale.com/hostname: "frontend-test" +spec: + selector: + app: frontend + ports: + - port: 80 + targetPort: 80 + type: ClusterIP diff --git a/k8s/test-env/services/logicway-service.yaml b/k8s/test-env/services/logicway-service.yaml new file mode 100644 index 00000000..c26f3927 --- /dev/null +++ b/k8s/test-env/services/logicway-service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: logicway + labels: + app: logicway + namespace: test + annotations: + tailscale.com/expose: "true" + tailscale.com/hostname: "logicway-test" +spec: + selector: + app: logicway + ports: + - name: http-django-8000 + port: 80 + targetPort: 8000 + type: ClusterIP diff --git a/k8s/test-env/services/postgres-service.yaml b/k8s/test-env/services/postgres-service.yaml new file mode 100644 index 00000000..c5f76ca7 --- /dev/null +++ b/k8s/test-env/services/postgres-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: postgres + namespace: test + annotations: + tailscale.com/expose: "true" + tailscale.com/hostname: "postgres-test" +spec: + selector: + app: postgres + ports: + - port: 5432 + targetPort: 5432 + type: ClusterIP diff --git a/k8s/test-env/services/route-engine-service.yaml b/k8s/test-env/services/route-engine-service.yaml new file mode 100644 index 00000000..53ad5ca7 --- /dev/null +++ b/k8s/test-env/services/route-engine-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: route-engine + labels: + app: route-engine +spec: + selector: + app: route-engine + ports: + - name: http-django-8001 + port: 80 + targetPort: 8001 + type: ClusterIP diff --git a/k8s/test-ingress.yaml b/k8s/test-ingress.yaml deleted file mode 100644 index 570fef3c..00000000 --- a/k8s/test-ingress.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: test-ingress - namespace: test - annotations: - traefik.ingress.kubernetes.io/rewrite-target: /$2 -spec: - ingressClassName: traefik - rules: - - host: "logicway-test.taile241c6.ts.net" - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: frontend - port: - number: 80 - - path: /logicway(/|$)(.*) - pathType: Prefix - backend: - service: - name: logicway - port: - number: 8000 \ No newline at end of file diff --git a/logicway/logicway/asgi.py b/logicway/logicway/asgi.py index 7eab4127..6a3a654b 100644 --- a/logicway/logicway/asgi.py +++ b/logicway/logicway/asgi.py @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'logicway.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'logicway.settings.dev') application = get_asgi_application() diff --git a/poetry.lock b/poetry.lock index 161ed473..c8ec2b15 100644 --- a/poetry.lock +++ b/poetry.lock @@ -287,12 +287,12 @@ version = "0.4.6" description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -groups = ["main", "logicway"] +groups = ["main", "dev", "logicway"] files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] -markers = {main = "sys_platform == \"win32\" or platform_system == \"Windows\"", logicway = "platform_system == \"Windows\""} +markers = {main = "platform_system == \"Windows\"", dev = "sys_platform == \"win32\"", logicway = "platform_system == \"Windows\""} [[package]] name = "django" @@ -353,12 +353,12 @@ version = "1.3.0" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" -groups = ["main", "logicway"] +groups = ["main", "dev", "logicway"] files = [ {file = "exceptiongroup-1.3.0-py3-none-any.whl", hash = "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10"}, {file = "exceptiongroup-1.3.0.tar.gz", hash = "sha256:b241f5885f560bc56a59ee63ca4c6a8bfa46ae4ad651af316d4e81817bb9fd88"}, ] -markers = {logicway = "python_version == \"3.10\""} +markers = {dev = "python_version == \"3.10\"", logicway = "python_version == \"3.10\""} [package.dependencies] typing-extensions = {version = ">=4.6.0", markers = "python_version < \"3.13\""} @@ -584,7 +584,7 @@ version = "2.1.0" description = "brain-dead simple config-ini parsing" optional = false python-versions = ">=3.8" -groups = ["main"] +groups = ["dev"] files = [ {file = "iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"}, {file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"}, @@ -608,7 +608,7 @@ version = "3.1.6" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" -groups = ["logicway"] +groups = ["dev", "logicway"] files = [ {file = "jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67"}, {file = "jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"}, @@ -646,7 +646,7 @@ version = "3.0.2" description = "Safely add untrusted strings to HTML/XML markup." optional = false python-versions = ">=3.9" -groups = ["logicway"] +groups = ["dev", "logicway"] files = [ {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8"}, {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158"}, @@ -903,7 +903,7 @@ version = "25.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" -groups = ["main", "logicway"] +groups = ["main", "dev", "logicway"] files = [ {file = "packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484"}, {file = "packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f"}, @@ -1002,7 +1002,7 @@ version = "1.6.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.9" -groups = ["main"] +groups = ["dev"] files = [ {file = "pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746"}, {file = "pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3"}, @@ -1124,7 +1124,7 @@ version = "2.19.2" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.8" -groups = ["main"] +groups = ["dev"] files = [ {file = "pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"}, {file = "pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887"}, @@ -1152,7 +1152,7 @@ version = "8.4.1" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.9" -groups = ["main"] +groups = ["dev"] files = [ {file = "pytest-8.4.1-py3-none-any.whl", hash = "sha256:539c70ba6fcead8e78eebbf1115e8b589e7565830d7d006a8723f19ac8a0afb7"}, {file = "pytest-8.4.1.tar.gz", hash = "sha256:7c67fd69174877359ed9371ec3af8a3d2b04741818c51e5e99cc1742251fa93c"}, @@ -1176,7 +1176,7 @@ version = "4.11.1" description = "A Django plugin for pytest." optional = false python-versions = ">=3.8" -groups = ["main"] +groups = ["dev"] files = [ {file = "pytest_django-4.11.1-py3-none-any.whl", hash = "sha256:1b63773f648aa3d8541000c26929c1ea63934be1cfa674c76436966d73fe6a10"}, {file = "pytest_django-4.11.1.tar.gz", hash = "sha256:a949141a1ee103cb0e7a20f1451d355f83f5e4a5d07bdd4dcfdd1fd0ff227991"}, @@ -1189,6 +1189,45 @@ pytest = ">=7.0.0" docs = ["sphinx", "sphinx_rtd_theme"] testing = ["Django", "django-configurations (>=2.0)"] +[[package]] +name = "pytest-html" +version = "4.1.1" +description = "pytest plugin for generating HTML reports" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "pytest_html-4.1.1-py3-none-any.whl", hash = "sha256:c8152cea03bd4e9bee6d525573b67bbc6622967b72b9628dda0ea3e2a0b5dd71"}, + {file = "pytest_html-4.1.1.tar.gz", hash = "sha256:70a01e8ae5800f4a074b56a4cb1025c8f4f9b038bba5fe31e3c98eb996686f07"}, +] + +[package.dependencies] +jinja2 = ">=3.0.0" +pytest = ">=7.0.0" +pytest-metadata = ">=2.0.0" + +[package.extras] +docs = ["pip-tools (>=6.13.0)"] +test = ["assertpy (>=1.1)", "beautifulsoup4 (>=4.11.1)", "black (>=22.1.0)", "flake8 (>=4.0.1)", "pre-commit (>=2.17.0)", "pytest-mock (>=3.7.0)", "pytest-rerunfailures (>=11.1.2)", "pytest-xdist (>=2.4.0)", "selenium (>=4.3.0)", "tox (>=3.24.5)"] + +[[package]] +name = "pytest-metadata" +version = "3.1.1" +description = "pytest plugin for test session metadata" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "pytest_metadata-3.1.1-py3-none-any.whl", hash = "sha256:c8e0844db684ee1c798cfa38908d20d67d0463ecb6137c72e91f418558dd5f4b"}, + {file = "pytest_metadata-3.1.1.tar.gz", hash = "sha256:d2a29b0355fbc03f168aa96d41ff88b1a3b44a3b02acbe491801c98a048017c8"}, +] + +[package.dependencies] +pytest = ">=7.0.0" + +[package.extras] +test = ["black (>=22.1.0)", "flake8 (>=4.0.1)", "pre-commit (>=2.17.0)", "tox (>=3.24.5)"] + [[package]] name = "python-dateutil" version = "2.9.0.post0" @@ -1267,6 +1306,35 @@ files = [ [package.dependencies] requests = ">=2.20.0" +[[package]] +name = "ruff" +version = "0.12.9" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +groups = ["dev"] +files = [ + {file = "ruff-0.12.9-py3-none-linux_armv6l.whl", hash = "sha256:fcebc6c79fcae3f220d05585229463621f5dbf24d79fdc4936d9302e177cfa3e"}, + {file = "ruff-0.12.9-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:aed9d15f8c5755c0e74467731a007fcad41f19bcce41cd75f768bbd687f8535f"}, + {file = "ruff-0.12.9-py3-none-macosx_11_0_arm64.whl", hash = "sha256:5b15ea354c6ff0d7423814ba6d44be2807644d0c05e9ed60caca87e963e93f70"}, + {file = "ruff-0.12.9-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d596c2d0393c2502eaabfef723bd74ca35348a8dac4267d18a94910087807c53"}, + {file = "ruff-0.12.9-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1b15599931a1a7a03c388b9c5df1bfa62be7ede6eb7ef753b272381f39c3d0ff"}, + {file = "ruff-0.12.9-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3d02faa2977fb6f3f32ddb7828e212b7dd499c59eb896ae6c03ea5c303575756"}, + {file = "ruff-0.12.9-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:17d5b6b0b3a25259b69ebcba87908496e6830e03acfb929ef9fd4c58675fa2ea"}, + {file = "ruff-0.12.9-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:72db7521860e246adbb43f6ef464dd2a532ef2ef1f5dd0d470455b8d9f1773e0"}, + {file = "ruff-0.12.9-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a03242c1522b4e0885af63320ad754d53983c9599157ee33e77d748363c561ce"}, + {file = "ruff-0.12.9-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9fc83e4e9751e6c13b5046d7162f205d0a7bac5840183c5beebf824b08a27340"}, + {file = "ruff-0.12.9-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:881465ed56ba4dd26a691954650de6ad389a2d1fdb130fe51ff18a25639fe4bb"}, + {file = "ruff-0.12.9-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:43f07a3ccfc62cdb4d3a3348bf0588358a66da756aa113e071b8ca8c3b9826af"}, + {file = "ruff-0.12.9-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:07adb221c54b6bba24387911e5734357f042e5669fa5718920ee728aba3cbadc"}, + {file = "ruff-0.12.9-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f5cd34fabfdea3933ab85d72359f118035882a01bff15bd1d2b15261d85d5f66"}, + {file = "ruff-0.12.9-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:f6be1d2ca0686c54564da8e7ee9e25f93bdd6868263805f8c0b8fc6a449db6d7"}, + {file = "ruff-0.12.9-py3-none-win32.whl", hash = "sha256:cc7a37bd2509974379d0115cc5608a1a4a6c4bff1b452ea69db83c8855d53f93"}, + {file = "ruff-0.12.9-py3-none-win_amd64.whl", hash = "sha256:6fb15b1977309741d7d098c8a3cb7a30bc112760a00fb6efb7abc85f00ba5908"}, + {file = "ruff-0.12.9-py3-none-win_arm64.whl", hash = "sha256:63c8c819739d86b96d500cce885956a1a48ab056bbcbc61b747ad494b2485089"}, + {file = "ruff-0.12.9.tar.gz", hash = "sha256:fbd94b2e3c623f659962934e52c2bea6fc6da11f667a427a368adaf3af2c866a"}, +] + [[package]] name = "selenium" version = "4.34.2" @@ -1453,7 +1521,7 @@ version = "2.2.1" description = "A lil' TOML parser" optional = false python-versions = ">=3.8" -groups = ["main", "logicway"] +groups = ["dev", "logicway"] markers = "python_version == \"3.10\"" files = [ {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, @@ -1557,12 +1625,12 @@ version = "4.14.1" description = "Backported and Experimental Type Hints for Python 3.9+" optional = false python-versions = ">=3.9" -groups = ["main", "logicway"] +groups = ["main", "dev", "logicway"] files = [ {file = "typing_extensions-4.14.1-py3-none-any.whl", hash = "sha256:d1e1e3b58374dc93031d6eda2420a48ea44a36c2b4766a4fdeb3710755731d76"}, {file = "typing_extensions-4.14.1.tar.gz", hash = "sha256:38b39f4aeeab64884ce9f74c94263ef78f3c22467c8724005483154c26648d36"}, ] -markers = {main = "python_version < \"3.13\""} +markers = {main = "python_version <= \"3.12\"", dev = "python_version == \"3.10\""} [[package]] name = "tzdata" @@ -1683,4 +1751,4 @@ h11 = ">=0.9.0,<1" [metadata] lock-version = "2.1" python-versions = "^3.10" -content-hash = "6870a1df8db709e4bc17fed3b1491e31602ac4ddbc97ded03c0b0da44dac459c" +content-hash = "71bf854c724984dd0df65bc588aa63b457b54408421b5b1be491152fc067e0d4" diff --git a/pyproject.toml b/pyproject.toml index 15c7e9e1..72b480a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,6 @@ readme = "README.md" python = "^3.10" django = "==5.2.1" whitenoise = "^6.9.0" -pytest-django = "^4.11.1" python-dotenv = "^1.1.0" django-cors-headers = "^4.7.0" gunicorn = "^23.0.0" @@ -18,6 +17,7 @@ click = "==8.2.0" greenlet = "==3.2.2" django-prometheus = "^2.3.1" + [tool.poetry.group.logicway.dependencies] sqlalchemy = "^2.0.40" selenium = "^4.31.0" @@ -30,10 +30,19 @@ flask = "^3.1.0" gitpython = "^3.1.44" networkx = "^3.4.2" + [tool.poetry.group.route_engine.dependencies] routingpy = "^1.3.0" geopy = "^2.4.1" + +[tool.poetry.group.dev.dependencies] +pytest = "^8.4.1" +pytest-django = "^4.11.1" +ruff = "^0.12.9" +pytest-html = "^4.1.1" + + [tool.ruff] line-length = 120 ignore = [ From 45f2b338cf92a9bb0568730b0fc7ec407edf6288 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Thu, 21 Aug 2025 14:01:33 +0200 Subject: [PATCH 09/12] [created] k8s apply scripts --- k8s/apply_preprod.sh | 17 +++++++++++++++++ k8s/apply_test.sh | 17 +++++++++++++++++ k8s/preprod-env/services/logicway-service.yaml | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 k8s/apply_preprod.sh create mode 100644 k8s/apply_test.sh diff --git a/k8s/apply_preprod.sh b/k8s/apply_preprod.sh new file mode 100644 index 00000000..c969078a --- /dev/null +++ b/k8s/apply_preprod.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# --- apply configmaps and secrets --- +kubectl apply -f preprod-env/configmap.yaml +kubectl apply -f base/secret.yaml + +# --- apply deployments --- +kubectl apply -f base/frontend/frontend-deployment.yaml +kubectl apply -f base/logicway/logicway-deployment.yaml +kubectl apply -f base/postgres/postgres-deployment.yaml +kubectl apply -f base/route-engine/route-engine-deployment.yaml + +# --- apply services --- +kubectl apply -f preprod-env/services/ + +# --- apply jobs --- +kubectl apply -f base/logicway/job-load-data.yaml \ No newline at end of file diff --git a/k8s/apply_test.sh b/k8s/apply_test.sh new file mode 100644 index 00000000..9143e778 --- /dev/null +++ b/k8s/apply_test.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# --- apply configmaps and secrets --- +kubectl apply -f test-env/configmap.yaml +kubectl apply -f base/secret.yaml + +# --- apply deployments --- +kubectl apply -f base/frontend/frontend-deployment.yaml +kubectl apply -f base/logicway/logicway-deployment.yaml +kubectl apply -f base/postgres/postgres-deployment.yaml +kubectl apply -f base/route-engine/route-engine-deployment.yaml + +# --- apply services --- +kubectl apply -f test-env/services/ + +# --- apply jobs --- +kubectl apply -f base/logicway/job-load-data.yaml \ No newline at end of file diff --git a/k8s/preprod-env/services/logicway-service.yaml b/k8s/preprod-env/services/logicway-service.yaml index 0f552bb9..e850834b 100644 --- a/k8s/preprod-env/services/logicway-service.yaml +++ b/k8s/preprod-env/services/logicway-service.yaml @@ -4,7 +4,7 @@ metadata: name: logicway labels: app: logicway - namespace: ppreprod + namespace: preprod annotations: tailscale.com/expose: "true" tailscale.com/hostname: "logicway-preprod" From a6762198726d8bde32e7098a75c14511847efe11 Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Thu, 21 Aug 2025 14:04:50 +0200 Subject: [PATCH 10/12] [added] namespaces in sctipts --- k8s/apply_preprod.sh | 16 ++++++++-------- k8s/apply_test.sh | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/k8s/apply_preprod.sh b/k8s/apply_preprod.sh index c969078a..9ec6595d 100644 --- a/k8s/apply_preprod.sh +++ b/k8s/apply_preprod.sh @@ -1,17 +1,17 @@ #!/bin/bash # --- apply configmaps and secrets --- -kubectl apply -f preprod-env/configmap.yaml -kubectl apply -f base/secret.yaml +kubectl apply -f preprod-env/configmap.yaml -n preprod +kubectl apply -f base/secret.yaml -n preprod # --- apply deployments --- -kubectl apply -f base/frontend/frontend-deployment.yaml -kubectl apply -f base/logicway/logicway-deployment.yaml -kubectl apply -f base/postgres/postgres-deployment.yaml -kubectl apply -f base/route-engine/route-engine-deployment.yaml +kubectl apply -f base/frontend/frontend-deployment.yaml -n preprod +kubectl apply -f base/logicway/logicway-deployment.yaml -n preprod +kubectl apply -f base/postgres/postgres-deployment.yaml -n preprod +kubectl apply -f base/route-engine/route-engine-deployment.yaml -n preprod # --- apply services --- -kubectl apply -f preprod-env/services/ +kubectl apply -f preprod-env/services/ -n preprod # --- apply jobs --- -kubectl apply -f base/logicway/job-load-data.yaml \ No newline at end of file +kubectl apply -f base/logicway/job-load-data.yaml -n preprod \ No newline at end of file diff --git a/k8s/apply_test.sh b/k8s/apply_test.sh index 9143e778..37c8a5bc 100644 --- a/k8s/apply_test.sh +++ b/k8s/apply_test.sh @@ -1,17 +1,17 @@ #!/bin/bash # --- apply configmaps and secrets --- -kubectl apply -f test-env/configmap.yaml -kubectl apply -f base/secret.yaml +kubectl apply -f test-env/configmap.yaml -n test +kubectl apply -f test-env/secret.yaml -n test # --- apply deployments --- -kubectl apply -f base/frontend/frontend-deployment.yaml -kubectl apply -f base/logicway/logicway-deployment.yaml -kubectl apply -f base/postgres/postgres-deployment.yaml -kubectl apply -f base/route-engine/route-engine-deployment.yaml +kubectl apply -f test-env/frontend/frontend-deployment.yaml -n test +kubectl apply -f test-env/logicway/logicway-deployment.yaml -n test +kubectl apply -f test-env/postgres/postgres-deployment.yaml -n test +kubectl apply -f test-env/route-engine/route-engine-deployment.yaml -n test # --- apply services --- -kubectl apply -f test-env/services/ +kubectl apply -f test-env/services/ -n test # --- apply jobs --- -kubectl apply -f base/logicway/job-load-data.yaml \ No newline at end of file +kubectl apply -f test-env/logicway/job-load-data.yaml -n test \ No newline at end of file From f763ac2945c341f2017f24550302667e938c973e Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Thu, 21 Aug 2025 17:27:50 +0200 Subject: [PATCH 11/12] [changed_minor] missed Install Poetry step --- .github/workflows/django-linter.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/django-linter.yml b/.github/workflows/django-linter.yml index 2beae63c..f080bb61 100644 --- a/.github/workflows/django-linter.yml +++ b/.github/workflows/django-linter.yml @@ -14,6 +14,9 @@ jobs: with: python-version: '3.12' + - name: Install Poetry + run: pip install poetry + - name: Install dependencies run: | poetry install --with dev From af07842e4ee6a64d9f01d9488431a7931d00203d Mon Sep 17 00:00:00 2001 From: Mikita Tsybulka Date: Thu, 21 Aug 2025 17:31:56 +0200 Subject: [PATCH 12/12] [changed_minor] linter run + missed namesppaces in k8s mnfs --- .github/workflows/django-linter.yml | 2 +- k8s/preprod-env/services/route-engine-service.yaml | 1 + k8s/test-env/services/route-engine-service.yaml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/django-linter.yml b/.github/workflows/django-linter.yml index f080bb61..88435e4f 100644 --- a/.github/workflows/django-linter.yml +++ b/.github/workflows/django-linter.yml @@ -23,4 +23,4 @@ jobs: - name: Run linter with auto-fix run: | - poetry run ruff check --fix . --format=github + poetry run ruff check --fix . diff --git a/k8s/preprod-env/services/route-engine-service.yaml b/k8s/preprod-env/services/route-engine-service.yaml index 53ad5ca7..40176c42 100644 --- a/k8s/preprod-env/services/route-engine-service.yaml +++ b/k8s/preprod-env/services/route-engine-service.yaml @@ -4,6 +4,7 @@ metadata: name: route-engine labels: app: route-engine + namespace: preprod spec: selector: app: route-engine diff --git a/k8s/test-env/services/route-engine-service.yaml b/k8s/test-env/services/route-engine-service.yaml index 53ad5ca7..b7077526 100644 --- a/k8s/test-env/services/route-engine-service.yaml +++ b/k8s/test-env/services/route-engine-service.yaml @@ -4,6 +4,7 @@ metadata: name: route-engine labels: app: route-engine + namespace: test spec: selector: app: route-engine