apiVersion: v1
kind: Namespace
metadata:
  name: jellyfin
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: jellyfin
  namespace: jellyfin
  labels:
    app: jellyfin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jellyfin
  template:
    metadata:
      labels:
        app: jellyfin
    spec:
      containers:
        - name: jellyfin
          image: jellyfin/jellyfin:latest
          ports:
            - containerPort: 8096
              name: http
          volumeMounts:
            - name: config
              mountPath: /config
            - name: cache
              mountPath: /cache
          resources:
            requests:
              memory: "512Mi"
              cpu: "250m"
            limits:
              memory: "2Gi"
              cpu: "2"
      volumes:
        - name: config
          hostPath:
            path: /opt/k3s/jellyfin/config
            type: DirectoryOrCreate
        - name: cache
          hostPath:
            path: /opt/k3s/jellyfin/cache
            type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
  name: jellyfin
  namespace: jellyfin
spec:
  type: ClusterIP
  selector:
    app: jellyfin
  ports:
    - port: 8096
      targetPort: 8096
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: jellyfin
  namespace: jellyfin
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  ingressClassName: traefik
  tls:
    - hosts:
        - jelly.roysland.net
      secretName: jellyfin-tls
  rules:
    - host: jelly.roysland.net
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: jellyfin
                port:
                  number: 8096
