feat: add production k3s deployment
This commit is contained in:
1 parent
6b74dfa70f
commit
16407cd208
3 files changed
+206
-2
No files matched your search
@@ -19,3 +19,4 @@
|
|||||||
- Confirmed calculations are persisted through `BELKI_DATABASE_URL` by `app/belki/history.py`; PostgreSQL is the intended production store and SQLite is only a local fallback.
|
- Confirmed calculations are persisted through `BELKI_DATABASE_URL` by `app/belki/history.py`; PostgreSQL is the intended production store and SQLite is only a local fallback.
|
||||||
- The admin history is served at `/admin`; `/api/admin/calculations` requires `BELKI_ADMIN_PASSWORD` via `X-Admin-Password` and supports sorting by kitten ID/name. The password is configured out-of-band and is not stored in browser localStorage.
|
- The admin history is served at `/admin`; `/api/admin/calculations` requires `BELKI_ADMIN_PASSWORD` via `X-Admin-Password` and supports sorting by kitten ID/name. The password is configured out-of-band and is not stored in browser localStorage.
|
||||||
- The new domain uses 5 minutes = 1 adult point and 5 minutes = 2 kitten points; a non-self-sufficient main kitten gives the adult a 1.5x multiplier and each additional non-self-sufficient kitten adds 0.5x, matching the inspected Google Sheet formulas.
|
- The new domain uses 5 minutes = 1 adult point and 5 minutes = 2 kitten points; a non-self-sufficient main kitten gives the adult a 1.5x multiplier and each additional non-self-sufficient kitten adds 0.5x, matching the inspected Google Sheet formulas.
|
||||||
|
- 2026-08-16 production deployment: namespace `belki` is live in k3s. Web and bot use `reg.nyan404.ru/cwshed-clone/belki:6b74dfa`; PostgreSQL uses the amd64 mirror `reg.nyan404.ru/library/postgres:16-alpine-amd64` on Longhorn. The web LoadBalancer is MetalLB `10.12.0.212`; route `cat.nyan404.ru/belki` through the external Nginx to that IP. Runtime credentials remain only in the cluster Secret `belki-runtime`.
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: belki-postgres-data
|
||||||
|
namespace: belki
|
||||||
|
spec:
|
||||||
|
accessModes: [ReadWriteOnce]
|
||||||
|
storageClassName: longhorn
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 2Gi
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: belki-postgres
|
||||||
|
namespace: belki
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: belki-postgres
|
||||||
|
app.kubernetes.io/part-of: belki-calculator
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: belki-postgres
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: belki-postgres
|
||||||
|
app.kubernetes.io/part-of: belki-calculator
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: reg-nyan404
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: reg.nyan404.ru/library/postgres:16-alpine-amd64
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
ports:
|
||||||
|
- name: postgres
|
||||||
|
containerPort: 5432
|
||||||
|
env:
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
value: belki
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
value: belki
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: belki-runtime
|
||||||
|
key: POSTGRES_PASSWORD
|
||||||
|
- name: PGDATA
|
||||||
|
value: /var/lib/postgresql/data/pgdata
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command: ["sh", "-c", "pg_isready -U belki -d belki"]
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 10
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: belki-postgres-data
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: belki-postgres
|
||||||
|
namespace: belki
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app.kubernetes.io/name: belki-postgres
|
||||||
|
ports:
|
||||||
|
- name: postgres
|
||||||
|
port: 5432
|
||||||
|
targetPort: postgres
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: belki-web
|
||||||
|
namespace: belki
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: belki-web
|
||||||
|
app.kubernetes.io/part-of: belki-calculator
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: belki-web
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: belki-web
|
||||||
|
app.kubernetes.io/part-of: belki-calculator
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: reg-nyan404
|
||||||
|
containers:
|
||||||
|
- name: web
|
||||||
|
image: reg.nyan404.ru/cwshed-clone/belki:6b74dfa
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command: ["python", "-m", "app.main"]
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 8080
|
||||||
|
env:
|
||||||
|
- name: BELKI_PORT
|
||||||
|
value: "8080"
|
||||||
|
- name: BELKI_DATABASE_URL
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: belki-runtime
|
||||||
|
key: BELKI_DATABASE_URL
|
||||||
|
- name: BELKI_ADMIN_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: belki-runtime
|
||||||
|
key: BELKI_ADMIN_PASSWORD
|
||||||
|
- name: BELKI_IMAGE_HOST_API_URL
|
||||||
|
value: https://nyan.nyan404.ru
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /health
|
||||||
|
port: http
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 10
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /health
|
||||||
|
port: http
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 20
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: belki-web
|
||||||
|
namespace: belki
|
||||||
|
annotations:
|
||||||
|
metallb.io/address-pool: k3s-services
|
||||||
|
spec:
|
||||||
|
type: LoadBalancer
|
||||||
|
loadBalancerIP: 10.12.0.212
|
||||||
|
selector:
|
||||||
|
app.kubernetes.io/name: belki-web
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 80
|
||||||
|
targetPort: http
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: belki-bot
|
||||||
|
namespace: belki
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: belki-bot
|
||||||
|
app.kubernetes.io/part-of: belki-calculator
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: belki-bot
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: belki-bot
|
||||||
|
app.kubernetes.io/part-of: belki-calculator
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: reg-nyan404
|
||||||
|
containers:
|
||||||
|
- name: bot
|
||||||
|
image: reg.nyan404.ru/cwshed-clone/belki:6b74dfa
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command: ["python", "-m", "app.belki.vk_bot"]
|
||||||
|
env:
|
||||||
|
- name: VK_GROUP_TOKEN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: belki-runtime
|
||||||
|
key: VK_GROUP_TOKEN
|
||||||
|
- name: VK_GROUP_ID
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: belki-runtime
|
||||||
|
key: VK_GROUP_ID
|
||||||
|
- name: VK_API_VERSION
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: belki-runtime
|
||||||
|
key: VK_API_VERSION
|
||||||
|
- name: BELKI_DATABASE_URL
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: belki-runtime
|
||||||
|
key: BELKI_DATABASE_URL
|
||||||
|
- name: BELKI_IMAGE_HOST_API_URL
|
||||||
|
value: https://nyan.nyan404.ru
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
- [`Dockerfile`](./Dockerfile): Python 3.12 runtime image for the calculator web service and shared static assets.
|
- [`Dockerfile`](./Dockerfile): Python 3.12 runtime image for the calculator web service and shared static assets.
|
||||||
- [`app/`](./app): calculation domain, report templates, JSON API, HTTP server, and VK Bots Long Poll adapter.
|
- [`app/`](./app): calculation domain, report templates, JSON API, HTTP server, and VK Bots Long Poll adapter.
|
||||||
- [`web/`](./web): calculator frontend plus legacy CatWar userscript assets.
|
- [`web/`](./web): calculator frontend plus legacy CatWar userscript assets.
|
||||||
- [`deploy/k8s/`](./deploy/k8s): not-yet-applied namespace, web/bot Deployments, ClusterIP Service, and Secret example.
|
- [`deploy/k8s/`](./deploy/k8s): namespace and production web/bot/PostgreSQL manifests.
|
||||||
- [`tests/`](./tests): standard-library unit tests for calculation, reports, API, and VK parsing.
|
- [`tests/`](./tests): standard-library unit tests for calculation, reports, API, and VK parsing.
|
||||||
- [`docs/staging/`](./docs/staging): working specification and implementation plan for the Belki calculator.
|
- [`docs/staging/`](./docs/staging): working specification and implementation plan for the Belki calculator.
|
||||||
- [`AGENTS.md`](./AGENTS.md): repo-specific instructions for future coding agents.
|
- [`AGENTS.md`](./AGENTS.md): repo-specific instructions for future coding agents.
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
- VK photo attachments received during an active dialog are normalized into `input.attachments` and persisted with the calculation; `/admin` renders their thumbnails. With `BELKI_IMAGE_HOST_API_URL`, the bot mirrors each photo through image-hosting-web and stores `mirror_url`; Google Sheets export remains deferred.
|
- VK photo attachments received during an active dialog are normalized into `input.attachments` and persisted with the calculation; `/admin` renders their thumbnails. With `BELKI_IMAGE_HOST_API_URL`, the bot mirrors each photo through image-hosting-web and stores `mirror_url`; Google Sheets export remains deferred.
|
||||||
- `/admin` and `/api/admin/calculations` expose the calculation history for review. The API requires `X-Admin-Password` matching `BELKI_ADMIN_PASSWORD`; the web page supports sorting by kitten ID or name and does not persist the password in browser storage.
|
- `/admin` and `/api/admin/calculations` expose the calculation history for review. The API requires `X-Admin-Password` matching `BELKI_ADMIN_PASSWORD`; the web page supports sorting by kitten ID or name and does not persist the password in browser storage.
|
||||||
- VK `messages.send` responses include a serialized context-aware keyboard; button payloads are translated back into the same dialog commands, while text commands remain supported.
|
- VK `messages.send` responses include a serialized context-aware keyboard; button payloads are translated back into the same dialog commands, while text commands remain supported.
|
||||||
- No k3s deployment or cluster state change has been made. The SSH tunnel used for read-only service inventory was stopped.
|
- Production k3s deployment (2026-08-16): namespace `belki` runs the web calculator, VK bot, and PostgreSQL 16 on a Longhorn 2 GiB PVC. The web LoadBalancer has MetalLB IP `10.12.0.212`; external Nginx should proxy `cat.nyan404.ru/belki` to this address. The image is `reg.nyan404.ru/cwshed-clone/belki:6b74dfa` (pushed as `latest` too). PostgreSQL is mirrored as `reg.nyan404.ru/library/postgres:16-alpine-amd64` because cluster nodes cannot pull Docker Hub directly. Registry pull credentials and runtime secrets are created out-of-band in the `belki` namespace.
|
||||||
- Remote runner host: `root@10.3.1.236` (`docker-03.homelab.local`), GitLab Runner `stage-zone-runner`, Docker executor, privileged, with `docker:29.6.1-dind` as the service image.
|
- Remote runner host: `root@10.3.1.236` (`docker-03.homelab.local`), GitLab Runner `stage-zone-runner`, Docker executor, privileged, with `docker:29.6.1-dind` as the service image.
|
||||||
- 2026-08-16 `prevent-eol` check: `python:3.12-slim` is currently maintained through 2028-10-31; Docker `29.6.1-cli` was `unknown` to the EOL catalog (no finding). Docker/CI references remain tag-pinned rather than digest-pinned.
|
- 2026-08-16 `prevent-eol` check: `python:3.12-slim` is currently maintained through 2028-10-31; Docker `29.6.1-cli` was `unknown` to the EOL catalog (no finding). Docker/CI references remain tag-pinned rather than digest-pinned.
|
||||||
|
|
||||||
@@ -38,3 +38,4 @@
|
|||||||
- 2026-08-16: added the Belki calculator domain, report templates, local web form, VK Long Poll adapter, and draft k3s manifests. Deployment remains intentionally deferred.
|
- 2026-08-16: added the Belki calculator domain, report templates, local web form, VK Long Poll adapter, and draft k3s manifests. Deployment remains intentionally deferred.
|
||||||
- 2026-08-16: made bulk entry conversational and separator-free; added API/web inspection and clarification flow.
|
- 2026-08-16: made bulk entry conversational and separator-free; added API/web inspection and clarification flow.
|
||||||
- 2026-08-16: rewrote VK help, welcome, and web hints as a concise neutral FAQ; command behavior is unchanged.
|
- 2026-08-16: rewrote VK help, welcome, and web hints as a concise neutral FAQ; command behavior is unchanged.
|
||||||
|
- 2026-08-16: added the calculator/VK links to the CatWar home page and deployed the calculator stack to k3s; MetalLB assigned `10.12.0.212`.
|
||||||
Reference in new issue
Block a user