Skip to content

Commit

Permalink
Merge pull request #1 from small-hack/use-existing-secrets
Browse files Browse the repository at this point in the history
allow getting secret data from existing Kubernetes secrets
  • Loading branch information
jessebot authored Nov 10, 2024
2 parents f1b7800 + 7633e4f commit af60787
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/libretranslate/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ sources:
- https://github.com/LibreTranslate/LibreTranslate/
- https://github.com/LibreTranslate/helm-chart/
icon: https://libretranslate.com/static/favicon.ico
version: 0.1.3
version: 0.2.0
4 changes: 4 additions & 0 deletions charts/libretranslate/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ data:
debug: {{ .Values.appSettings.debug | squote }}
ssl: {{ .Values.appSettings.ssl | squote }}
apiKeys: {{ .Values.appSettings.apiKeys | squote }}
{{- if and (not .Values.appSettings.existingSecret) (not .Values.appSettings.secretKeys.origin) }}
requireApiKeyOrigin: {{ .Values.appSettings.requireApiKeyOrigin | squote }}
{{- end }}
{{- if and (not .Values.appSettings.existingSecret) (not .Values.appSettings.secretKeys.secret) }}
requireApiKeySecret: {{ .Values.appSettings.requireApiKeySecret | squote }}
{{- end }}
suggestions: {{ .Values.appSettings.suggestions | squote }}
disableFilesTranslation: {{ .Values.appSettings.disableFilesTranslation | squote }}
disableWebUi: {{ .Values.appSettings.disableWebUi | squote }}
Expand Down
2 changes: 2 additions & 0 deletions charts/libretranslate/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.adminUser.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -7,3 +8,4 @@ data:
auth: {{ .Values.adminUser.auth | quote }}
username: {{ .Values.adminUser.name | quote }}
password: {{ .Values.adminUser.password | quote }}
{{- end }}
18 changes: 15 additions & 3 deletions charts/libretranslate/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,31 @@ spec:
name: libretranslate-appsettings
key: apiKeys
{{- end }}
{{- if and (.Values.appSettings.requireApiKeyOrigin) (ne .Values.appSettings.requireApiKeyOrigin "") }}
{{- if or .Values.appSettings.requireApiKeyOrigin .Values.appSettings.existingSecret }}
- name: LT_REQUIRE_API_KEY_ORIGIN
valueFrom:
{{- if not .Values.appSettings.existingSecret }}
configMapKeyRef:
name: libretranslate-appsettings
key: requireApiKeyOrigin
{{- else }}
secretKeyRef:
name: {{ .Values.appSettings.existingSecret }}
key: {{ .Values.appSettings.secretKeys.origin }}
{{- end }}
{{- end }}
{{- if and (.Values.appSettings.requireApiKeySecret) (ne .Values.appSettings.requireApiKeySecret "") }}
{{- if and .Values.appSettings.requireApiKeySecret .Values.appSettings.existingSecret }}
- name: LT_REQUIRE_API_KEY_SECRET
valueFrom:
{{- if not .Values.appSettings.existingSecret }}
configMapKeyRef:
name: libretranslate-appsettings
key: requireApiKeySecret
{{- else }}
secretKeyRef:
name: {{ .Values.appSettings.existingSecret }}
key: {{ .Values.appSettings.secretKeys.secret }}
{{- end }}
{{- end }}
{{- if and (.Values.appSettings.suggestions) (ne .Values.appSettings.suggestions "") }}
- name: LT_SUGGESTIONS
Expand Down Expand Up @@ -341,4 +353,4 @@ spec:
storageClassName: {{ .Values.persistence.db.storageClass | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/libretranslate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ adminUser:
name: "YWRtaW4K" # copy the username in base64 as a reference
auth: "YWRtaW46JGFwcjEkYlpydmYvUFYkSHBHSlhqZU1EN0ZON2kyYndsMVRNMQoK" # copy the output from the htpasswd command here as a reference
password: "bXlTZWNyZXRQYXNzd29yZAo=" # copy the password as base64 for the admin user here as a reference
existingSecret: "" # use an existing secret for admin user
# key in existing secret
secretKeys:
name: "name"
auth: "auth"
password: "password"

# Settings / Flags
appSettings:
Expand All @@ -140,6 +146,12 @@ appSettings:
disableWebUi: "false" # Disable web ui (Default: Web Ui enabled)
updateModels: "false" # Update language models at startup (Default: Only on if no models found)
metrics: "false" # Enable the /metrics endpoint for exporting Prometheus usage metrics (Default: Disabled)
existingSecret: "" # use an existing secret for api key origin and secret
# keys in existing secret
secretKeys:
apiKeyorigin: "origin"
apiKeysecret: "secret"


# Configuration Parameters
appConfig:
Expand Down

0 comments on commit af60787

Please sign in to comment.