Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions .github/workflows/helm-chart-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,30 @@ jobs:
for ref in UC_S3_ACCESSKEY_0:ci-s3-credentials:accessKey UC_S3_SECRETKEY_0:ci-s3-credentials:secretKey \
UC_ADLS_TENANTID_0:ci-adls-credentials:tenantId UC_ADLS_CLIENTID_0:ci-adls-credentials:clientId \
UC_ADLS_CLIENTSECRET_0:ci-adls-credentials:clientSecret \
UC_HIBERNATE_CONNECTION_PASSWORD:ci-db-password:password; do
UC_HIBERNATE_CONNECTION_PASSWORD:ci-db-password:password \
UC_SERVER_CREDENTIAL_ENCRYPTION_KEY:ci-credential-encryption:ciEncryptionKey; do
IFS=: read -r name secret key <<<"$ref"
grep -A4 -- "- name: $name\$" <<<"$out" | tr -d '\n' | grep -qE "name: \"$secret\" +key: \"?$key\"?( |\$)"
done
# None in the file, which the init container writes only at pod start.
! grep -qE 'server\.client-secret|s3\.(accessKey|secretKey)|adls\.(tenantId|clientId|clientSecret)|hibernate\.connection\.password' <<<"$out" || exit 1
! grep -qE 'server\.client-secret|server\.credential-encryption-key|s3\.(accessKey|secretKey)|adls\.(tenantId|clientId|clientSecret)|hibernate\.connection\.password' <<<"$out" || exit 1
# The credential encryption key is passed only when its Secret is named, with any database.
default_render="$(helm template uc helm)"
! grep -qF 'UC_SERVER_CREDENTIAL_ENCRYPTION_KEY' <<<"$default_render" || exit 1
# With any database, in the one env list of the server container, and never in the file.
for values in "" "-f helm/ci/postgresql-values.yaml" "-f helm/ci/mysql-values.yaml"; do
key_only="$(helm template uc helm $values --set server.credentialEncryptionKeySecret.name=k)"
[ "$(grep -c -- '- name: UC_SERVER_CREDENTIAL_ENCRYPTION_KEY$' <<<"$key_only")" -eq 1 ]
grep -A4 -- "- name: UC_SERVER_CREDENTIAL_ENCRYPTION_KEY\$" <<<"$key_only" | tr -d '\n' \
| grep -qE 'name: "k" +key: "?encryptionKey"?( |$)'
! grep -qE 'server\.credential-encryption-key' <<<"$key_only" || exit 1
done
# On MySQL, JDK_JAVA_OPTIONS follows the key in the same env list: no second env: between
# them.
mysql_out="$(helm template uc helm -f helm/ci/mysql-values.yaml --set server.credentialEncryptionKeySecret.name=k)"
between="$(sed -n '/- name: UC_SERVER_CREDENTIAL_ENCRYPTION_KEY$/,/- name: JDK_JAVA_OPTIONS$/p' <<<"$mysql_out")"
grep -qF -- '- name: JDK_JAVA_OPTIONS' <<<"$between"
! grep -qE '^\s*env:' <<<"$between" || exit 1
# The rendered chart no longer has DB_PASSWORD.
! grep -qF 'DB_PASSWORD' <<<"$out" || exit 1
# The deprecated init container variables are there only for a custom template.
Expand Down Expand Up @@ -230,6 +248,14 @@ jobs:
done
values=()
[ "$DB" = file ] || values=(--values "helm/ci/$DB-values.yaml")
# The PostgreSQL case also turns on s3_compatible credentials, with an encryption key from a
# Secret; the other cases keep the default install.
if [ "$DB" = postgresql ]; then
kubectl create secret generic credential-encryption --namespace uc \
--from-literal=encryptionKey="$(openssl rand -base64 32)"
values+=(--set server.credentialEncryptionKeySecret.name=credential-encryption \
--set-string 'server.config.extraProperties.server\.s3-compatible-storage\.enabled=true')
fi
helm install uc "$RUNNER_TEMP/unitycatalog-chart-0.0.0-ci.tgz" --namespace uc --create-namespace --wait --timeout 600s \
"${values[@]}" \
--set server.deployment.image.repository=unitycatalog \
Expand All @@ -238,4 +264,10 @@ jobs:
--set server.deployment.enableReadinessProbe=true \
--set ui.deployment.image.repository=unitycatalog-ui \
--set ui.deployment.image.pullPolicy=Never
if [ "$DB" = postgresql ]; then
# The server read the key, which it checks at startup with the feature on.
kubectl logs --namespace uc deployment/uc-unitycatalog-server --container server \
| grep -F 'Using the UC_SERVER_CREDENTIAL_ENCRYPTION_KEY environment variable' > /dev/null \
|| { echo "::error::The server did not read the credential encryption key"; exit 1; }
fi
helm test uc --namespace uc --logs
10 changes: 9 additions & 1 deletion docs/server/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ environment):
| `aws.secretKey` | `UC_AWS_SECRETKEY` |
| `s3.secretKey.<n>`, `s3.sessionToken.<n>` | `UC_S3_SECRETKEY_<n>`, `UC_S3_SESSIONTOKEN_<n>` |
| `adls.clientSecret.<n>` | `UC_ADLS_CLIENTSECRET_<n>` |
| `server.credential-encryption-key` | `UC_SERVER_CREDENTIAL_ENCRYPTION_KEY` |
| `hibernate.connection.password` (in `hibernate.properties`) | `UC_HIBERNATE_CONNECTION_PASSWORD` |

```sh
Expand All @@ -119,7 +120,14 @@ server logs the name of each environment variable it uses for a setting, never i
read by `bin/uc auth login`, not by the server. The Helm chart passes each S3 and ADLS credential to the server
container from its Kubernetes Secret, in `UC_S3_ACCESSKEY_<n>` and `UC_S3_SECRETKEY_<n>`, or `UC_ADLS_TENANTID_<n>`,
`UC_ADLS_CLIENTID_<n>` and `UC_ADLS_CLIENTSECRET_<n>`. With `server.db.type: postgresql` or `mysql`, it also passes
`UC_HIBERNATE_CONNECTION_PASSWORD` if that database's `passwordSecretName` is set.
`UC_HIBERNATE_CONNECTION_PASSWORD` if that database's `passwordSecretName` is set. With any database, if
`server.credentialEncryptionKeySecret.name` is set, it passes `UC_SERVER_CREDENTIAL_ENCRYPTION_KEY` from that Secret's
`server.credentialEncryptionKeySecret.key` (by default `encryptionKey`). Only the experimental `s3_compatible`
credentials need it, and only with `server.s3-compatible-storage.enabled=true` (in the chart, under
`server.config.extraProperties`): the server then refuses to start with a malformed key, and without one it cannot
create or use such credentials. See the chart's
[README](https://github.com/unitycatalog/unitycatalog/blob/main/helm/README.md#s3-compatible-storage-credentials) for a
complete example.

!!! warning "Deprecated: secrets in properties files"
Secrets in `server.properties` and the password in `hibernate.properties` still work, but this is deprecated. The
Expand Down
58 changes: 54 additions & 4 deletions helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ server:
server.audit.sink: io.unitycatalog.server.audit.FileAuditSink
```

## S3-compatible storage credentials
The experimental `s3_compatible` storage credentials need both the server flag and a key that the
server encrypts their secret values with in its database. Create the key once and keep it for as
long as such credentials exist:

```sh
kubectl create secret generic uc-credential-encryption \
--from-literal=encryptionKey="$(openssl rand -base64 32)"
```

Then set both values:

```yaml
server:
credentialEncryptionKeySecret:
name: uc-credential-encryption
config:
extraProperties:
server.s3-compatible-storage.enabled: "true"
```

## Configuration
The following table lists the configurable parameters of the Unity Catalog chart and their default values.

Expand Down Expand Up @@ -378,10 +399,12 @@ server.port=8080
...other config properties...
```

Do not put secrets here: the chart passes the S3 and ADLS secrets to the server as environment
variables, and a secret in `server.properties` is deprecated. A template that uses `${OAUTH_CLIENT_SECRET}`,
`${S3_SECRET_KEY_<n>}` or `${ADLS_CLIENT_SECRET_<n>}` still gets them, but that is deprecated
too: the server reads `UC_S3_SECRETKEY_<n>` and `UC_ADLS_CLIENTSECRET_<n>` from its environment.
Do not put secrets here: the chart passes the S3 and ADLS secrets, and the credential
encryption key, to the server as environment variables, and a secret in `server.properties`
is deprecated. A template that uses `${OAUTH_CLIENT_SECRET}`, `${S3_SECRET_KEY_<n>}` or
`${ADLS_CLIENT_SECRET_<n>}` still gets them, but that is deprecated too: the server reads
`UC_S3_SECRETKEY_<n>` and `UC_ADLS_CLIENTSECRET_<n>` from its environment. For the
encryption key, see [S3-compatible storage credentials](#s3-compatible-storage-credentials).
</td>
</tr>
<tr>
Expand Down Expand Up @@ -445,6 +468,33 @@ not set
<td>TTL for the create users job (in seconds)

[Kubernetes docs](https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/)
</td>
</tr>
<tr>
<td>server.credentialEncryptionKeySecret.key</td>
<td>string</td>
<td><pre lang="json">
"encryptionKey"
</pre>
</td>
<td>Key in the Secret that holds the encryption key: 32 random bytes in base64, such as the output of `openssl rand -base64 32`</td>
</tr>
<tr>
<td>server.credentialEncryptionKeySecret.name</td>
<td>string</td>
<td><pre lang="">
not set
</pre>
</td>
<td>Name of a Secret with the key that the server encrypts the secret values of storage credentials with in its database

Only the experimental `s3_compatible` storage credentials need it, and only when
`server.s3-compatible-storage.enabled` is `"true"`: setting the Secret alone leaves them
disabled. With the flag set, the server refuses to start with a malformed key. Keep the same
key for as long as such credentials exist: values stored with a key cannot be read with
another. The chart passes the key to the server container as
`UC_SERVER_CREDENTIAL_ENCRYPTION_KEY`. See
[S3-compatible storage credentials](#s3-compatible-storage-credentials) for a complete example.
</td>
</tr>
<tr>
Expand Down
21 changes: 21 additions & 0 deletions helm/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ server:
server.audit.sink: io.unitycatalog.server.audit.FileAuditSink
```

## S3-compatible storage credentials
The experimental `s3_compatible` storage credentials need both the server flag and a key that the
server encrypts their secret values with in its database. Create the key once and keep it for as
long as such credentials exist:

```sh
kubectl create secret generic uc-credential-encryption \
--from-literal=encryptionKey="$(openssl rand -base64 32)"
```

Then set both values:

```yaml
server:
credentialEncryptionKeySecret:
name: uc-credential-encryption
config:
extraProperties:
server.s3-compatible-storage.enabled: "true"
```

## Configuration
The following table lists the configurable parameters of the Unity Catalog chart and their default values.

Expand Down
4 changes: 4 additions & 0 deletions helm/ci/secrets-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ server:
username: uc
passwordSecretName: ci-db-password
passwordSecretKey: password
# A key other than the default, so the render checks cover the setting.
credentialEncryptionKeySecret:
name: ci-credential-encryption
key: ciEncryptionKey
config:
# A custom template still gets the deprecated init container variables.
extraProperties:
Expand Down
13 changes: 11 additions & 2 deletions helm/templates/server/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ rootLogger.appenderRef.console.ref=Console

{{/*
Secrets for the server container (see "Secrets" in docs/server/configuration.md): the database
password and every part of each storage credential come from here, not from the generated properties
files, which are written only at pod start.
password, every part of each storage credential and the credential encryption key come from here,
not from the generated properties files, which are written only at pod start.
*/}}
{{- define "unitycatalog.server.secretEnv" -}}
{{- $db := dict "postgresql" .Values.server.db.postgresqlConfig "mysql" .Values.server.db.mysqlConfig }}
Expand Down Expand Up @@ -195,4 +195,13 @@ files, which are written only at pod start.
name: {{ $config.credentialsSecretName | quote }}
key: clientSecret
{{- end }}
{{- with .Values.server.credentialEncryptionKeySecret }}
{{- if .name }}
- name: UC_SERVER_CREDENTIAL_ENCRYPTION_KEY
valueFrom:
secretKeyRef:
name: {{ .name | quote }}
key: {{ required "Credential encryption key secret key is required" .key | quote }}
{{- end }}
{{- end }}
{{- end }}
30 changes: 26 additions & 4 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,12 @@ server:
# ...other config properties...
# ```
#
# Do not put secrets here: the chart passes the S3 and ADLS secrets to the server as environment
# variables, and a secret in `server.properties` is deprecated. A template that uses `${OAUTH_CLIENT_SECRET}`,
# `${S3_SECRET_KEY_<n>}` or `${ADLS_CLIENT_SECRET_<n>}` still gets them, but that is deprecated
# too: the server reads `UC_S3_SECRETKEY_<n>` and `UC_ADLS_CLIENTSECRET_<n>` from its environment.
# Do not put secrets here: the chart passes the S3 and ADLS secrets, and the credential
# encryption key, to the server as environment variables, and a secret in `server.properties`
# is deprecated. A template that uses `${OAUTH_CLIENT_SECRET}`, `${S3_SECRET_KEY_<n>}` or
# `${ADLS_CLIENT_SECRET_<n>}` still gets them, but that is deprecated too: the server reads
# `UC_S3_SECRETKEY_<n>` and `UC_ADLS_CLIENTSECRET_<n>` from its environment. For the
# encryption key, see [S3-compatible storage credentials](#s3-compatible-storage-credentials).
#
override:

Expand Down Expand Up @@ -748,6 +750,26 @@ server:
#
create: true

credentialEncryptionKeySecret:
# -- (string) Name of a Secret with the key that the server encrypts the secret values of
# storage credentials with in its database
# @default -- not set
# @raw
#
# Only the experimental `s3_compatible` storage credentials need it, and only when
# `server.s3-compatible-storage.enabled` is `"true"`: setting the Secret alone leaves them
# disabled. With the flag set, the server refuses to start with a malformed key. Keep the same
# key for as long as such credentials exist: values stored with a key cannot be read with
# another. The chart passes the key to the server container as
# `UC_SERVER_CREDENTIAL_ENCRYPTION_KEY`. See
# [S3-compatible storage credentials](#s3-compatible-storage-credentials) for a complete example.
#
name:

# -- (string) Key in the Secret that holds the encryption key: 32 random bytes in base64, such
# as the output of `openssl rand -base64 32`
key: encryptionKey

# -- (string) Log level for the server
# @default -- info
logLevel: info
Expand Down
Loading