From 0a85155bf1b2d1746274cf6489d35b3b2d0453ed Mon Sep 17 00:00:00 2001 From: Michael Ruoss Date: Sat, 3 Feb 2024 11:37:54 +0100 Subject: [PATCH] feat(livebook) AWS credentials and data folder (#17555) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** Followup after #16880. I'm still waiting for the next release of Livebook before moving this to the stable train as it comes with a fix for clustering (https://github.com/phoenixframework/dns_cluster/issues/10). * Adding variables for AWS credentials * moved the variables in `questions.yaml` to the `podOptions` section. This ways I can put secret values inside secrets. * Run as non-root by default * Point the `LIVEBOOK_DATA_PATH` to the PVC in order to persist the config (e.g. aws storage config) **โš™๏ธ Type of change** - [x] โš™๏ธ 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?** Using `helm template` to verify the resulting manifest. **๐Ÿ“ƒ Notes:** **โœ”๏ธ Checklist:** - [x] โš–๏ธ My code follows the style guidelines of this project - [x] ๐Ÿ‘€ I have performed a self-review of my own code - [ ] #๏ธโƒฃ 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._ --- charts/dev/livebook/Chart.yaml | 2 +- charts/dev/livebook/ci/test-values.yaml | 2 + charts/dev/livebook/questions.yaml | 90 +++++++++++++++------- charts/dev/livebook/templates/_secrets.tpl | 6 +- charts/dev/livebook/values.yaml | 26 ++++++- 5 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 charts/dev/livebook/ci/test-values.yaml diff --git a/charts/dev/livebook/Chart.yaml b/charts/dev/livebook/Chart.yaml index 53486c3e3e1..9e50721d90e 100644 --- a/charts/dev/livebook/Chart.yaml +++ b/charts/dev/livebook/Chart.yaml @@ -34,4 +34,4 @@ sources: - https://github.com/truecharts/charts/tree/master/charts/dev/livebook - https://ghcr.io/livebook-dev/livebook type: application -version: 3.1.1 +version: 3.2.0 diff --git a/charts/dev/livebook/ci/test-values.yaml b/charts/dev/livebook/ci/test-values.yaml new file mode 100644 index 00000000000..9555d2e0d25 --- /dev/null +++ b/charts/dev/livebook/ci/test-values.yaml @@ -0,0 +1,2 @@ +livebook: + password: thisisunsafefortests diff --git a/charts/dev/livebook/questions.yaml b/charts/dev/livebook/questions.yaml index 675cde7e542..e1742281910 100644 --- a/charts/dev/livebook/questions.yaml +++ b/charts/dev/livebook/questions.yaml @@ -9,31 +9,67 @@ questions: # Include{replicas1} # Include{podSpec} # Include{containerMain} - - variable: env - label: Image Environment - schema: - additional_attrs: true - type: dict - attrs: - - variable: LIVEBOOK_PASSWORD - label: "Password (LIVEBOOK_PASSWORD)" - description: "Password needed to access livebook (must be at least 12 characters)" - schema: - type: string - 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{containerBasic} +# Include{containerAdvanced} +# Include{containerConfig} +# Include{podOptions} + - variable: livebook + group: App Configuration + label: Livebook + schema: + additional_attrs: true + type: dict + attrs: + - variable: password + label: "Password (LIVEBOOK_PASSWORD)" + description: Password needed to access livebook (must be at least 12 characters) + schema: + type: string + min_length: 12 + required: true + private: true + - variable: debug + label: "Debug Logging (LIVEBOOK_DEBUG)" + description: > + Enables verbose logging, when set to "true". Disabled by default. + schema: + type: boolean + default: false + - variable: updateInstructionsUrl + 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 + - variable: awsCredentials + label: AWS Credentials + schema: + additional_attrs: true + type: dict + attrs: + - variable: enabled + label: "Set AWS Credentials" + description: > + Enable Livebook to read AWS Credentials from environment variables, + AWS Credentials, EC2/ECS metadata when configuring S3 buckets. + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: accessKeyId + label: "AWS Access Key ID" + description: > + AWS Access Key ID in case you want to configure AWS S3 Storage inside Livebook + schema: + type: string + - variable: secretAccessKey + label: "AWS Secret Access Key" + description: > + AWS Secret Access Key in case you want to configure AWS S3 Storage inside Livebook + schema: + type: string + private: true # Include{serviceRoot} - variable: main label: "Main Service" @@ -86,13 +122,13 @@ questions: description: "The UserID of the user running the application" schema: type: int - default: 0 + default: 568 - variable: runAsGroup label: "runAsGroup" description: "The groupID of the user running the application" schema: type: int - default: 0 + default: 568 # Include{securityContextContainer} # Include{securityContextAdvanced} # Include{securityContextPod} diff --git a/charts/dev/livebook/templates/_secrets.tpl b/charts/dev/livebook/templates/_secrets.tpl index 205e77ddbd9..bc6f29f1323 100644 --- a/charts/dev/livebook/templates/_secrets.tpl +++ b/charts/dev/livebook/templates/_secrets.tpl @@ -10,6 +10,8 @@ {{- end }} enabled: true data: - LIVEBOOK_SECRET_KEY_BASE: {{ $secretKeyBase }} - LIVEBOOK_COOKIE: {{ $cookie }} + LIVEBOOK_SECRET_KEY_BASE: {{ $secretKeyBase | quote }} + LIVEBOOK_COOKIE: {{ $cookie | quote }} + LIVEBOOK_PASSWORD: {{ .Values.livebook.password | quote }} + AWS_SECRET_ACCESS_KEY: {{ .Values.livebook.awsCredentials.secretAccessKey | default "" | quote }} {{- end -}} diff --git a/charts/dev/livebook/values.yaml b/charts/dev/livebook/values.yaml index cf90783411f..dec21dd1e7e 100644 --- a/charts/dev/livebook/values.yaml +++ b/charts/dev/livebook/values.yaml @@ -12,8 +12,8 @@ portal: securityContext: container: readOnlyRootFilesystem: false - runAsGroup: 0 - runAsUser: 0 + runAsGroup: 568 + runAsUser: 568 service: main: ports: @@ -42,6 +42,7 @@ workload: LIVEBOOK_NODE: livebook@$(A_POD_IP) LIVEBOOK_PORT: "{{ .Values.service.main.ports.main.port }}" LIVEBOOK_HOME: "{{ .Values.persistence.data.mountPath }}" + LIVEBOOK_DATA_PATH: "{{ .Values.persistence.data.mountPath }}" LIVEBOOK_SECRET_KEY_BASE: secretKeyRef: name: secrets @@ -50,3 +51,24 @@ workload: secretKeyRef: name: secrets key: LIVEBOOK_COOKIE + LIVEBOOK_PASSWORD: + secretKeyRef: + name: secrets + key: LIVEBOOK_PASSWORD + LIVEBOOK_DEBUG: '{{ ternary "true" "false" .Values.livebook.debug }}' + LIVEBOOK_UPDATE_INSTRUCTIONS_URL: "{{ .Values.livebook.updateInstructionsUrl }}" + LIVEBOOK_AWS_CREDENTIALS: '{{ ternary "true" "false" .Values.livebook.awsCredentials.enabled }}' + AWS_ACCESS_KEY_ID: "{{ .Values.livebook.awsCredentials.accessKeyId }}" + AWS_SECRET_ACCESS_KEY: + secretKeyRef: + name: secrets + key: AWS_SECRET_ACCESS_KEY +# default values +livebook: + password: "" + updateInstructionsUrl: "" + debug: false + awsCredentials: + enabled: false + accessKeyId: "" + secretAccessKey: ""