Skip to content

Commit

Permalink
Merge pull request #176 from rstudio/launcher-config
Browse files Browse the repository at this point in the history
Allow Launcher to self-configure Kubernetes
  • Loading branch information
bschwedler authored May 26, 2022
2 parents 51b4e82 + 6c78a73 commit ac8f676
Show file tree
Hide file tree
Showing 25 changed files with 169 additions and 63 deletions.
6 changes: 3 additions & 3 deletions charts/rstudio-connect/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: rstudio-library
repository: file://../rstudio-library
version: 0.1.21
digest: sha256:7bc6016cffb72b8e8880c88470bc2cafedd0614140efb0e9cd42640b7d2eccb6
generated: "2022-01-05T11:41:03.825289-05:00"
version: 0.1.22
digest: sha256:67078d006502ce6427289f3353527128432dc9bb6d77464ea362c2782b534a72
generated: "2022-04-07T12:15:12.285746972-05:00"
4 changes: 2 additions & 2 deletions charts/rstudio-connect/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: rstudio-connect
description: Official Helm chart for RStudio Connect
version: 0.2.31
version: 0.2.32
apiVersion: v2
appVersion: 2022.05.0
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
Expand All @@ -13,7 +13,7 @@ maintainers:
url: https://github.com/sol-eng
dependencies:
- name: rstudio-library
version: 0.1.21
version: 0.1.22
repository: file://../rstudio-library
annotations:
artifacthub.io/images: |
Expand Down
4 changes: 4 additions & 0 deletions charts/rstudio-connect/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.2.32

- Update `rstudio-library` chart version. Add support for lists in INI file sections.

# 0.2.31

- Bump Connect version to 2022.05.0
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-connect/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RStudio Connect

![Version: 0.2.31](https://img.shields.io/badge/Version-0.2.31-informational?style=flat-square) ![AppVersion: 2022.05.0](https://img.shields.io/badge/AppVersion-2022.05.0-informational?style=flat-square)
![Version: 0.2.32](https://img.shields.io/badge/Version-0.2.32-informational?style=flat-square) ![AppVersion: 2022.05.0](https://img.shields.io/badge/AppVersion-2022.05.0-informational?style=flat-square)

#### _Official Helm chart for RStudio Connect_

Expand All @@ -23,11 +23,11 @@ As a result, please:

## Installing the Chart

To install the chart with the release name `my-release` at version 0.2.31:
To install the chart with the release name `my-release` at version 0.2.32:

```bash
helm repo add rstudio https://helm.rstudio.com
helm install my-release rstudio/rstudio-connect --version=0.2.31
helm install my-release rstudio/rstudio-connect --version=0.2.32
```

## Required Configuration
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-launcher-rbac/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: rstudio-library
repository: file://../rstudio-library
version: 0.1.21
digest: sha256:7bc6016cffb72b8e8880c88470bc2cafedd0614140efb0e9cd42640b7d2eccb6
generated: "2022-02-18T14:37:26.158615-05:00"
version: 0.1.22
digest: sha256:67078d006502ce6427289f3353527128432dc9bb6d77464ea362c2782b534a72
generated: "2022-04-07T12:15:16.512343746-05:00"
6 changes: 3 additions & 3 deletions charts/rstudio-launcher-rbac/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: rstudio-launcher-rbac
description: RBAC definition for the RStudio Job Launcher
type: application
version: 0.2.11
appVersion: 0.2.11
version: 0.2.12
appVersion: 0.2.12
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
sources:
- https://github.com/rstudio/helm
Expand All @@ -13,7 +13,7 @@ maintainers:
url: https://github.com/sol-eng
dependencies:
- name: rstudio-library
version: 0.1.21
version: 0.1.22
repository: file://../rstudio-library
keywords:
- "data science"
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-launcher-rbac/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rstudio-launcher-rbac

![Version: 0.2.11](https://img.shields.io/badge/Version-0.2.11-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.11](https://img.shields.io/badge/AppVersion-0.2.11-informational?style=flat-square)
![Version: 0.2.12](https://img.shields.io/badge/Version-0.2.12-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.12](https://img.shields.io/badge/AppVersion-0.2.12-informational?style=flat-square)

#### _RBAC definition for the RStudio Job Launcher_

Expand All @@ -20,11 +20,11 @@ As a result, please:

## Installing the Chart

To install the chart with the release name `my-release` at version 0.2.11:
To install the chart with the release name `my-release` at version 0.2.12:

```bash
helm repo add rstudio https://helm.rstudio.com
helm install my-release rstudio/rstudio-launcher-rbac --version=0.2.11
helm install my-release rstudio/rstudio-launcher-rbac --version=0.2.12
```

## Common Usage
Expand Down
4 changes: 2 additions & 2 deletions charts/rstudio-library/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: rstudio-library
description: Helm library helpers for use by Official RStudio charts
type: library
version: 0.1.21
appVersion: 0.1.21
version: 0.1.22
appVersion: 0.1.22

icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
home: https://www.rstudio.com
Expand Down
19 changes: 19 additions & 0 deletions charts/rstudio-library/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# 0.1.22

- Add support for list of INI file sections, like the following example

```yaml
config:
server:
launcher.conf:
cluster:
- name: Cluster1
type: Kubernetes
- name: Cluster2
type: Kubernetes
config-file: /path/to/config/file
```
- Fixes issue where RBAC service account is always created even when `serviceAccountCreate: false`
`serviceAccountCreate` is required and must be specified as a boolean

# 0.1.20

- Add a `_tplvalues.tpl` helper
Expand Down
2 changes: 1 addition & 1 deletion charts/rstudio-library/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rstudio-library

![Version: 0.1.21](https://img.shields.io/badge/Version-0.1.21-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.21](https://img.shields.io/badge/AppVersion-0.1.21-informational?style=flat-square)
![Version: 0.1.22](https://img.shields.io/badge/Version-0.1.22-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.22](https://img.shields.io/badge/AppVersion-0.1.22-informational?style=flat-square)

#### _Helm library helpers for use by Official RStudio charts_

Expand Down
22 changes: 12 additions & 10 deletions charts/rstudio-library/templates/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
i.e.
{ "Server" = {"Host" = "value", "another" = ["multiple", "values"]}}
Valid values depend on the product
*/ -}}
*/ -}}

{{- define "rstudio-library.config.gcfg" -}}
{{- range $section,$keys := . -}}
Expand Down Expand Up @@ -50,18 +50,20 @@
{{- $keys | nindent 2 }}
{{- else }}
{{- range $parent, $child := $keys -}}
{{- if kindIs "map" $child }}
{{- if not ( kindIs "slice" $keys ) -}}
{{/* ini files may have multiple sections with the same name */}}
{{- $sections := ( (kindIs "slice" $child) | ternary $child ( list $child ))}}
{{- range $i, $section := $sections -}}
{{- if kindIs "map" $section }}
{{- if not ( kindIs "slice" $keys ) -}}
{{- printf "[%s]" (toString $parent) | nindent 2 }}
{{- end }}
{{- range $key, $val := $section }}
{{- printf "%s=%s" (toString $key) (toString $val) | nindent 2 }}
{{- end }}
{{- printf "" | nindent 0 }}
{{- printf "[%s]" (toString $parent) | nindent 2 }}
{{- else }}
{{- printf "" | nindent 0 }}
{{- end }}
{{- range $key, $val := $child }}
{{- printf "%s=%s" (toString $key) (toString $val) | nindent 2 }}
{{- printf "%s=%s" (toString $parent) (toString $section) | nindent 2 }}
{{- end }}
{{- else }}
{{- printf "%s=%s" (toString $parent) (toString $child) | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
3 changes: 2 additions & 1 deletion charts/rstudio-library/templates/_rbac.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
*/ -}}
{{- define "rstudio-library.rbac" -}}
{{- $serviceAccountAnnotations := default (dict) .serviceAccountAnnotations }}
{{- $serviceAccountCreate := default true .serviceAccountCreate }}
{{- include "rstudio-library.debug.type-check" (dict "name" "serviceAccountCreate" "object" .serviceAccountCreate "expected" "bool" "description" "enabling cluster service account creation") }}
{{- $serviceAccountCreate := eq .serviceAccountCreate false | ternary false true }}
{{- $serviceAccountName := .serviceAccountName }}
{{- $roleName := default $serviceAccountName .roleName }}
{{- $removeNamespaceReferences := default false .removeNamespaceReferences }}
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-pm/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: rstudio-library
repository: file://../rstudio-library
version: 0.1.21
digest: sha256:7bc6016cffb72b8e8880c88470bc2cafedd0614140efb0e9cd42640b7d2eccb6
generated: "2022-02-18T14:35:16.491951-05:00"
version: 0.1.22
digest: sha256:67078d006502ce6427289f3353527128432dc9bb6d77464ea362c2782b534a72
generated: "2022-04-07T12:15:20.723889381-05:00"
4 changes: 2 additions & 2 deletions charts/rstudio-pm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: rstudio-pm
description: Official Helm chart for RStudio Package Manager
version: 0.3.8
version: 0.3.9
apiVersion: v2
appVersion: 2022.04.0-7
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
Expand All @@ -14,7 +14,7 @@ maintainers:
url: https://github.com/rstudio/helm
dependencies:
- name: rstudio-library
version: 0.1.21
version: 0.1.22
repository: file://../rstudio-library
annotations:
artifacthub.io/images: |
Expand Down
7 changes: 6 additions & 1 deletion charts/rstudio-pm/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@

# 0.3.9

- Update `rstudio-library` chart version. Add support for lists in INI file sections.

# 0.3.8

- Add `securityContext` for pod and container as documented [here](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)

# 0.3.7

- Add `extraContainers` value. This allows adding a list of additional containers.

# 0.3.6

- Add `pod.lifecycle` value. This allows running lifecycle hooks like postStart commands!
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-pm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RStudio Package Manager

![Version: 0.3.8](https://img.shields.io/badge/Version-0.3.8-informational?style=flat-square) ![AppVersion: 2022.04.0-7](https://img.shields.io/badge/AppVersion-2022.04.0--7-informational?style=flat-square)
![Version: 0.3.9](https://img.shields.io/badge/Version-0.3.9-informational?style=flat-square) ![AppVersion: 2022.04.0-7](https://img.shields.io/badge/AppVersion-2022.04.0--7-informational?style=flat-square)

#### _Official Helm chart for RStudio Package Manager_

Expand All @@ -23,11 +23,11 @@ As a result, please:

## Installing the Chart

To install the chart with the release name `my-release` at version 0.3.8:
To install the chart with the release name `my-release` at version 0.3.9:

```bash
helm repo add rstudio https://helm.rstudio.com
helm install my-release rstudio/rstudio-pm --version=0.3.8
helm install my-release rstudio/rstudio-pm --version=0.3.9
```

## Required Configuration
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-workbench/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: rstudio-library
repository: file://../rstudio-library
version: 0.1.21
digest: sha256:7bc6016cffb72b8e8880c88470bc2cafedd0614140efb0e9cd42640b7d2eccb6
generated: "2022-02-18T14:35:26.757261-05:00"
version: 0.1.22
digest: sha256:67078d006502ce6427289f3353527128432dc9bb6d77464ea362c2782b534a72
generated: "2022-04-07T08:48:53.61057359-05:00"
4 changes: 2 additions & 2 deletions charts/rstudio-workbench/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: rstudio-workbench
description: Official Helm chart for RStudio Workbench
version: 0.5.11
version: 0.5.12
apiVersion: v2
appVersion: 2022.02.1-461.pro1
icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png
Expand All @@ -13,7 +13,7 @@ maintainers:
url: https://github.com/sol-eng
dependencies:
- name: rstudio-library
version: 0.1.21
version: 0.1.22
repository: file://../rstudio-library
annotations:
artifacthub.io/images: |
Expand Down
7 changes: 7 additions & 0 deletions charts/rstudio-workbench/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 0.5.12

- Allow Launcher to Auto Configure Kubernetes variables
- Removes dynamic generation of `launcher.kubernetes.conf` file
- Add `launcher.kubernetes.conf` to default values, setting `kubernetes-namespace` to the value of `launcher.namespace`
- Update `rstudio-library` chart version. Add support for lists in INI file sections.

# 0.5.11

- Update docs for `job-json-overrides` (fix a key reference issue and link to new docs in the helm repo)
Expand Down
6 changes: 3 additions & 3 deletions charts/rstudio-workbench/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RStudio Workbench

![Version: 0.5.11](https://img.shields.io/badge/Version-0.5.11-informational?style=flat-square) ![AppVersion: 2022.02.1-461.pro1](https://img.shields.io/badge/AppVersion-2022.02.1--461.pro1-informational?style=flat-square)
![Version: 0.5.12](https://img.shields.io/badge/Version-0.5.12-informational?style=flat-square) ![AppVersion: 2022.02.1-461.pro1](https://img.shields.io/badge/AppVersion-2022.02.1--461.pro1-informational?style=flat-square)

#### _Official Helm chart for RStudio Workbench_

Expand All @@ -23,11 +23,11 @@ As a result, please:

## Installing the Chart

To install the chart with the release name `my-release` at version 0.5.11:
To install the chart with the release name `my-release` at version 0.5.12:

```bash
helm repo add rstudio https://helm.rstudio.com
helm install my-release rstudio/rstudio-workbench --version=0.5.11
helm install my-release rstudio/rstudio-workbench --version=0.5.12
```

## Required Configuration
Expand Down
16 changes: 2 additions & 14 deletions charts/rstudio-workbench/prestart-launcher.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ main() {

local cacert='/var/run/secrets/kubernetes.io/serviceaccount/ca.crt'
local k8s_url="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}"
local launcher_k8s_conf="${dyn_dir}/launcher.kubernetes.conf"
local launcher_ns="${RSTUDIO_LAUNCHER_NAMESPACE:-rstudio}"

_logf 'Loading service account token'
local sa_token
sa_token="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"

_logf 'Loading service account ca.crt'
local ca_string
ca_string="$(tr -d '\n' <"${cacert}" | base64 | tr -d '\n')"

_logf 'Ensuring %s exists' "${dyn_dir}"
mkdir -p "${dyn_dir}"

# Empty if enabled, set to "disabled" by default
if [[ -z "${RSTUDIO_LAUNCHER_STARTUP_HEALTH_CHECK}" ]]; then
_logf 'Checking kubernetes health via %s' "${k8s_url}"
# shellcheck disable=SC2086
curl ${RSTUDIO_LAUNCHER_STARTUP_HEALTH_CHECK_ARGS} \
-H "Authorization: Bearer ${sa_token}" \
--cacert "${cacert}" \
Expand All @@ -34,14 +30,6 @@ main() {
printf '\n'
fi

_logf 'Generating %s' "${launcher_k8s_conf}"
cat >"${launcher_k8s_conf}" <<EOF
api-url=${k8s_url}
auth-token=${sa_token}
kubernetes-namespace=${launcher_ns}
certificate-authority=${ca_string}
EOF

_logf 'Configuring certs'
cp -v "${cacert}" ${dyn_dir}/k8s-cert 2>&1 | _indent
mkdir -p /usr/local/share/ca-certificates/Kubernetes
Expand Down
3 changes: 3 additions & 0 deletions charts/rstudio-workbench/templates/configmap-general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
{{- $defaultIDEServiceURL := printf "http://%s.%s.svc.cluster.local:80" $defaultIDEServiceName $.Release.Namespace }}
{{- $defaultRServerConfigValues := dict "launcher-sessions-callback-address" ($defaultIDEServiceURL) }}
{{- $defaultRServerConfig := dict "rserver.conf" ($defaultRServerConfigValues) }}
{{- $defaultLauncherK8sConfigValues := dict "kubernetes-namespace" (default $.Release.Namespace .Values.launcher.namespace) }}
{{- $defaultLauncherK8sConfig := dict "launcher.kubernetes.conf" ($defaultLauncherK8sConfigValues) }}
---
apiVersion: v1
kind: ConfigMap
Expand All @@ -43,6 +45,7 @@ data:
{{- $overrideDict = mergeOverwrite $licenseServerConf $overrideDict }}
{{- end }}
{{- $overrideDict = mergeOverwrite $defaultRServerConfig $overrideDict }}
{{- $overrideDict = mergeOverwrite $defaultLauncherK8sConfig $overrideDict }}
{{ include "rstudio-library.config.ini" $overrideDict | indent 2 }}
{{/* helper variables to make things here a bit more sane */}}
{{- $profilesConfig := .Values.config.profiles }}
Expand Down
2 changes: 1 addition & 1 deletion charts/rstudio-workbench/templates/configmap-startup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ metadata:
name: {{ include "rstudio-workbench.fullname" . }}-start-user
namespace: {{ $.Release.Namespace }}
data:
{{- include "rstudio-library.config.ini" .Values.config.startupUserProvisioning | nindent 2}}
{{- include "rstudio-library.config.ini" .Values.config.startupUserProvisioning | nindent 2 }}
{{- end }}
{{- if .Values.config.startupCustom }}
---
Expand Down
Loading

0 comments on commit ac8f676

Please sign in to comment.