apps(farrisilk): lab replica stack (Odoo 18 + plain Postgres + Metabase) on :8086/:8087
Odoo 18 (dated tag 18.0-20261112) on a plain postgres:16 container, not CNPG: the client runs bare Postgres on a Proxmox VM and this namespace mirrors that shape. Odoo's initContainer installs base,web once, applies the read-only BI grants/revokes and sets the admin login from a Secret. Metabase gets its own state in the same Postgres (db metabase) with a 1Gi heap and MB_ENCRYPTION_SECRET_KEY. Two bare-IP Gateways (8086 odoo, 8087 metabase) in ns internal, each with its own RouteConfiguration. Host firewall (nft on siriussec, ufw on rpi) carries 8086/8087 and was installed before the Gateways were pushed.
This commit is contained in:
parent
930752152e
commit
7f7f806616
14 changed files with 874 additions and 6 deletions
44
apps/base/farrisilk/httproute.yaml
Normal file
44
apps/base/farrisilk/httproute.yaml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# Two separate HTTPRoutes and two separate Gateways, on purpose.
|
||||
#
|
||||
# A hostname-less route answers on the bare WireGuard address
|
||||
# (http://10.10.0.2:8086/ and :8087/) for ANY Host header, because a phone
|
||||
# cannot edit /etc/hosts. Cilium renders ONE RouteConfiguration per Gateway and
|
||||
# merges every hostname-less route in it into a single weighted route, so two
|
||||
# services sharing one Gateway serve each other's traffic at random regardless
|
||||
# of listener port. Hence gateway-farrisilk-odoo.yaml (8086) and
|
||||
# gateway-farrisilk-metabase.yaml (8087) in infrastructure/networking/internal/.
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: odoo
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: farrisilk-odoo
|
||||
namespace: internal
|
||||
rules:
|
||||
- matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: /
|
||||
backendRefs:
|
||||
- name: odoo
|
||||
port: 8069
|
||||
---
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: metabase
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: farrisilk-metabase
|
||||
namespace: internal
|
||||
rules:
|
||||
- matches:
|
||||
- path:
|
||||
type: PathPrefix
|
||||
value: /
|
||||
backendRefs:
|
||||
- name: metabase
|
||||
port: 3000
|
||||
19
apps/base/farrisilk/kustomization.yaml
Normal file
19
apps/base/farrisilk/kustomization.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- namespace.yaml
|
||||
# Secrets are created out of band, before this Kustomization applies:
|
||||
# farrisilk/pg-app basic-auth, postgres superuser
|
||||
# farrisilk/pg-users odoo/metabase/metabase_ro role passwords
|
||||
# farrisilk/odoo-config admin_passwd (database master password)
|
||||
# farrisilk/odoo-admin email, password (web admin login)
|
||||
# farrisilk/metabase-admin email, password (Metabase's own login)
|
||||
# farrisilk/metabase-data-source-creds username=metabase_ro + password
|
||||
# farrisilk/metabase-secret-key MB_ENCRYPTION_SECRET_KEY
|
||||
# None of them appear in git; they are not managed (or pruned) by Flux.
|
||||
- postgres-init.yaml
|
||||
- postgres.yaml
|
||||
- odoo-init.yaml
|
||||
- odoo.yaml
|
||||
- metabase.yaml
|
||||
- httproute.yaml
|
||||
106
apps/base/farrisilk/metabase.yaml
Normal file
106
apps/base/farrisilk/metabase.yaml
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
# Metabase for the lab replica — its own state in the SAME plain Postgres
|
||||
# (database `metabase`), one data source: `farrisilk odoo` as `metabase_ro`.
|
||||
#
|
||||
# This is a SECOND instance next to the evaluation one in namespace `metabase`.
|
||||
# The laptop is on a marginal USB-C supply, so it does not repeat that
|
||||
# instance's 1.5 GiB heap: 1 GiB heap, 2 GiB container limit.
|
||||
#
|
||||
# MB_ENCRYPTION_SECRET_KEY is set here on purpose. Without it Metabase encrypts
|
||||
# stored data-source passwords with a key derived from its own default, so a
|
||||
# copy of the app DB is enough to read them. The key lives in Secret
|
||||
# `farrisilk/metabase-secret-key` and must stay stable for the life of the app
|
||||
# DB — rotating it makes every stored datasource password undecryptable.
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: metabase
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: metabase
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: metabase
|
||||
app.kubernetes.io/part-of: farrisilk
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: siriussec
|
||||
tolerations:
|
||||
- key: dedicated
|
||||
operator: Exists
|
||||
effect: PreferNoSchedule
|
||||
containers:
|
||||
- name: metabase
|
||||
image: metabase/metabase:v0.65.6.3
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
env:
|
||||
- name: JAVA_OPTS
|
||||
value: "-Xmx1024m"
|
||||
- name: MB_DB_TYPE
|
||||
value: postgres
|
||||
- name: MB_DB_HOST
|
||||
value: pg.farrisilk.svc.cluster.local
|
||||
- name: MB_DB_PORT
|
||||
value: "5432"
|
||||
- name: MB_DB_DBNAME
|
||||
value: metabase
|
||||
- name: MB_DB_USER
|
||||
value: metabase
|
||||
- name: MB_DB_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-users
|
||||
key: metabase_password
|
||||
- name: MB_ENCRYPTION_SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: metabase-secret-key
|
||||
key: MB_ENCRYPTION_SECRET_KEY
|
||||
- name: MB_JETTY_PORT
|
||||
value: "3000"
|
||||
- name: TZ
|
||||
value: America/Los_Angeles
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/health
|
||||
port: http
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 6
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /api/health
|
||||
port: http
|
||||
initialDelaySeconds: 120
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 1Gi
|
||||
limits:
|
||||
cpu: "2"
|
||||
memory: 2Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: metabase
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: metabase
|
||||
ports:
|
||||
- name: http
|
||||
port: 3000
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
7
apps/base/farrisilk/namespace.yaml
Normal file
7
apps/base/farrisilk/namespace.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: farrisilk
|
||||
labels:
|
||||
app.kubernetes.io/part-of: farrisilk
|
||||
sirius.dev/purpose: lab-replica-of-client-stack
|
||||
164
apps/base/farrisilk/odoo-init.yaml
Normal file
164
apps/base/farrisilk/odoo-init.yaml
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
# Odoo provisioning, run as an initContainer on every pod start — idempotent by
|
||||
# construction, so a restart never re-initialises a live database.
|
||||
#
|
||||
# 1. wait for Postgres
|
||||
# 2. if the `farrisilk` database has no tables: `odoo -i base,web
|
||||
# --without-demo=all --stop-after-init` (the "init once" step, done by the
|
||||
# pod rather than by a separate Job so there is exactly one thing to wait
|
||||
# on and no ordering race between a Job and the Deployment)
|
||||
# 3. CREATE EXTENSION unaccent, as the database owner
|
||||
# 4. (re)apply the read-only BI grants over every table Odoo just created,
|
||||
# including revoking the tables that carry credentials
|
||||
# 5. set the admin login/password from Secret `farrisilk/odoo-admin`
|
||||
#
|
||||
# Step 4 runs unconditionally, not only on first install: it is what picks up
|
||||
# tables added by a later module install (`-i`/`-u` from /mnt/extra-addons), and
|
||||
# `ALTER DEFAULT PRIVILEGES` alone does not cover tables created before the
|
||||
# grant. Nothing here writes a credential to stdout.
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: odoo-init
|
||||
namespace: farrisilk
|
||||
data:
|
||||
init_db.py: |
|
||||
#!/usr/bin/env python3
|
||||
"""Idempotent first-run provisioning of the Farrisilk lab Odoo database."""
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
import psycopg2
|
||||
|
||||
HOST = os.environ["DB_HOST"]
|
||||
PORT = int(os.environ.get("DB_PORT", "5432"))
|
||||
SUPER_USER = os.environ["PG_SUPERUSER"]
|
||||
SUPER_PW = os.environ["PG_SUPERPASS"]
|
||||
DB = os.environ.get("ODOO_DB_NAME", "farrisilk")
|
||||
CONF = "/etc/odoo-runtime/odoo.conf"
|
||||
ADMIN_LOGIN = os.environ["ODOO_ADMIN_LOGIN"]
|
||||
ADMIN_PASSWORD = os.environ["ODOO_ADMIN_PASSWORD"]
|
||||
|
||||
# Tables that hold credentials looking like data. `ir_config_parameter` is
|
||||
# the one the card calls out (API keys/tokens for integrations); the rest
|
||||
# are the same class of column. `res_users` is deliberately NOT in this
|
||||
# list: it carries a password *hash* only, and Metabase needs it for user
|
||||
# counts. Everything found by inspection at runtime is added and logged.
|
||||
CREDENTIAL_TABLES = [
|
||||
"ir_config_parameter",
|
||||
"ir_mail_server",
|
||||
"fetchmail_server",
|
||||
"res_users_apikeys",
|
||||
"payment_provider",
|
||||
"res_users_identitycheck",
|
||||
]
|
||||
|
||||
def connect(dbname, user, password):
|
||||
conn = psycopg2.connect(
|
||||
host=HOST, port=PORT, dbname=dbname, user=user, password=password,
|
||||
connect_timeout=10,
|
||||
)
|
||||
conn.autocommit = True
|
||||
return conn
|
||||
|
||||
def wait_for_pg():
|
||||
for _ in range(90):
|
||||
try:
|
||||
connect("postgres", SUPER_USER, SUPER_PW).close()
|
||||
return
|
||||
except psycopg2.Error:
|
||||
time.sleep(2)
|
||||
sys.exit("postgres unreachable")
|
||||
|
||||
def tables(cur):
|
||||
cur.execute(
|
||||
"select table_name from information_schema.tables "
|
||||
"where table_schema = 'public' and table_type = 'BASE TABLE'"
|
||||
)
|
||||
return {r[0] for r in cur.fetchall()}
|
||||
|
||||
def run(cmd, **kw):
|
||||
print("+ " + " ".join(cmd), flush=True)
|
||||
subprocess.run(cmd, check=True, **kw)
|
||||
|
||||
wait_for_pg()
|
||||
|
||||
conn = connect("postgres", SUPER_USER, SUPER_PW)
|
||||
cur = conn.cursor()
|
||||
cur.execute("select 1 from pg_database where datname = %s", (DB,))
|
||||
exists = cur.fetchone() is not None
|
||||
conn.close()
|
||||
|
||||
have_tables = False
|
||||
if exists:
|
||||
dconn = connect(DB, SUPER_USER, SUPER_PW)
|
||||
dcur = dconn.cursor()
|
||||
have_tables = bool(tables(dcur))
|
||||
dconn.close()
|
||||
|
||||
if not have_tables:
|
||||
print(f"== initialising {DB}: base,web (no demo data) ==", flush=True)
|
||||
run(["odoo", "-c", CONF, "-d", DB, "-i", "base,web",
|
||||
"--without-demo=all", "--stop-after-init", "--no-http"])
|
||||
else:
|
||||
print(f"== {DB} already initialised: skipping -i base ==", flush=True)
|
||||
|
||||
# unaccent as the database owner (trusted extension in PG16). Odoo uses it
|
||||
# for accent-insensitive search in the web client.
|
||||
oconn = connect(DB, "odoo", os.environ["ODOO_DB_PASSWORD"])
|
||||
ocur = oconn.cursor()
|
||||
ocur.execute("CREATE EXTENSION IF NOT EXISTS unaccent")
|
||||
ocur.execute("select extname, extowner::regrole::text from pg_extension where extname = 'unaccent'")
|
||||
print("unaccent:", ocur.fetchone(), flush=True)
|
||||
oconn.close()
|
||||
|
||||
# Read-only BI grants + credential-table revokes.
|
||||
gconn = connect(DB, SUPER_USER, SUPER_PW)
|
||||
gcur = gconn.cursor()
|
||||
gcur.execute("GRANT USAGE ON SCHEMA public TO metabase_ro")
|
||||
gcur.execute("GRANT SELECT ON ALL TABLES IN SCHEMA public TO metabase_ro")
|
||||
gcur.execute(
|
||||
"ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public "
|
||||
"GRANT SELECT ON TABLES TO metabase_ro"
|
||||
)
|
||||
present = tables(gcur)
|
||||
revoked = sorted({t for t in CREDENTIAL_TABLES if t in present})
|
||||
# Inspect rather than assume the static list is complete: anything whose
|
||||
# columns look like credentials is added to the revoke set (logged below).
|
||||
gcur.execute(
|
||||
"select distinct table_name from information_schema.columns "
|
||||
"where table_schema = 'public' and ("
|
||||
" column_name ~ '(^|_)(password|secret|token)($|_)' or "
|
||||
" column_name ~ '(api_key|access_key|private_key)'"
|
||||
") and table_name not in ('res_users', 'res_partner')"
|
||||
)
|
||||
for (t,) in gcur.fetchall():
|
||||
if t in present and t not in revoked:
|
||||
revoked.append(t)
|
||||
revoked = sorted(revoked)
|
||||
for t in revoked:
|
||||
gcur.execute("REVOKE SELECT ON public.%s FROM metabase_ro" % t)
|
||||
gcur.execute(
|
||||
"select table_name from information_schema.table_privileges "
|
||||
"where grantee = 'metabase_ro' and privilege_type = 'SELECT' "
|
||||
"and table_schema = 'public' order by 1"
|
||||
)
|
||||
readable = len(gcur.fetchall())
|
||||
gconn.close()
|
||||
print(f"metabase_ro: SELECT granted on {readable} tables; "
|
||||
f"revoked on {revoked}", flush=True)
|
||||
|
||||
# Admin login/password from Secret farrisilk/odoo-admin. `odoo shell` is
|
||||
# the supported way to set a res.users password without hand-rolling a
|
||||
# pbkdf2 hash. Re-writing the same value on every start is harmless.
|
||||
payload = (
|
||||
"u = env.ref('base.user_admin')\n"
|
||||
f"u.write({{'login': {ADMIN_LOGIN!r}, 'password': {ADMIN_PASSWORD!r}}})\n"
|
||||
"env.cr.commit()\n"
|
||||
"print('admin uid', u.id, 'login', u.login)\n"
|
||||
)
|
||||
run(["odoo", "shell", "-c", CONF, "-d", DB, "--no-http",
|
||||
"--shell-interface=python"], input=payload, text=True)
|
||||
|
||||
print("== provisioning complete ==", flush=True)
|
||||
258
apps/base/farrisilk/odoo.yaml
Normal file
258
apps/base/farrisilk/odoo.yaml
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
# Odoo 18 — the application half of the Farrisilk lab replica.
|
||||
#
|
||||
# Image is pinned to the DATED build, never `18.0`/`latest`: Odoo auto-migrates
|
||||
# its database schema on start, so a floating tag turns a pod restart into an
|
||||
# unplanned upgrade of a database you may be auditing.
|
||||
#
|
||||
# This image already ships wkhtmltopdf 0.12.6.1 (patched Qt) at
|
||||
# /usr/local/bin/wkhtmltopdf, so PDF reports/ invoices render without a derived
|
||||
# image. Verified 2026-11-22 — see README.
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: odoo-data
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
accessModes: [ReadWriteOnce]
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
---
|
||||
# Empty by default. This is where the client's custom modules are copied in
|
||||
# (`kubectl cp ./module farrisilk/<odoo-pod>:/mnt/extra-addons/...`), which is
|
||||
# why it is a PVC and not an emptyDir: a module installed from here must survive
|
||||
# a pod restart, or the modules table and the addons path disagree and Odoo
|
||||
# refuses to start the affected modules.
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: odoo-extra-addons
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
accessModes: [ReadWriteOnce]
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: 5Gi
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: odoo
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: odoo
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: odoo
|
||||
app.kubernetes.io/part-of: farrisilk
|
||||
spec:
|
||||
# Envoy has to reach the backend on the same node it serves from, and the
|
||||
# filestore PVC is local-path (siriussec-only anyway).
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: siriussec
|
||||
tolerations:
|
||||
- key: dedicated
|
||||
operator: Exists
|
||||
effect: PreferNoSchedule
|
||||
initContainers:
|
||||
# Odoo has no env-var support for db_password, so the config file is
|
||||
# rendered from the ConfigMap template + the Secret on every pod start
|
||||
# into an emptyDir. Runs as root only to fix PVC ownership (the image
|
||||
# user is uid 100 / gid 101 and local-path hands out root-owned dirs).
|
||||
- name: render-config
|
||||
image: odoo:18.0-20261112
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
command:
|
||||
- /bin/sh
|
||||
- -ec
|
||||
- |
|
||||
mkdir -p /mnt/extra-addons /var/lib/odoo /etc/odoo-runtime
|
||||
chown -R 100:101 /var/lib/odoo /mnt/extra-addons
|
||||
chmod 0755 /mnt/extra-addons
|
||||
umask 077
|
||||
cat > /etc/odoo-runtime/odoo.conf <<EOF
|
||||
[options]
|
||||
admin_passwd = ${ODOO_ADMIN_PASSWD}
|
||||
addons_path = /mnt/extra-addons,/mnt/enterprise-addons,/usr/lib/python3/dist-packages/odoo/addons
|
||||
data_dir = /var/lib/odoo
|
||||
db_host = ${DB_HOST}
|
||||
db_port = ${DB_PORT}
|
||||
db_name = farrisilk
|
||||
db_user = odoo
|
||||
db_password = ${ODOO_DB_PASSWORD}
|
||||
dbfilter = ^farrisilk\$
|
||||
list_db = False
|
||||
proxy_mode = True
|
||||
workers = 0
|
||||
limit_memory_hard = 1610612736
|
||||
limit_memory_soft = 1342177280
|
||||
max_cron_threads = 1
|
||||
log_level = info
|
||||
log_handler = :INFO
|
||||
xmlrpc_port = 8069
|
||||
EOF
|
||||
chown 100:101 /etc/odoo-runtime/odoo.conf
|
||||
env:
|
||||
- name: DB_HOST
|
||||
value: pg
|
||||
- name: DB_PORT
|
||||
value: "5432"
|
||||
- name: ODOO_DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-users
|
||||
key: odoo_password
|
||||
- name: ODOO_ADMIN_PASSWD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: odoo-config
|
||||
key: admin_passwd
|
||||
volumeMounts:
|
||||
- name: runtime-config
|
||||
mountPath: /etc/odoo-runtime
|
||||
- name: data
|
||||
mountPath: /var/lib/odoo
|
||||
- name: extra-addons
|
||||
mountPath: /mnt/extra-addons
|
||||
# "Init once". Idempotent: reinstalls nothing when the database already
|
||||
# has tables, but always re-applies the BI grants/revokes and the admin
|
||||
# credentials. Script lives in ConfigMap odoo-init.
|
||||
- name: init-db
|
||||
image: odoo:18.0-20261112
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["python3", "/opt/init/init_db.py"]
|
||||
env:
|
||||
- name: DB_HOST
|
||||
value: pg
|
||||
- name: DB_PORT
|
||||
value: "5432"
|
||||
- name: ODOO_DB_NAME
|
||||
value: farrisilk
|
||||
- name: PG_SUPERUSER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-app
|
||||
key: username
|
||||
- name: PG_SUPERPASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-app
|
||||
key: password
|
||||
- name: ODOO_DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-users
|
||||
key: odoo_password
|
||||
- name: ODOO_ADMIN_LOGIN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: odoo-admin
|
||||
key: email
|
||||
- name: ODOO_ADMIN_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: odoo-admin
|
||||
key: password
|
||||
- name: TZ
|
||||
value: America/Los_Angeles
|
||||
volumeMounts:
|
||||
- name: runtime-config
|
||||
mountPath: /etc/odoo-runtime
|
||||
- name: data
|
||||
mountPath: /var/lib/odoo
|
||||
- name: extra-addons
|
||||
mountPath: /mnt/extra-addons
|
||||
- name: enterprise-addons
|
||||
mountPath: /mnt/enterprise-addons
|
||||
- name: init-script
|
||||
mountPath: /opt/init
|
||||
containers:
|
||||
- name: odoo
|
||||
image: odoo:18.0-20261112
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["odoo"]
|
||||
args: ["-c", "/etc/odoo-runtime/odoo.conf"]
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8069
|
||||
env:
|
||||
- name: TZ
|
||||
value: America/Los_Angeles
|
||||
- name: HOST
|
||||
value: 0.0.0.0
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /web/login
|
||||
port: http
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 6
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: http
|
||||
initialDelaySeconds: 90
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 4
|
||||
resources:
|
||||
requests:
|
||||
cpu: 200m
|
||||
memory: 512Mi
|
||||
# workers=0 is a single process; the config's limit_memory_hard is
|
||||
# 1.5 GiB, below this container limit, so Odoo throttles itself
|
||||
# before the kernel OOM-kills the pod.
|
||||
limits:
|
||||
memory: 2Gi
|
||||
volumeMounts:
|
||||
- name: runtime-config
|
||||
mountPath: /etc/odoo-runtime
|
||||
- name: data
|
||||
mountPath: /var/lib/odoo
|
||||
- name: extra-addons
|
||||
mountPath: /mnt/extra-addons
|
||||
- name: enterprise-addons
|
||||
mountPath: /mnt/enterprise-addons
|
||||
volumes:
|
||||
- name: runtime-config
|
||||
emptyDir: {}
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: odoo-data
|
||||
- name: extra-addons
|
||||
persistentVolumeClaim:
|
||||
claimName: odoo-extra-addons
|
||||
# Empty, unused until the Enterprise licence question is answered. It
|
||||
# exists so /mnt/enterprise-addons is already on addons_path the day an
|
||||
# EE addons tree is dropped in, without a manifest change.
|
||||
- name: enterprise-addons
|
||||
emptyDir: {}
|
||||
- name: init-script
|
||||
configMap:
|
||||
name: odoo-init
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: odoo
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: odoo
|
||||
ports:
|
||||
- name: http
|
||||
port: 8069
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
67
apps/base/farrisilk/postgres-init.yaml
Normal file
67
apps/base/farrisilk/postgres-init.yaml
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# First-run provisioning for the lab Postgres: two databases (odoo, metabase)
|
||||
# and three roles. Runs once, from postgres:16's /docker-entrypoint-initdb.d,
|
||||
# only while PGDATA is empty.
|
||||
#
|
||||
# Why an init script instead of POSTGRES_DB/POSTGRES_USER: the stock image only
|
||||
# knows one database and one role, and this namespace needs
|
||||
# - `odoo` : owner of db `odoo`, CREATEDB (Odoo creates its own database
|
||||
# on first `-i base` and needs the privilege to do it)
|
||||
# - `metabase` : owner of db `metabase` (Metabase's own application DB)
|
||||
# - `metabase_ro` : the read-only BI identity used in §4 of the card, with
|
||||
# default_transaction_read_only + a statement timeout. Its
|
||||
# SELECT grants over Odoo's tables are applied AFTER Odoo has
|
||||
# installed them (the odoo Deployment's initContainer), because
|
||||
# at this point the `odoo` database has no tables at all.
|
||||
#
|
||||
# Passwords arrive as env vars from Secret `farrisilk/pg-users` (out of band);
|
||||
# nothing here is a credential literal.
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: pg-init
|
||||
namespace: farrisilk
|
||||
data:
|
||||
01-init-dbs.sh: |
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
: "${ODOO_DB_PASSWORD:?}"
|
||||
: "${METABASE_DB_PASSWORD:?}"
|
||||
: "${METABASE_RO_PASSWORD:?}"
|
||||
|
||||
# Roles + databases. psql autocommits each statement, which CREATE DATABASE
|
||||
# requires (it cannot run inside a transaction block).
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres \
|
||||
-v odoo_pw="$ODOO_DB_PASSWORD" \
|
||||
-v metabase_pw="$METABASE_DB_PASSWORD" \
|
||||
-v ro_pw="$METABASE_RO_PASSWORD" <<'EOSQL'
|
||||
CREATE ROLE odoo LOGIN CREATEDB PASSWORD :'odoo_pw';
|
||||
CREATE ROLE metabase LOGIN PASSWORD :'metabase_pw';
|
||||
CREATE ROLE metabase_ro LOGIN PASSWORD :'ro_pw' CONNECTION LIMIT 10;
|
||||
|
||||
-- Read-only BI identity: these are role-level defaults, so they hold for
|
||||
-- every session Metabase opens, including ones it recycles.
|
||||
ALTER ROLE metabase_ro SET default_transaction_read_only = on;
|
||||
ALTER ROLE metabase_ro SET statement_timeout = '60s';
|
||||
ALTER ROLE metabase_ro SET idle_in_transaction_session_timeout = '60s';
|
||||
|
||||
CREATE DATABASE odoo OWNER odoo;
|
||||
CREATE DATABASE metabase OWNER metabase;
|
||||
|
||||
-- No cross-tenant CONNECT: the BI role reaches `odoo` only, the Metabase
|
||||
-- application role never reaches `odoo`. (PUBLIC carries CONNECT on every
|
||||
-- new database, which is the usual way a "read-only" role ends up able to
|
||||
-- reach databases it was never granted.)
|
||||
REVOKE CONNECT ON DATABASE odoo FROM PUBLIC;
|
||||
GRANT CONNECT ON DATABASE odoo TO odoo, metabase_ro;
|
||||
REVOKE CONNECT ON DATABASE metabase FROM PUBLIC;
|
||||
GRANT CONNECT ON DATABASE metabase TO metabase;
|
||||
EOSQL
|
||||
|
||||
# Schema-level setup in the (still empty) odoo database. Table grants and
|
||||
# the credential-table revokes are (re)applied by the odoo initContainer.
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname odoo <<'EOSQL'
|
||||
GRANT USAGE ON SCHEMA public TO metabase_ro;
|
||||
ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public
|
||||
GRANT SELECT ON TABLES TO metabase_ro;
|
||||
EOSQL
|
||||
140
apps/base/farrisilk/postgres.yaml
Normal file
140
apps/base/farrisilk/postgres.yaml
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
# Plain PostgreSQL 16 — deliberately NOT CloudNativePG.
|
||||
#
|
||||
# The client runs Odoo against a plain Postgres on a Proxmox VM. This namespace
|
||||
# is a *lab replica of that shape*, so the database is a bare container with a
|
||||
# single local-path volume, no operator, no replicas, no WAL archive. Do not
|
||||
# "improve" this into a CNPG Cluster: the point is to develop and audit against
|
||||
# the client's actual architecture, not ours.
|
||||
#
|
||||
# Known gap (stated plainly on purpose): there are NO backups of this database.
|
||||
# The client's practice is a cron-driven `pg_dump` of the DB only; that mirrors
|
||||
# into a separate follow-up card for this namespace, and no PITR/barman story
|
||||
# is being invented here.
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: pg-data
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
accessModes: [ReadWriteOnce]
|
||||
storageClassName: local-path
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: pg
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
replicas: 1
|
||||
# RWO volume: two pods must never hold the data directory at once.
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: pg
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: pg
|
||||
app.kubernetes.io/part-of: farrisilk
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/hostname: siriussec
|
||||
tolerations:
|
||||
- key: dedicated
|
||||
operator: Exists
|
||||
effect: PreferNoSchedule
|
||||
containers:
|
||||
- name: postgres
|
||||
image: postgres:16
|
||||
imagePullPolicy: IfNotPresent
|
||||
args: ["-c", "max_connections=60"]
|
||||
ports:
|
||||
- name: postgres
|
||||
containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-app
|
||||
key: username
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-app
|
||||
key: password
|
||||
# The bootstrap superuser's own database. `odoo` and `metabase` are
|
||||
# created by the init script below.
|
||||
- name: POSTGRES_DB
|
||||
value: postgres
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
# Consumed only by 01-init-dbs.sh on first start.
|
||||
- name: ODOO_DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-users
|
||||
key: odoo_password
|
||||
- name: METABASE_DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-users
|
||||
key: metabase_password
|
||||
- name: METABASE_RO_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: pg-users
|
||||
key: metabase_ro_password
|
||||
- name: TZ
|
||||
value: America/Los_Angeles
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: ["pg_isready", "-U", "postgres", "-d", "postgres"]
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 3
|
||||
livenessProbe:
|
||||
exec:
|
||||
command: ["pg_isready", "-U", "postgres", "-d", "postgres"]
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 20
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 4
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
memory: 1Gi
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: initdb
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: pg-data
|
||||
- name: initdb
|
||||
configMap:
|
||||
name: pg-init
|
||||
defaultMode: 0555
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: pg
|
||||
namespace: farrisilk
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: pg
|
||||
ports:
|
||||
- name: postgres
|
||||
port: 5432
|
||||
targetPort: postgres
|
||||
protocol: TCP
|
||||
|
|
@ -7,3 +7,4 @@ resources:
|
|||
- ../base/sirius-growth
|
||||
- ../base/osint
|
||||
- ../base/metabase
|
||||
- ../base/farrisilk
|
||||
|
|
|
|||
Loading…
Reference in a new issue