Skip to content

Commit c6c1b08

Browse files
authored
feat: add nameservice configuration for current user execution
Merge pull request #727 from rstudio/lucas-configure-nameservice-for-racu-sso
2 parents 703ce96 + 6584020 commit c6c1b08

File tree

7 files changed

+384
-7
lines changed

7 files changed

+384
-7
lines changed

charts/rstudio-connect/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: rstudio-connect
22
description: Official Helm chart for Posit Connect
3-
version: 0.8.17
3+
version: 0.8.18
44
apiVersion: v2
55
appVersion: 2025.12.1
66
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png

charts/rstudio-connect/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Posit Connect
22

3-
![Version: 0.8.17](https://img.shields.io/badge/Version-0.8.17-informational?style=flat-square) ![AppVersion: 2025.12.1](https://img.shields.io/badge/AppVersion-2025.12.1-informational?style=flat-square)
3+
![Version: 0.8.18](https://img.shields.io/badge/Version-0.8.18-informational?style=flat-square) ![AppVersion: 2025.12.1](https://img.shields.io/badge/AppVersion-2025.12.1-informational?style=flat-square)
44

55
#### _Official Helm chart for Posit Connect_
66

@@ -30,11 +30,11 @@ To ensure reproducibility in your environment and insulate yourself from future
3030

3131
## Installing the chart
3232

33-
To install the chart with the release name `my-release` at version 0.8.17:
33+
To install the chart with the release name `my-release` at version 0.8.18:
3434

3535
```{.bash}
3636
helm repo add rstudio https://helm.rstudio.com
37-
helm upgrade --install my-release rstudio/rstudio-connect --version=0.8.17
37+
helm upgrade --install my-release rstudio/rstudio-connect --version=0.8.18
3838
```
3939

4040
To explore other chart versions, look at:
@@ -278,6 +278,11 @@ The Helm `config` values are converted into the `rstudio-connect.gcfg` service c
278278
| license.server | bool | `false` | server is the <hostname>:<port> for a license server |
279279
| livenessProbe | object | `{"enabled":false,"failureThreshold":10,"httpGet":{"path":"/__ping__","port":3939},"initialDelaySeconds":10,"periodSeconds":5,"timeoutSeconds":2}` | Used to configure the container's livenessProbe. Only included if enabled = true |
280280
| nameOverride | string | `""` | The name of the chart deployment (can be overridden) |
281+
| nameservice | object | `{"apiKey":"","enabled":false,"secretName":"","server":"http://127.0.0.1:3939"}` | Nameservice configuration for current user execution (RunAsCurrentUser). This can only be enabled if using an SSO authentication provider (OAuth2, SAML, or LDAP). |
282+
| nameservice.apiKey | string | `""` | Connect API key for nameservice module. Must be a Viewer API key. |
283+
| nameservice.enabled | bool | `false` | Whether to enable nameservice integration. |
284+
| nameservice.secretName | string | `""` | Optional: name of existing secret containing libnss_connect.conf (overrides apiKey and server). The secret must be in the same namespace as the Connect deployment. |
285+
| nameservice.server | string | `"http://127.0.0.1:3939"` | Connect server URL for nameservice module. |
281286
| nodeSelector | object | `{}` | A map used verbatim as the pod's "nodeSelector" definition |
282287
| pod.affinity | object | `{}` | A map used verbatim as the pod's "affinity" definition |
283288
| pod.annotations | object | `{}` | Additional annotations to add to the rstudio-connect pods |

charts/rstudio-connect/prestart.bash

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
set -o errexit
33
set -o pipefail
44

5-
main() {
6-
local startup_script="${1:-/usr/local/bin/startup.sh}"
7-
5+
kubernetes_health_check() {
86
local cacert='/var/run/secrets/kubernetes.io/serviceaccount/ca.crt'
97
local k8s_url="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"
108

@@ -18,6 +16,50 @@ main() {
1816
--cacert "${cacert}" \
1917
"${k8s_url}/healthz" 2>&1 | _indent
2018
printf '\n'
19+
}
20+
21+
configure_nameservice_module() {
22+
# Check if NSS Connect config file exists (mounted as a secret)
23+
if [[ ! -f "/etc/libnss_connect.conf" ]]; then
24+
_logf 'Nameservice config not found at /etc/libnss_connect.conf. Skipping nameservice setup'
25+
return 0
26+
fi
27+
28+
_logf 'Found /etc/libnss_connect.conf mounted from secret'
29+
_logf 'Configuring nameservice module'
30+
31+
cp /etc/nsswitch.conf /etc/nsswitch.conf.backup
32+
33+
# Ensure required lines exist in nsswitch.conf
34+
# Default to 'files' which matches glibc's implicit default when a line is missing
35+
for db in passwd group initgroups; do
36+
grep -q "^${db}:" /etc/nsswitch.conf || echo "${db}: files" >> /etc/nsswitch.conf
37+
done
38+
39+
# Add 'connect' module to each line
40+
sed -i \
41+
-e '/^passwd:/ { /connect/! s/$/ connect/ }' \
42+
-e '/^group:/ { /connect/! s/$/ connect/ }' \
43+
-e '/^initgroups:/ { /connect/! s/$/ connect/ }' \
44+
/etc/nsswitch.conf
45+
46+
_logf 'Updated /etc/nsswitch.conf with connect module'
47+
48+
# Run the nameservice activation script
49+
if [[ -x "/opt/rstudio-connect/extras/nameservice/activate-nameservice.sh" ]]; then
50+
/opt/rstudio-connect/extras/nameservice/activate-nameservice.sh
51+
else
52+
_logf 'WARNING: nameservice activation script not found or not executable'
53+
fi
54+
55+
printf '\n'
56+
}
57+
58+
main() {
59+
local startup_script="${1:-/usr/local/bin/startup.sh}"
60+
61+
kubernetes_health_check
62+
configure_nameservice_module
2163

2264
_logf 'Replacing process with %s' "${startup_script}"
2365
exec "${startup_script}"

charts/rstudio-connect/templates/deployment.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ spec:
219219
{{- end }}
220220
{{- end }}
221221
{{ include "rstudio-library.license-mount" (dict "license" ( .Values.license )) | indent 10 }}
222+
{{- if .Values.nameservice.enabled }}
223+
- name: nameservice-config
224+
mountPath: "/etc/libnss_connect.conf"
225+
subPath: "libnss_connect.conf"
226+
readOnly: true
227+
{{- end }}
222228
{{- if .Values.pod.volumeMounts }}
223229
{{- toYaml .Values.pod.volumeMounts | nindent 10 }}
224230
{{- end }}
@@ -289,6 +295,15 @@ spec:
289295
{{- if .Values.pod.volumes }}
290296
{{ toYaml .Values.pod.volumes | indent 6 }}
291297
{{- end }}
298+
{{- if .Values.nameservice.enabled }}
299+
- name: nameservice-config
300+
secret:
301+
secretName: {{ .Values.nameservice.secretName | default (printf "%s-nameservice-config" (include "rstudio-connect.fullname" .)) }}
302+
defaultMode: 0444
303+
items:
304+
- key: libnss_connect.conf
305+
path: libnss_connect.conf
306+
{{- end }}
292307
{{- if .Values.launcher.enabled }}
293308
{{- if .Values.launcher.useTemplates }}
294309
- name: rstudio-connect-templates
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{- if .Values.nameservice.enabled }}
2+
{{- $authProvider := "" }}
3+
{{- if hasKey .Values.config "Authentication" }}
4+
{{- if hasKey .Values.config.Authentication "Provider" }}
5+
{{- $authProvider = .Values.config.Authentication.Provider }}
6+
{{- end }}
7+
{{- end }}
8+
{{- $validProviders := list "oauth2" "saml" "ldap" }}
9+
{{- if not (has $authProvider $validProviders) }}
10+
{{- fail (printf "nameservice.enabled requires config.Authentication.Provider to be one of: %s. Current provider: '%s'" (join ", " $validProviders) $authProvider) }}
11+
{{- end }}
12+
{{- if and .Values.nameservice.secretName .Values.nameservice.apiKey }}
13+
{{- fail "nameservice.secretName and nameservice.apiKey cannot both be set. Use secretName to use an existing secret OR apiKey to create a new secret." }}
14+
{{- end }}
15+
{{- if and (not .Values.nameservice.secretName) (not .Values.nameservice.apiKey) }}
16+
{{- fail "When nameservice.enabled is true, either nameservice.secretName (for existing secret) or nameservice.apiKey (to create new secret) must be provided." }}
17+
{{- end }}
18+
{{- if not .Values.nameservice.secretName }}
19+
{{- $config := printf "CONNECT_API_KEY=%s\nCONNECT_SERVER=%s" .Values.nameservice.apiKey .Values.nameservice.server }}
20+
apiVersion: v1
21+
kind: Secret
22+
metadata:
23+
name: {{ include "rstudio-connect.fullname" . }}-nameservice-config
24+
namespace: {{ $.Release.Namespace }}
25+
labels:
26+
{{- include "rstudio-connect.labels" . | nindent 4 }}
27+
type: Opaque
28+
data:
29+
libnss_connect.conf: {{ $config | b64enc | quote }}
30+
{{- end }}
31+
{{- end }}

0 commit comments

Comments
 (0)