diff --git a/kubernetes/README.md b/kubernetes/README.md new file mode 100644 index 0000000..f2f826b --- /dev/null +++ b/kubernetes/README.md @@ -0,0 +1,7 @@ +# Kubernetes + +This folder represents deployments for various Kubernetes distributions. + +## K3s + +K3s uses Traefik internally so this implementation targets it. diff --git a/kubernetes/k3s/Chart.yaml b/kubernetes/k3s/Chart.yaml new file mode 100644 index 0000000..4bf311b --- /dev/null +++ b/kubernetes/k3s/Chart.yaml @@ -0,0 +1,6 @@ +name: myytdownloader +type: application +version: "1.0" +appVersion: v1.0.0 +apiVersion: v1 +description: Helm chart for yt-dlp-web-ui. diff --git a/kubernetes/k3s/charts/yt-downloader/Chart.yaml b/kubernetes/k3s/charts/yt-downloader/Chart.yaml new file mode 100644 index 0000000..4bf311b --- /dev/null +++ b/kubernetes/k3s/charts/yt-downloader/Chart.yaml @@ -0,0 +1,6 @@ +name: myytdownloader +type: application +version: "1.0" +appVersion: v1.0.0 +apiVersion: v1 +description: Helm chart for yt-dlp-web-ui. diff --git a/kubernetes/k3s/charts/yt-downloader/templates/cm.yaml b/kubernetes/k3s/charts/yt-downloader/templates/cm.yaml new file mode 100644 index 0000000..dded228 --- /dev/null +++ b/kubernetes/k3s/charts/yt-downloader/templates/cm.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader + name: yt-downloader-cm + namespace: yt-downloader +data: + settings: | + session_file_path: /session diff --git a/kubernetes/k3s/charts/yt-downloader/templates/deployment.yaml b/kubernetes/k3s/charts/yt-downloader/templates/deployment.yaml new file mode 100644 index 0000000..623c1b2 --- /dev/null +++ b/kubernetes/k3s/charts/yt-downloader/templates/deployment.yaml @@ -0,0 +1,58 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: yt-downloader-deployment + namespace: yt-downloader + labels: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader +spec: + selector: + matchLabels: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader + replicas: 1 + template: + metadata: + labels: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader + spec: + containers: + - name: yt-downloader + image: docker.io/marcobaobao/yt-dlp-webui@sha256:5be29ff9b08d8633f47bf1c4084109b8e6a71dfbb41fa974620dbe3324868775 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 3033 + name: app-port + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + privileged: false + runAsGroup: 1000 + runAsUser: 1001 + volumeMounts: + - name: config-root + mountPath: "/config" + - name: config-yaml + mountPath: "/config/config.yml" + subPath: settings + - name: downloads + mountPath: "/downloads" + - name: session + mountPath: "/session" + volumes: + - name: config-root + persistentVolumeClaim: + claimName: yt-downloader-pvc-config-root + - name: config-yaml + configMap: + name: yt-downloader-cm + - name: downloads + persistentVolumeClaim: + claimName: yt-downloader-pvc-downloads + - name: session + persistentVolumeClaim: + claimName: yt-downloader-pvc-session diff --git a/kubernetes/k3s/charts/yt-downloader/templates/ingress.yaml b/kubernetes/k3s/charts/yt-downloader/templates/ingress.yaml new file mode 100644 index 0000000..f5813c5 --- /dev/null +++ b/kubernetes/k3s/charts/yt-downloader/templates/ingress.yaml @@ -0,0 +1,33 @@ +# Awesome - works now with this middleware. +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: strip-double-slash + namespace: yt-downloader +spec: + replacePathRegex: + regex: /{2,} + replacement: / +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: yt-downloader-ingress + namespace: yt-downloader + annotations: + kubernetes.io/ingress.class: traefik + traefik.ingress.kubernetes.io/websocket: "true" + traefik.ingress.kubernetes.io/router.middlewares: kube-system-strip-prefix@kubernetescrd,yt-downloader-strip-double-slash@kubernetescrd +spec: + rules: + - host: my.hostname + http: + paths: + - path: /yt + pathType: ImplementationSpecific + backend: + service: + name: yt-downloader-svc + port: + number: 90 + diff --git a/kubernetes/k3s/charts/yt-downloader/templates/pvc.yaml b/kubernetes/k3s/charts/yt-downloader/templates/pvc.yaml new file mode 100644 index 0000000..18ad115 --- /dev/null +++ b/kubernetes/k3s/charts/yt-downloader/templates/pvc.yaml @@ -0,0 +1,46 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader + name: yt-downloader-pvc-downloads + namespace: yt-downloader +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "250Mi" + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader + name: yt-downloader-pvc-session + namespace: yt-downloader +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "10Mi" + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + labels: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader + name: yt-downloader-pvc-config-root + namespace: yt-downloader +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "10Mi" diff --git a/kubernetes/k3s/charts/yt-downloader/templates/service.yaml b/kubernetes/k3s/charts/yt-downloader/templates/service.yaml new file mode 100644 index 0000000..3d4d9ad --- /dev/null +++ b/kubernetes/k3s/charts/yt-downloader/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: yt-downloader-svc + namespace: yt-downloader + labels: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader +spec: + type: ClusterIP + ports: + - port: 90 + targetPort: 3033 + selector: + app.kubernetes.io/name: yt-downloader + app.kubernetes.io/instance: yt-downloader diff --git a/kubernetes/k3s/charts/yt-downloader/templates/traefik-strip-prefix-middleware.yaml b/kubernetes/k3s/charts/yt-downloader/templates/traefik-strip-prefix-middleware.yaml new file mode 100644 index 0000000..8abbb7d --- /dev/null +++ b/kubernetes/k3s/charts/yt-downloader/templates/traefik-strip-prefix-middleware.yaml @@ -0,0 +1,12 @@ +# This Middleware is necessary to strip prefix for a path in an ingress before forwarding to a service. +# Without it, the whole path is sent to the service. + +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: strip-prefix + namespace: kube-system # can be anything, but needs ingress.metadata.annotations spec: traefik.ingress.kubernetes.io/router.middlewares: namespace-strip-prefix@kubernetescrd +spec: + stripPrefixRegex: + regex: + - ^/[^/]+ diff --git a/kubernetes/k3s/charts/yt-downloader/values.yaml b/kubernetes/k3s/charts/yt-downloader/values.yaml new file mode 100644 index 0000000..5d20567 --- /dev/null +++ b/kubernetes/k3s/charts/yt-downloader/values.yaml @@ -0,0 +1 @@ +yt-downloader: diff --git a/kubernetes/k3s/values.yaml b/kubernetes/k3s/values.yaml new file mode 100644 index 0000000..5d20567 --- /dev/null +++ b/kubernetes/k3s/values.yaml @@ -0,0 +1 @@ +yt-downloader: