livebook: add env variables and fix docker image (#16880)

**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->

* Fix Livebook container image source and upgrade to latest version
* Add environment variables, mostly for clustering of multiple replicas

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [x] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

I've used a local KIND cluster and `helm template` => `kubectl install`

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [x] ⚖️ My code follows the style guidelines of this project
- [x] 👀 I have performed a self-review of my own code
- [x] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [x] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [x] ⬆️ I increased versions for any altered app according to semantic
versioning

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
This commit is contained in:
Michael Ruoss
2024-01-05 22:32:11 +01:00
committed by GitHub
parent 1e27b14d0f
commit 150e8785ae
5 changed files with 70 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
kubeVersion: ">=1.24.0-0"
apiVersion: v2
name: livebook
version: 3.0.13
version: 3.1.0
appVersion: latest
description: Livebook is a web application for writing interactive and collaborative code notebooks for Elixir
home: https://truecharts.org/charts/incubator/livebook

View File

@@ -16,11 +16,24 @@ questions:
type: dict
attrs:
- variable: LIVEBOOK_PASSWORD
label: "LIVEBOOK_PASSWORD"
label: "Password (LIVEBOOK_PASSWORD)"
description: "Password needed to access livebook (must be at least 12 characters)"
schema:
type: string
default: "livebookiscool"
required: true
private: true
- variable: LIVEBOOK_DEBUG
label: "Debug Logging (LIVEBOOK_DEBUG)"
description: >
enables verbose logging, when set to "true". Disabled by default.
schema:
type: boolean
- variable: LIVEBOOK_UPDATE_INSTRUCTIONS_URL
label: "Update instruction URL (LIVEBOOK_UPDATE_INSTRUCTIONS_URL)"
description: >
sets the URL to direct the user to for updating Livebook when a new version becomes available.
schema:
type: string
# Include{serviceRoot}
- variable: main
label: "Main Service"

View File

@@ -0,0 +1,15 @@
{{/* Define the secrets */}}
{{- define "livebook.secrets" -}}
{{- $secretName := (printf "%s-secrets" (include "tc.v1.common.lib.chart.names.fullname" $)) }}
{{/* Base64 encoding is intended, application expects a b64 formatted value */}}
{{- $secretKeyBase := randAlphaNum 48 | b64enc -}}
{{- $cookie := randAlphaNum 20 -}}
{{- with (lookup "v1" "Secret" .Release.Namespace $secretName) -}}
{{- $secretKeyBase = index .data "LIVEBOOK_SECRET_KEY_BASE" | b64dec -}}
{{- $cookie = index .data "LIVEBOOK_COOKIE" | b64dec -}}
{{- end }}
enabled: true
data:
LIVEBOOK_SECRET_KEY_BASE: {{ $secretKeyBase }}
LIVEBOOK_COOKIE: {{ $cookie }}
{{- end -}}

View File

@@ -1,2 +1,13 @@
{{/* Render the templates */}}
{{ include "tc.v1.common.loader.all" . }}
{{/* Make sure all variables are set properly */}}
{{- include "tc.v1.common.loader.init" . }}
{{/* Render secrets for livebook */}}
{{- $secrets := include "livebook.secrets" . | fromYaml -}}
{{- if $secrets -}}
{{- $_ := set .Values.secret "secrets" $secrets -}}
{{- end -}}
{{/* Render the templates */}}
{{ include "tc.v1.common.loader.apply" . }}

View File

@@ -1,7 +1,7 @@
image:
pullPolicy: IfNotPresent
repository: livebook/livebook
tag: latest@sha256:99c321de38ad781df509cfd3e452805f04627589a435645faa889a963bd7d1f5
repository: ghcr.io/livebook-dev/livebook
tag: 0.12.1@sha256:11c5691efc8e35bf0eee9c336ff029e674bcf4146ec39021b1ef75c1b17fb775
persistence:
data:
enabled: true
@@ -19,12 +19,34 @@ service:
ports:
main:
port: 8787
protocol: tcp
targetPort: 8080
headless:
enabled: true
primary: false
clusterIP: None
ports:
headless:
enabled: true
port: "{{ .Values.service.main.ports.main.port }}"
workload:
main:
podSpec:
containers:
main:
env:
LIVEBOOK_PASSWORD: livebookiscool
# A_ because these variables are sorted alphabetically and this one needs to come first.
A_POD_IP:
fieldRef:
fieldPath: status.podIP
LIVEBOOK_CLUSTER: '{{ printf "dns:%s-headless" (include "tc.v1.common.lib.chart.names.fullname" .) }}'
LIVEBOOK_DISTRIBUTION: name
LIVEBOOK_NODE: livebook@$(A_POD_IP)
LIVEBOOK_PORT: "{{ .Values.service.main.ports.main.port }}"
LIVEBOOK_HOME: "{{ .Values.persistence.data.mountPath }}"
LIVEBOOK_SECRET_KEY_BASE:
secretKeyRef:
name: secrets
key: LIVEBOOK_SECRET_KEY_BASE
LIVEBOOK_COOKIE:
secretKeyRef:
name: secrets
key: LIVEBOOK_COOKIE