libretranslate

by f3k-tech

Helm chartv1.165.1App v1.6.5Verified publisher

Libretranslate Helm chart for Kubernetes

About this chart

LibreTranslate Helm Chart

Table of Contents

  • Repository
  • Arguments
  • Autoscaling and Persistent Storage
    • Sticky Sessions and Persistent Volumes
      • Option 1: Sticky Sessions
      • Option 2: Persistent Volume
  • Health Checks
    • Sample Probe Configurations

Repository

NameUrl
Contributehttps://github.com/f3k-tech/helm/tree/main/charts/libretranslate
Issueshttps://github.com/f3k-tech/helm/issues

Arguments

You can add arguments like this:

args:
  - --ssl
  - --update-models
  - --load-only
  - en,de,fr,hu,nl,tr

Autoscaling and Persistent Storage

Important: When using HPA with persistent storage, it's recommended to deploy a single pod to download the initial language files. Once the language files have been downloaded you can deploy more pods.

  • Make sure to use ReadWriteMany (RWX) when using the autoscaler in combination with persistent storage.
  • If you experience problems with languages not showing or want to make sure to have the latest language files, use the --update-models flag.

Sticky Sessions and Persistent Volumes

To manage translated files stored in /tmp/libretranslate-files-translate, you can use sticky sessions or mount a persistent volume. This is crucial for maintaining access to temporary files generated during file translation.

Sticky sessions provide an easier, straightforward solution for maintaining user session consistency, especially for stateful applications. However, they can constrain the flexibility and efficiency of autoscaling by tying sessions to specific pods, potentially leading to uneven load distribution and reduced fault tolerance. For scenarios requiring optimal autoscaling and resilience, leveraging shared persistent storage might be a more suitable approach, despite its greater complexity.

Option 1: Sticky Sessions

Enable sticky sessions to route requests from the same client to the same pod, ensuring consistent access to temporary stateful data across requests.

  • Traefik: Add to service.annotations in values:
service:
  annotations:
    traefik.ingress.kubernetes.io/service.sticky.cookie: "true"
  • Nginx: Add to ingress.annotations in values:
ingress:
  annotations:
    nginx.ingress.kubernetes.io/affinity: "cookie"
    nginx.ingress.kubernetes.io/session-cookie-name: "libretranslate-session"
    nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
    nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"

Option 2: Persistent Volume

For applications using Horizontal Pod Autoscaling (HPA), attach a Persistent Volume with ReadWriteMany (RWX) access to your pods. This allows all pods to share language files, facilitating consistent translations and quick scaling.

To ensure new pods have immediate access to language files, enable persistence.filesTranslate:

persistence:
  filesTranslate:
    enabled: true
    accessMode: ReadWriteMany

Health Checks

If language file downloads extend beyond the initial startup, readiness and liveness probes may fail. Adjust probe settings according to your network speed or disable them temporarily during the first deployment with persistent storage.

Sample Probe Configurations

10Mb/s

  initialDelaySeconds: 60
  periodSeconds: 30
  failureThreshold: 600
  successThreshold: 1
  timeoutSeconds: 5

100Mb/s

  initialDelaySeconds: 60
  periodSeconds: 30
  failureThreshold: 60
  successThreshold: 1
  timeoutSeconds: 5

1000Mb/s

  initialDelaySeconds: 60
  periodSeconds: 15
  failureThreshold: 12
  successThreshold: 1
  timeoutSeconds: 5

Deploy libretranslate with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has libretranslate on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartlibretranslate is pinned at v1.165.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply