-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathREADME.md.gotmpl
395 lines (311 loc) · 17 KB
/
README.md.gotmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
{{ template "rstudio.header" . }}
{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}
{{ template "rstudio.description" . }}
{{ template "rstudio.disclaimer" . }}
{{ template "rstudio.install" . }}
## Required configuration
To function, this chart requires the following:
* A license file. See the [Licensing](#licensing) section below for more details.
* A Kubernetes [PersistentVolume](https://kubernetes.io/docs/concepts/storage/persistent-volumes/) that contains the
home directory for users.
* If `homeStorage.create` is set, it creates a Persistent Volume Claim (PVC) that relies on the default storage class to generate the
PersistentVolume. Most Kubernetes environments do not have a default storage class that you can use
with `ReadWriteMany` access mode out-of-the-box. In this case, we recommend that you:
* Disable `homeStorage.create` and
create your own `PersistentVolume` and `PersistentVolumeClaim`, then
* Mount them into the container by specifying
the `pod.volumes` and `pod.volumeMounts` parameters, or by specifying your `PersistentVolumeClaim`
using `homeStorage.name` and `homeStorage.mount`.
* If you cannot use a `PersistentVolume` to properly mount your users' home directories, mount your
data in the container by using a
regular [Kubernetes Volume](https://kubernetes.io/docs/concepts/storage/volumes/#nfs), specified in `pod.volumes`
and `pod.volumeMounts`.
* If you cannot use a `Volume` to mount the directories, manually mount them during container startup
with a mechanism similar to what is described below for joining to auth domains.
* If not using `homeStorage.create`, configure `config.serverDcf.launcher-mounts` to ensure that the correct mounts are used when users create new sessions.
* If using load balancing (by setting `replicas > 1`), you need similar storage defined for `sharedStorage` to
store shared project configuration. However, you can also configure the product to store its shared data underneath `/home` by
setting `config.server.rserver\.conf.server-shared-storage-path=/home/some-shared-dir`.
* A method to join the deployed `rstudio-workbench` container to your auth domain. The default `rstudio/rstudio-workbench` image has `sssd` installed and started by default.
You can include `sssd` configuration in `config.userProvisioning` like so:
```yaml
config:
userProvisioning:
mysssd.conf:
sssd:
config_file_version: 2
services: nss, pam
domains: rstudio.com
domain/rstudio.com:
id_provider: ldap
auth_provider: ldap
```
{{ template "rstudio.licensing" . }}
## Database
Workbench requires a PostgreSQL database when running in Kubernetes. You must configure a [valid connection URI and a password](https://docs.posit.co/ide/server-pro/database/configuration.html#postgresql) for the product to function correctly. Both the connection URI and password may be specified in the `config` section of `values.yaml`. However, we recommend only adding the connection URI and putting the database password in a Kubernetes `Secret`, which can be [automatically set as an environment variable](#database-password).
### Database configuration
Add the following to your `values.yaml`, replacing the `connection-uri` with your database details.
```yaml
config:
secret:
database.conf:
provider: "postgresql"
connection-uri: "postgres://<USERNAME>@<HOST>:<PORT>/<DATABASE>?sslmode=allow"
```
### Database password
First, create a `Secret` declaratively with YAML or imperatively using the following command (replacing with your actual password):
```bash
kubectl create secret generic {{ .Name }}-database --from-literal=password=YOURPASSWORDHERE
```
Second, specify the following in your `values.yaml`:
```yaml
pod:
env:
- name: WORKBENCH_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Name }}-database
key: password
```
Alternatively, database passwords may be set during `helm install` with the following argument:
`--set config.secret.'database\.conf'.password="<YOUR_PASSWORD_HERE>"`
## General principles
- In most places, we opt to pass Helm values directly into ConfigMaps. We automatically translate these into the
valid `.ini` or `.dcf` file formats required by Workbench.
- Those configuration files and their mount locations are covered in the [Configuration files](#configuration-files) section below.
- If you need to modify the jobs launched by Workbench, use `job-json-overrides`.
- Review the [Job Json overrides](#job-json-overrides) section on this below. For general information, see [a support article](https://support.rstudio.com/hc/en-us/articles/360051652094-Using-Job-Json-Overrides-with-RStudio-Server-Pro-and-Kubernetes).
- The prestart scripts for Workbench and Posit Job Launcher are highly customized to get the service account information off of the Workbench pod for use in launching jobs.
- Workbench does not export prometheus metrics on its own. Instead, we run a sidecar graphite exporter.
- This is described in the
[Monitoring Posit Team Using Prometheus and Graphite](https://support.rstudio.com/hc/en-us/articles/360044800273-Monitoring-RStudio-Team-Using-Prometheus-and-Graphite) support article.
## Configuration files
These configuration values all take the form of usual Helm values
so you can set the database password with something like:
```{.bash}
... --set config.secret.database\.conf.password=mypassword ...
```
The files are converted into configuration files in the necessary format via go-templating. If you want to "in-line" a config file or mount it verbatim, you can use a pattern like:
```yaml
config:
server:
rserver.conf: |
verbatim-file=format
```
The names of files are dynamically used, so you can add new files as needed. Beware that some files have default values,
so moving them can have adverse effects. Also, if you use a different mounting paradigm, you need to change
the `XDG_CONFIG_DIRS` environment variable.
- Session Configuration
- These configuration files are mounted into the server and
are mounted into the session pods.
- `repos.conf`, `rsession.conf`, `notifications.conf`
- Located in: <br>`config.session.<< name of file >>` Helm values
- Mounted at:<br> `/mnt/session-configmap/rstudio/`
- Session Secret Configuration:
- These configuration files are mounted into the server and session pods.
- `odbc.ini` and other similar shared secrets.
- Located in: <br>`config.sessionSecret.<< name of file>>` Helm values
- Mounted at:<br> `/mnt/session-secret/`
- Secret Configuration:
- These configuration files are mounted into the server with more restrictive permissions (0600).
- `database.conf`, `openid-client-secret`, `databricks.conf`
- Located in: <br>`config.secret.<< name of file >>` Helm values
- Mounted at:<br> `/mnt/secret-configmap/rstudio/`
- Server Configuration:
- These configuration files are mounted into the server (.ini file format).
- `rserver.conf`, `launcher.conf`, `jupyter.conf`, `logging.conf`
- Located at:<br> `config.server.<< name of file >>` Helm values
- Mounted at:<br> `/mnt/configmap/rstudio/`
- Server DCF Configuration:
- These configuration files are mounted into the server (.dcf file format).
- `launcher-mounts`, `launcher-env`
- Located at:<br> `config.serverDcf.<< name of file >>` Helm values
- Included at:<br> `/mnt/configmap/rstudio/`
- Profiles Configuration:
- These configuration files are mounted into the server (.ini file format).
- `launcher.kubernetes.profiles.conf`
- They are located at `config.profiles.<< name of file >>` Helm values
- Included at:<br> `/mnt/configmap/rstudio/`
- See the [Profiles](#rstudio-profiles) section below for more information.
- Prestart:
- This is provided by the Helm chart in a configmap.
- It is mounted into the pod at `/scripts/`.
- `prestart-workbench.bash` is used to start workbench.
- `prestart-launcher.bash` is used to start launcher.
- User Provisioning Configuration:
- These configuration files are used for configuring user provisioning (i.e., `sssd`).
- Located at:<br> `config.userProvisioning.<< name of file >>` Helm values
- Mounted onto:<br> `/etc/sssd/conf.d/` with `0600` permissions by default.
- Custom Startup Configuration:
- `supervisord` service / unit definition `.conf` files.
- Use the `.ini` file format by default.
- Mounted at:<br> `/startup/custom`
- As with all configuration files above, you can override with a verbatim string if desired:
- Located at:<br> `config.startupCustom.<< name of file >>` Helm values:
```yaml
config:
startupCustom:
myfile.conf: |
file-used-verbatim
```
- PAM configuration:
- `pam` configuration files.
- Located at:<br> `config.pam.<< name of file >>` Helm values
- Mounted verbatim as individual files (using `subPath` mounts) at:<br> `/etc/pam.d/<< name of file >>`
#### Python repositories
pip can be configured with `config.session.pip.conf`. To ensure `pip.conf` is mounted into the session pods, it is important that:
- `launcher.useTemplates: true` is set
- `pip.conf` settings are listed under `config.session` as shown in the following example for adding Posit Public Package Manager's PyPI:
```yaml
launcher:
useTemplates: true
config:
session:
pip.conf:
"global":
index-url: https://packagemanager.posit.co/pypi/latest/simple
trusted-host: packagemanager.posit.co
```
#### R repositories
R package repositories can be configured with `config.session.repos.conf`:
```yaml
config:
session:
repos.conf:
CRAN: https://packagemanager.posit.co/cran/__linux__/jammy/latest
```
For more information about configuring CRAN repositories in Workbench, see the [Posit Workbench Administrator Guide's - Package Installation > CRAN repositories](https://docs.posit.co/ide/server-pro/rstudio_pro_sessions/package_installation.html#cran-repositories) section.
## User provisioning
Provisioning users in Workbench containers is challenging. Session images create users automatically (with
consistent UIDs / GIDs). However, creating users in the Workbench containers is a responsibility that falls to the
administrator.
The most common way to provision users is via `sssd`.
The [latest Workbench container](https://github.com/rstudio/rstudio-docker-products/tree/main/workbench#user-provisioning)
has `sssd` included and running by default (see `userProvisioning` configuration files above).
The other way that this can be managed is via a lightweight startup service (runs once at startup and then sleeps forever)
or a polling service (checks at regular intervals). Either can be written easily in `bash` or another programming language.
However, it is important to use caution for the following:
- UID / GID consistency:
- Linux usernames and their matching to UID/GID must be consistent across all nodes and across time.
- Failing can cause security issues and access by some users to access view they should not be allowed to see.
- Usernames cannot have `@`.
- The `@` sign (often used in emails with SSO) is a problem for Workbench because some operating systems disallow `@` signs in linux usernames.
- `supervisord` is configured by default to exit if any of its child processes exit.
- If you use `config.startupCustom` to configure a user management service, be careful that it does not exit unnecessarily.
We do not provide such a service out-of-the box because we intend for Workbench to solve this problem in a
future release. Please contact your account representative if you have feedback or questions about this
workflow.
### PAM
When starting sessions on Workbench, PAM configuration is often very important, even if PAM is not being used as
an authentication mechanism. The Workbench Helm chart allows creating custom PAM files via the `config.pam`
values section.
Each key under `config.pam` becomes a PAM configuration file, and is mounted into `/etc/pam.d/` in the container. For
example:
```yaml
config:
pam:
rstudio: |
# the rstudio PAM config file
# will be used verbatim
rstudio-session: |
# the rstudio-session PAM config file
# will be used verbatim
```
## RStudio profiles
Profiles are used to define product behavior (in `.ini` file format) based on user and group membership.
Sections define whether a set of configurations is applied to a user's jobs based on the following criteria:
- If section header is `[*]`, it applies to all users.
- If a user's username is `myusername`, the section `[myusername]` applies to them.
- If a user is in the `allusers` group, then the section `[@allusers]` applies to them
The product reads configuration from top to bottom and "last-in-wins" for a given configuration value.
### `/etc/rstudio/profiles`
The `/etc/rstudio/profiles` file enables you to tailor the behavior of sessions on a per-user or per-group basis. See the [Posit Workbench Administrator Guide - User and Group Profiles](https://docs.posit.co/ide/server-pro/rstudio_pro_sessions/user_and_group_profiles.html) page for more information.
In the `values.yaml`, define the content of `/etc/rstudio/profiles` in `config.server.profiles`. For example:
```yaml
config:
server:
profiles:
"*":
session-limit: 5
session-timeout-minutes: 60
```
Becomes:
_/etc/rstudio/profiles_
```ini
[*]
session-limit=5
session-timeout-minutes=60
```
### `/etc/rstudio/launcher.kubernetes.profiles.conf`
The `/etc/rstudio/launcher.kubernetes.profiles.conf` contains the configuration of resource limits by user and group when using the Kubernetes Launcher Plugin. In the `values.yaml`, define the content of `/etc/rstudio/launcher.kubernetes.profiles.conf ` in the `config.profiles.launcher.kubernetes.profiles.conf` file. The `config.profiles` section has a couple of niceties that are added in by default.
- YAML arrays like the following becomes "comma-joined." For instance, the following becomes: `some-key=value1,value2`
```yaml
some-key:
- value1
- value2
```
- The `[*]` section has arrays "appended" to user and group sections, along with "defaults" defined by the chart.
For example:
```yaml
config:
profiles:
launcher.kubernetes.profiles.conf:
"*":
some-key:
- value1
- value2
myuser:
some-key:
- value4
- value5
```
Becomes:
_/etc/rstudio/launcher.kubernetes.profiles.conf_
```ini
[*]
some-key: value1,value2
[myuser]
some-key: value1,value2,value3,value4
```
:::{.callout-note}
This appending/concatenation/array translation behavior only works with the helm chart.
:::
### Job Json overrides
If you want to customize the job launch process (i.e., how sessions are defined), edit the following configuration:
- Modify:
```yaml
config.profiles.launcher\.kubernetes\.profiles\.conf.<< some selector >>.job-json-overrides`
```
- Create an array of maps with the following keys:
- `target`: The "target" part of the job spec to replace.
- `name`: A unique identifier (ideally with no spaces) becomes a configuration filename on disk.
- `json`: A YAML value that is translated directly to JSON and injected into the job spec at `target`.
Explore the docs in the [Helm repository](https://github.com/rstudio/helm/blob/main/docs/customize.md) for additional information.
```yaml
config:
profiles:
launcher.kubernetes.profiles.conf:
"*":
job-json-overrides:
- target: "/spec/template/spec/containers/0/imagePullPolicy"
json: "Always"
name: imagePullPolicy
- target: "/spec/template/spec/imagePullSecrets"
json:
- name: my-pull-secret
name: imagePullSecrets
container-images:
- "one-image:tag"
- "two-image:tag
```
## Sealed secrets
This chart supports the use of [Sealed Secrets](https://github.com/bitnami-labs/sealed-secrets) to allow for storing secrets in SCM and to ensure secrets are never leaked via Helm. The target cluster must include a `SealedSecret` controller as the controller is responsible for converting a `SealedSecret` to a `Secret`.
To activate the use of `SealedSecret` templates instead of `Secret` templates in the chart, set `sealedSecret.enabled=true` and ensure the following values are all encrypted (the chart does not support mixing encrypted values with unencrypted values):
- `config.secret`
- `config.sessionSecret`
- `config.userProvisioning`
- `launcherPem`
- `secureCookieKey` (or `global.secureCookieKey`)
Use of [Sealed secrets](https://github.com/bitnami-labs/sealed-secrets) disables the chart's auto-generation and reuse capabilities for `launcherPem` and `secureCookieKey`. `launcherPem` is an RSA private key, which can be generated via an RSA tool such as Helm's [`genPrivateKey`](https://helm.sh/docs/chart_template_guide/function_list/#genprivatekey) function. `secureCookieKey` is typically a UUID, which can be generated via a UUID generator such as Helm's [`uuidv4`](https://helm.sh/docs/chart_template_guide/function_list/#uuid-functions) function.
{{ template "chart.valuesSection" . }}
{{ template "helm-docs.versionFooter" . }}