From 9ef96af4a55475de908d07b7203bd080fa4405c2 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 22 Feb 2024 16:47:51 -0300 Subject: [PATCH] add calibre server --- charts/calibre-server/Chart.yaml | 13 +++ charts/calibre-server/README.md | 17 ++++ .../calibre-server/templates/deployment.yaml | 84 +++++++++++++++++++ .../templates/ingress-route.yaml | 35 ++++++++ .../calibre-server/templates/middleware.yaml | 30 +++++++ .../templates/persistant-volume-claim.yaml | 20 +++++ .../templates/service-account.yaml | 12 +++ charts/calibre-server/templates/service.yaml | 46 ++++++++++ charts/calibre-server/values.yaml | 42 ++++++++++ 9 files changed, 299 insertions(+) create mode 100644 charts/calibre-server/Chart.yaml create mode 100644 charts/calibre-server/README.md create mode 100644 charts/calibre-server/templates/deployment.yaml create mode 100644 charts/calibre-server/templates/ingress-route.yaml create mode 100644 charts/calibre-server/templates/middleware.yaml create mode 100644 charts/calibre-server/templates/persistant-volume-claim.yaml create mode 100644 charts/calibre-server/templates/service-account.yaml create mode 100644 charts/calibre-server/templates/service.yaml create mode 100644 charts/calibre-server/values.yaml diff --git a/charts/calibre-server/Chart.yaml b/charts/calibre-server/Chart.yaml new file mode 100644 index 0000000..758d3bc --- /dev/null +++ b/charts/calibre-server/Chart.yaml @@ -0,0 +1,13 @@ +apiVersion: v2 +name: calibre-server +version: 0.0.1 +description: Chart for Calibre content database +keywords: + - media + - books +sources: + - https://github.com/kovidgoyal/calibre +maintainers: + - name: alexlebens +icon: https://raw.githubusercontent.com/kovidgoyal/calibre/master/resources/images/lt.png +appVersion: 7.5.1 diff --git a/charts/calibre-server/README.md b/charts/calibre-server/README.md new file mode 100644 index 0000000..a69cf68 --- /dev/null +++ b/charts/calibre-server/README.md @@ -0,0 +1,17 @@ +## Introduction + +[Calibre](https://calibre-ebook.com/) + +calibre is an e-book manager. It can view, convert, edit and catalog e-books in all of the major e-book formats. It can also talk to e-book reader devices. It can go out to the internet and fetch metadata for your books. It can download newspapers and convert them into e-books for convenient reading. + +This chart bootstraps a [Calibre](https://github.com/home-assistant) deployment on a [Kubernetes](https://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes +- Helm +- Traefik v2 / IngressRoute + +## Parameters + +See the [values files](values.yaml). diff --git a/charts/calibre-server/templates/deployment.yaml b/charts/calibre-server/templates/deployment.yaml new file mode 100644 index 0000000..d0334b6 --- /dev/null +++ b/charts/calibre-server/templates/deployment.yaml @@ -0,0 +1,84 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: calibre-server + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: {{ .Release.Name }} + app.kubernetes.io/managed-by: helm +spec: + revisionHistoryLimit: 3 + replicas: {{ .Values.deployment.replicas }} + strategy: + type: {{ .Values.deployment.strategy }} + selector: + matchLabels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + serviceAccountName: calibre-server + automountServiceAccountToken: true + containers: + - name: {{ .Release.Name }} + image: "{{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }}" + imagePullPolicy: {{ .Values.deployment.image.imagePullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.http.port }} + protocol: TCP + - name: content + containerPort: {{ .Values.service.content.port }} + protocol: TCP + env: + {{- range $k,$v := .Values.deployment.env }} + - name: {{ $k }} + value: {{ $v | quote }} + {{- end }} + {{- with .Values.deployment.envFrom }} + envFrom: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - mountPath: /config + name: calibre-server-config + - mountPath: /books + name: calibre-server-books + resources: + {{- toYaml .Values.deployment.resources | nindent 12 }} + livenessProbe: + tcpSocket: + port: {{ .Values.service.http.port }} + initialDelaySeconds: 0 + failureThreshold: 3 + timeoutSeconds: 1 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: {{ .Values.service.http.port }} + initialDelaySeconds: 0 + failureThreshold: 3 + timeoutSeconds: 1 + periodSeconds: 10 + startupProbe: + tcpSocket: + port: {{ .Values.service.http.port }} + initialDelaySeconds: 0 + failureThreshold: 30 + timeoutSeconds: 1 + periodSeconds: 5 + volumes: + - name: calibre-server-config + persistentVolumeClaim: + claimName: calibre-server-config + - name: calibre-server-books + persistentVolumeClaim: + claimName: {{ .Values.persistence.books.claimName }} diff --git a/charts/calibre-server/templates/ingress-route.yaml b/charts/calibre-server/templates/ingress-route.yaml new file mode 100644 index 0000000..4f94b6e --- /dev/null +++ b/charts/calibre-server/templates/ingress-route.yaml @@ -0,0 +1,35 @@ +{{- if .Values.ingressRoute.enabled }} +apiVersion: traefik.io/v1alpha1 +kind: IngressRoute +metadata: + name: calibre-server + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: calibre-server + app.kubernetes.io/managed-by: helm +spec: + entryPoints: + - websecure + routes: + - kind: Rule + match: "Host(`{{ .Values.ingressRoute.http.host }}`)" + middlewares: + - name: authentik + namespace: {{ .Release.Namespace }} + priority: 10 + services: + - kind: Service + name: calibre-server + port: {{ .Values.service.http.port }} + - kind: Rule + match: "Host(`{{ .Values.ingressRoute.http.host }}`) && PathPrefix(`/outpost.goauthentik.io/`)" + priority: 15 + services: + - kind: Service + name: {{ .Values.ingressRoute.authentik.outpost }} + port: {{ .Values.ingressRoute.authentik.port }} +{{- end }} diff --git a/charts/calibre-server/templates/middleware.yaml b/charts/calibre-server/templates/middleware.yaml new file mode 100644 index 0000000..a50bc80 --- /dev/null +++ b/charts/calibre-server/templates/middleware.yaml @@ -0,0 +1,30 @@ +{{- if .Values.ingressRoute.enabled }} +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: authentik + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: auth + app.kubernetes.io/part-of: calibre-server + app.kubernetes.io/managed-by: helm +spec: + forwardAuth: + address: "http://{{ .Values.ingressRoute.authentik.outpost }}.authentik:{{ .Values.ingressRoute.authentik.port }}/outpost.goauthentik.io/auth/traefik" + trustForwardHeader: true + authResponseHeaders: + - X-authentik-username + - X-authentik-groups + - X-authentik-email + - X-authentik-name + - X-authentik-uid + - X-authentik-jwt + - X-authentik-meta-jwks + - X-authentik-meta-outpost + - X-authentik-meta-provider + - X-authentik-meta-app + - X-authentik-meta-version +{{- end }} diff --git a/charts/calibre-server/templates/persistant-volume-claim.yaml b/charts/calibre-server/templates/persistant-volume-claim.yaml new file mode 100644 index 0000000..9b9f50a --- /dev/null +++ b/charts/calibre-server/templates/persistant-volume-claim.yaml @@ -0,0 +1,20 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: calibre-server-config + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: {{ .Release.Name }} + app.kubernetes.io/managed-by: helm +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.persistence.config.storageSize }} + storageClassName: {{ .Values.persistence.config.storageClassName }} + volumeMode: {{ .Values.persistence.config.volumeMode }} diff --git a/charts/calibre-server/templates/service-account.yaml b/charts/calibre-server/templates/service-account.yaml new file mode 100644 index 0000000..0d04f13 --- /dev/null +++ b/charts/calibre-server/templates/service-account.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: calibre-server + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: calibre-server + app.kubernetes.io/managed-by: helm diff --git a/charts/calibre-server/templates/service.yaml b/charts/calibre-server/templates/service.yaml new file mode 100644 index 0000000..2e0ce7a --- /dev/null +++ b/charts/calibre-server/templates/service.yaml @@ -0,0 +1,46 @@ +apiVersion: v1 +kind: Service +metadata: + name: calibre-server + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: {{ .Release.Name }} + app.kubernetes.io/managed-by: helm +spec: + type: ClusterIP + ports: + - port: {{ .Values.service.http.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: calibre-server-content + namespace: {{ .Release.Namespace }} + labels: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/version: {{ .Chart.AppVersion }} + app.kubernetes.io/component: web + app.kubernetes.io/part-of: {{ .Release.Name }} + app.kubernetes.io/managed-by: helm +spec: + type: ClusterIP + ports: + - port: {{ .Values.service.content.port }} + targetPort: content + protocol: TCP + name: content + selector: + app.kubernetes.io/name: calibre-server + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/charts/calibre-server/values.yaml b/charts/calibre-server/values.yaml new file mode 100644 index 0000000..77338f4 --- /dev/null +++ b/charts/calibre-server/values.yaml @@ -0,0 +1,42 @@ +deployment: + replicas: 1 + strategy: Recreate + image: + repository: linuxserver/calibre + tag: v7.5.1-ls269 + imagePullPolicy: IfNotPresent + env: + PGID: "1001" + PUID: "1001" + TZ: UTC + UMASK_SET: "022" + CUSTOM_USER: calibre + TITLE: Calibre Server + NO_DECOR: true + envFrom: + resources: + requests: + memory: 256Mi + cpu: 50m + limits: + memory: 1Gi + cpu: 500m +service: + http: + port: 8080 + content: + port: 8081 +ingressRoute: + enabled: true + http: + host: server.calibre.alexlebens.net + authentik: + outpost: authentik-proxy-outpost + port: 9000 +persistence: + config: + storageClassName: ceph-block + storageSize: 5Gi + volumeMode: Filesystem + books: + claimName: