commit 8073a2274b330a9283f677ec205e90db6ab404ca Author: Conan Scott Date: Tue Nov 25 19:11:49 2025 +1100 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf39b75 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Kubernetes deployment of calibre-web + +This is a **Kubernetes** deployment of [calibre-web](https://github.com/janeczku/calibre-web) application which uses [linuxserver/calibre-web](https://hub.docker.com/r/linuxserver/calibre-web) docker image. + +## How to + +**Note** This deployment assumes the Kubernetes cluster runs the [NGINX Ingress Controller](https://kubernetes.github.io/ingress-nginx) as ingress controller. If you use another ingress controller, you will have to adapt `ingress.yml` accordingly. + + git clone https://github.com/devtud/calibre-kubernetes + +Edit `ingress.yml` and replace your domain name on this line: + +```yml + - host: +``` + +Open `deployment.yml` and adapt the two values on the following lines according to your needs (the user id and group id which own the files on the host machine - **do not set it as root!**). + +```yml + - name: PUID + value: "1001" + - name: PGID + value: "1001" +``` + +Apply the Kubernetes resources: + + kubectl apply -f ns.yml + kubectl apply -f pv_books.yml + kubectl apply -f pv_config.yml + kubectl apply -f pvc_books.yml + kubectl apply -f pvc_config.yml + kubectl apply -f deployment.yml + kubectl apply -f service.yml + kubectl apply -f ingress.yml + + +**Important** Even though you can access the deployed `calibre-web` app at your address, you won't be able to use it, because neither the calibre-web app nor the docker image provide a Calibre database. You have to get a Calibre database first and upload it to `/var/data/calibre/books/metadata.db` (note that this is the path on your host machine where the persistent volume [pv_books.yml](pv_books.yml) is pointing to). One way of doing this is to install a fresh Calibre on your computer and copy the `metadata.db` file from your computer to the mentioned path. + +After you open the web interface, in the config screen put the following values: +- `/books` for the db path +- `/usr/bin/ebook-convert` for the converter path +- `/usr/bin/unrar` for the unrar path diff --git a/deployment.yml b/deployment.yml new file mode 100644 index 0000000..16008b5 --- /dev/null +++ b/deployment.yml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: calibre + namespace: calibre + labels: + app: calibre + version: latest + type: third-party + facing: internal +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: calibre + template: + metadata: + labels: + app: calibre + spec: + serviceAccountName: calibre-sa + securityContext: + runAsUser: 0 + runAsGroup: 0 + fsGroup: 0 + containers: + - name: calibre + image: linuxserver/calibre-web:latest + env: + - name: PUID + value: "1001" + - name: PGID + value: "1001" + - name: TZ + value: "Europe/Bucharest" + - name: DOCKER_MODS + value: "linuxserver/calibre-web:calibre" + ports: + - name: "http-port" + containerPort: 8083 + protocol: TCP + volumeMounts: + - name: calibre-config + mountPath: /config + - name: calibre-books + mountPath: /books + resources: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "512Mi" + cpu: "1000m" + volumes: + - name: calibre-config + persistentVolumeClaim: + claimName: calibre-config + - name: calibre-books + persistentVolumeClaim: + claimName: calibre-books diff --git a/ns.yml b/ns.yml new file mode 100644 index 0000000..b12a467 --- /dev/null +++ b/ns.yml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: calibre + labels: + app: calibre + type: third-party + facing: internal diff --git a/pv_books.yml b/pv_books.yml new file mode 100644 index 0000000..dd33c74 --- /dev/null +++ b/pv_books.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: calibre-books + namespace: calibre +spec: + capacity: + storage: 8Gi + nfs: + server: 192.168.0.105 + path: /nfs/NFS/ocp/calibre/books + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: nfs diff --git a/pv_config.yml b/pv_config.yml new file mode 100644 index 0000000..66d214b --- /dev/null +++ b/pv_config.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: calibre-config + namespace: calibre +spec: + capacity: + storage: 500Mi + nfs: + server: 192.168.0.105 + path: /nfs/NFS/ocp/calibre/config + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: nfs diff --git a/pvc_books.yml b/pvc_books.yml new file mode 100644 index 0000000..4833797 --- /dev/null +++ b/pvc_books.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: calibre-books + namespace: calibre +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 8Gi + storageClassName: nfs + volumeName: calibre-books diff --git a/pvc_config.yml b/pvc_config.yml new file mode 100644 index 0000000..7aea955 --- /dev/null +++ b/pvc_config.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: calibre-config + namespace: calibre +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 500Mi + storageClassName: nfs + volumeName: calibre-config diff --git a/route.yaml b/route.yaml new file mode 100644 index 0000000..4cd9b6b --- /dev/null +++ b/route.yaml @@ -0,0 +1,22 @@ +kind: Route +apiVersion: route.openshift.io/v1 +metadata: + name: calibre-route + namespace: calibre + annotations: + cert-manager.io/issuer-kind: ClusterIssuer + cert-manager.io/issuer-name: letsencrypt-dns01-cloudflare +spec: + host: calibre.apilab.us + path: / + to: + kind: Service + name: calibre + weight: 100 + port: + targetPort: http-port + tls: + termination: edge + certificate: + key: + wildcardPolicy: None diff --git a/service.yaml b/service.yaml new file mode 100644 index 0000000..b73bd2c --- /dev/null +++ b/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: calibre + namespace: calibre + labels: + app: calibre +spec: + selector: + app: calibre + ports: + - name: "http-port" + protocol: TCP + targetPort: 8083 + port: 80 +