Skip to content

Commit 1effff1

Browse files
vitoficoclaude
andcommitted
🔧 chore(deploy): co-deploy opds-sync in calibre-web namespace
Drop Authentik prereq, drop separate ingress (path-routed under CWA's existing Ingress on ebooks.theficos.dedyn.io). Postgres renamed to postgres-opds-sync to avoid namespace collisions. Operations doc replaced. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c0c83e5 commit 1effff1

13 files changed

Lines changed: 122 additions & 148 deletions

deploy/k8s/opds-sync/README.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# opds-sync deploy
22

3-
Apply order on first deploy:
3+
Co-deployed with Calibre-Web-Automated in the `calibre-web` namespace.
4+
opds-sync proxies user authentication to CWA.
5+
6+
## Prerequisites
7+
8+
- CWA running in the `calibre-web` namespace, exposing port 8083 to the
9+
`app: calibre-web` pod label.
10+
- The Android client uses the same Basic credentials for CWA OPDS and
11+
for opds-sync; no separate sign-in.
12+
13+
## Apply order
414

515
1. Create the encrypted secret (SOPS) and apply it:
616

@@ -15,19 +25,19 @@ Apply order on first deploy:
1525

1626
3. Verify:
1727

18-
kubectl -n opds-sync rollout status deploy/opds-sync
19-
curl https://sync.theficos.dedyn.io/sync/v1/healthz
20-
21-
## Authentik prerequisite
28+
kubectl -n calibre-web rollout status deploy/opds-sync
29+
curl https://ebooks.theficos.dedyn.io/sync/v1/healthz
2230

23-
Create an OAuth2 application in Authentik **before** deploying:
31+
## Adding the path rule to CWA's Ingress
2432

25-
- Name: Quire
26-
- Slug: quire
27-
- Provider type: OAuth2/OpenID
28-
- Client type: **Public**
29-
- PKCE: required
30-
- Redirect URIs: `quire://oauth`
31-
- Audience: `quire`
33+
opds-sync is served by CWA's existing Ingress at `ebooks.theficos.dedyn.io`.
34+
Add this path rule to the CWA Ingress (in `theficos-cluster/applications/calibre-web/ingress.yaml`)
35+
**before** the catch-all `/` rule:
3236

33-
The audience must match `OPDS_SYNC_AUTHENTIK_AUDIENCE`.
37+
- path: /sync/
38+
pathType: Prefix
39+
backend:
40+
service:
41+
name: opds-sync
42+
port:
43+
number: 80

deploy/k8s/opds-sync/deployment.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: opds-sync
5-
namespace: opds-sync
5+
namespace: calibre-web
66
spec:
77
replicas: 1
88
selector:
@@ -28,10 +28,8 @@ spec:
2828
env:
2929
- name: OPDS_SYNC_DATABASE_URL
3030
valueFrom: { secretKeyRef: { name: opds-sync-secrets, key: database-url } }
31-
- name: OPDS_SYNC_AUTHENTIK_ISSUER
32-
valueFrom: { secretKeyRef: { name: opds-sync-secrets, key: authentik-issuer } }
33-
- name: OPDS_SYNC_AUTHENTIK_AUDIENCE
34-
valueFrom: { secretKeyRef: { name: opds-sync-secrets, key: authentik-audience } }
31+
- name: OPDS_SYNC_CWA_BASE_URL
32+
value: http://calibre-web.calibre-web.svc.cluster.local:8083
3533
- name: OPDS_SYNC_LOG_LEVEL
3634
value: INFO
3735
readinessProbe:

deploy/k8s/opds-sync/ingress.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

deploy/k8s/opds-sync/kustomization.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
3-
namespace: opds-sync
3+
namespace: calibre-web
44

55
resources:
6-
- namespace.yaml
76
- postgres-pvc.yaml
87
- postgres-service.yaml
98
- postgres-statefulset.yaml
109
- service.yaml
1110
- deployment.yaml
12-
- ingress.yaml
1311
- network-policies.yaml
1412

1513
images:

deploy/k8s/opds-sync/namespace.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

deploy/k8s/opds-sync/network-policies.yaml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
apiVersion: networking.k8s.io/v1
22
kind: NetworkPolicy
3-
metadata:
4-
name: deny-all-default
5-
namespace: opds-sync
6-
spec:
7-
podSelector: {}
8-
policyTypes: [Ingress, Egress]
9-
---
10-
apiVersion: networking.k8s.io/v1
11-
kind: NetworkPolicy
123
metadata:
134
name: opds-sync-allow
14-
namespace: opds-sync
5+
namespace: calibre-web
156
spec:
167
podSelector:
178
matchLabels:
@@ -28,24 +19,31 @@ spec:
2819
- to:
2920
- podSelector:
3021
matchLabels:
31-
app: postgres
22+
app: postgres-opds-sync
3223
ports:
3324
- port: 5432
25+
# Talk to CWA in the same namespace.
26+
- to:
27+
- podSelector:
28+
matchLabels:
29+
app: calibre-web
30+
ports:
31+
- port: 8083
32+
# DNS
3433
- to: []
3534
ports:
3635
- port: 53
3736
protocol: UDP
38-
- port: 443
3937
---
4038
apiVersion: networking.k8s.io/v1
4139
kind: NetworkPolicy
4240
metadata:
43-
name: postgres-allow
44-
namespace: opds-sync
41+
name: postgres-opds-sync-allow
42+
namespace: calibre-web
4543
spec:
4644
podSelector:
4745
matchLabels:
48-
app: postgres
46+
app: postgres-opds-sync
4947
policyTypes: [Ingress]
5048
ingress:
5149
- from:

deploy/k8s/opds-sync/postgres-pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: PersistentVolumeClaim
33
metadata:
44
name: opds-sync-postgres
5-
namespace: opds-sync
5+
namespace: calibre-web
66
spec:
77
accessModes: ["ReadWriteOnce"]
88
resources:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: postgres
5-
namespace: opds-sync
4+
name: postgres-opds-sync
5+
namespace: calibre-web
66
spec:
77
type: ClusterIP
88
selector:
9-
app: postgres
9+
app: postgres-opds-sync
1010
ports:
1111
- port: 5432
1212
targetPort: 5432

deploy/k8s/opds-sync/postgres-statefulset.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
apiVersion: apps/v1
22
kind: StatefulSet
33
metadata:
4-
name: postgres
5-
namespace: opds-sync
4+
name: postgres-opds-sync
5+
namespace: calibre-web
66
spec:
7-
serviceName: postgres
7+
serviceName: postgres-opds-sync
88
replicas: 1
99
selector:
1010
matchLabels:
11-
app: postgres
11+
app: postgres-opds-sync
1212
template:
1313
metadata:
1414
labels:
15-
app: postgres
15+
app: postgres-opds-sync
1616
spec:
1717
containers:
1818
- name: postgres
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# Template. Copy to secret.yaml, fill in, then `sops --encrypt --in-place secret.yaml`.
2-
# Apply manually: kubectl apply -f secret.yaml
2+
# Apply manually: sops --decrypt secret.yaml | kubectl apply -f -
33
apiVersion: v1
44
kind: Secret
55
metadata:
66
name: opds-sync-secrets
7-
namespace: opds-sync
7+
namespace: calibre-web
88
type: Opaque
99
stringData:
1010
postgres-user: opds_sync
1111
postgres-password: REPLACE_ME
12-
database-url: postgresql+asyncpg://opds_sync:REPLACE_ME@postgres.opds-sync.svc.cluster.local:5432/opds_sync
13-
authentik-issuer: https://auth.theficos.dedyn.io/application/o/quire/
14-
authentik-audience: quire
12+
database-url: postgresql+asyncpg://opds_sync:REPLACE_ME@postgres-opds-sync.calibre-web.svc.cluster.local:5432/opds_sync

0 commit comments

Comments
 (0)