tagAudiobookshelf Deployment in Kubernetes
tagPrerequisites
-
Kubernetes Cluster
Ensure you have a Kubernetes cluster running. This deployment assumes you're using nginx as the ingress controller.
-
Ingress Controller (NGINX)
Make sure NGINX ingress controller is installed and configured on your cluster. If you don't have it installed yet, you can follow the official NGINX ingress controller installation guide.
-
Cluster Issuer for Let's Encrypt
You need a ClusterIssuer to automatically manage TLS certificates using Let's Encrypt. Below is an example configuration to create a ClusterIssuer:
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-production
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: your-email@example.com
privateKeySecretRef:
name: letsencrypt-production-key
solvers:
- http01:
ingress:
class: nginx
- Replace your-email@example.com with your own email address.
- This will use HTTP-01 challenge for certificate issuance, with NGINX managing the ingress.
Apply this YAML to your cluster using:
kubectl apply -f cluster-issuer.yaml
- Subdomain Setup (Optional) If you want to use a subdomain, set up your DNS records to point to your Kubernetes cluster. In this case, I am using OVH as my DNS provider. Create an A record for your subdomain pointing to your cluster’s IP address.
tagCreate Namespace for Audiobookshelf
First, create a dedicated namespace for Audiobookshelf:
apiVersion: v1
kind: Namespace
metadata:
name: audiobookshelf-ns
Apply the namespace with:
kubectl apply -f namespace.yaml
tagAudiobookshelf Kubernetes Deployment
tag1. Audiobookshelf Service
Defines a service that exposes the Audiobookshelf application within the cluster:
apiVersion: v1
kind: Service
metadata:
name: audiobookshelf
namespace: audiobookshelf-ns
spec:
selector:
app: audiobookshelf
ports:
- protocol: TCP
port: 80
targetPort: 80
type: ClusterIP
tag2. Audiobookshelf Ingress
Configures access to the Audiobookshelf service via a domain name and sets up TLS encryption:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: audiobookshelf-ingress
namespace: audiobookshelf-ns
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
acme.cert-manager.io/http01-ingress-class: public
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-body-size: 2048m
spec:
rules:
- host: audiobooks.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: audiobookshelf
port:
number: 80
tls:
- hosts:
- audiobooks.example.com
secretName: audiobookshelf-tls
tag3. Audiobookshelf Deployment
Deploys the Audiobookshelf application with volume mounts for storing audiobooks, podcasts, and configuration files:
apiVersion: apps/v1
kind: Deployment
metadata:
name: audiobookshelf
namespace: audiobookshelf-ns
spec:
replicas: 1
selector:
matchLabels:
app: audiobookshelf
template:
metadata:
labels:
app: audiobookshelf
spec:
containers:
- name: audiobookshelf
image: ghcr.io/advplyr/audiobookshelf:latest
ports:
- containerPort: 80
volumeMounts:
- name: audiobooks-volume
mountPath: /audiobooks
- name: podcasts-volume
mountPath: /podcasts
- name: config-volume
mountPath: /config
- name: metadata-volume
mountPath: /metadata
volumes:
- name: audiobooks-volume
hostPath:
path: /YOUR_PATH/audiobooks/
- name: podcasts-volume
hostPath:
path: /YOUR_PATH//podcasts
- name: config-volume
hostPath:
path: /YOUR_PATH//audiobookshelf
- name: metadata-volume
hostPath:
path: /YOUR_PATH/metadata
Apply the full manifest:
kubectl apply -f audiobookshelf-manifest.yaml
Verify that the services, ingress, and deployment are running:
kubectl get all -n audiobookshelf-ns
kubectl describe ingress audiobookshelf-ingress -n audiobookshelf-ns