diff --git a/charts/rstudio-connect/Chart.yaml b/charts/rstudio-connect/Chart.yaml index c8c9c7bc..7cc2a854 100644 --- a/charts/rstudio-connect/Chart.yaml +++ b/charts/rstudio-connect/Chart.yaml @@ -1,6 +1,6 @@ name: rstudio-connect description: Official Helm chart for RStudio Connect -version: 0.5.1 +version: 0.5.2 apiVersion: v2 appVersion: 2023.06.0 icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png diff --git a/charts/rstudio-connect/NEWS.md b/charts/rstudio-connect/NEWS.md index c85f6f58..a0fb123b 100644 --- a/charts/rstudio-connect/NEWS.md +++ b/charts/rstudio-connect/NEWS.md @@ -1,3 +1,8 @@ +# 0.5.2 + +- Add support for `pod.command` and `pod.env` for Connect off-host execution sessions + - `pod.command` is a hack for now... it will be removed eventually + # 0.5.1 - Bump Connect version to 2023.06.0 diff --git a/charts/rstudio-connect/README.md b/charts/rstudio-connect/README.md index b6ed3d30..5d87d7cc 100644 --- a/charts/rstudio-connect/README.md +++ b/charts/rstudio-connect/README.md @@ -1,6 +1,6 @@ # RStudio Connect -![Version: 0.5.1](https://img.shields.io/badge/Version-0.5.1-informational?style=flat-square) ![AppVersion: 2023.06.0](https://img.shields.io/badge/AppVersion-2023.06.0-informational?style=flat-square) +![Version: 0.5.2](https://img.shields.io/badge/Version-0.5.2-informational?style=flat-square) ![AppVersion: 2023.06.0](https://img.shields.io/badge/AppVersion-2023.06.0-informational?style=flat-square) #### _Official Helm chart for RStudio Connect_ @@ -26,11 +26,11 @@ To ensure reproducibility in your environment and insulate yourself from future ## Installing the Chart -To install the chart with the release name `my-release` at version 0.5.1: +To install the chart with the release name `my-release` at version 0.5.2: ```bash helm repo add rstudio https://helm.rstudio.com -helm upgrade --install my-release rstudio/rstudio-connect --version=0.5.1 +helm upgrade --install my-release rstudio/rstudio-connect --version=0.5.2 ``` To explore other chart versions, take a look at: @@ -118,7 +118,8 @@ The Helm `config` values are converted into the `rstudio-connect.gcfg` service c | launcher.includeTemplateValues | bool | `true` | whether to include the templateValues rendering process | | launcher.launcherKubernetesProfilesConf | object | `{}` | User definition of launcher.kubernetes.profiles.conf for job customization | | launcher.namespace | string | `""` | The namespace to launch sessions into. Uses the Release namespace by default | -| launcher.templateValues | object | `{"job":{"annotations":{},"labels":{}},"pod":{"affinity":{},"annotations":{},"containerSecurityContext":{},"defaultSecurityContext":{},"env":[],"extraContainers":[],"imagePullPolicy":"","imagePullSecrets":[],"initContainers":[],"labels":{},"nodeSelector":{},"priorityClassName":"","securityContext":{},"serviceAccountName":"","tolerations":[],"volumeMounts":[],"volumes":[]},"service":{"annotations":{},"labels":{},"type":"ClusterIP"}}` | Values to pass along to the RStudio Connect session templating process | +| launcher.templateValues | object | `{"job":{"annotations":{},"labels":{}},"pod":{"affinity":{},"annotations":{},"command":[],"containerSecurityContext":{},"defaultSecurityContext":{},"env":[],"extraContainers":[],"imagePullPolicy":"","imagePullSecrets":[],"initContainers":[],"labels":{},"nodeSelector":{},"priorityClassName":"","securityContext":{},"serviceAccountName":"","tolerations":[],"volumeMounts":[],"volumes":[]},"service":{"annotations":{},"labels":{},"type":"ClusterIP"}}` | Values to pass along to the RStudio Connect session templating process | +| launcher.templateValues.pod.command | list | `[]` | command for all pods. This is really not something we should expose and will be removed once we have a better option | | launcher.useTemplates | bool | `true` | Whether to use launcher templates when launching sessions. Defaults to true | | license.file | object | `{"contents":false,"mountPath":"/etc/rstudio-licensing","mountSubPath":false,"secret":false,"secretKey":"license.lic"}` | the file section is used for licensing with a license file | | license.file.contents | bool | `false` | contents is an in-line license file | diff --git a/charts/rstudio-connect/files/job.tpl b/charts/rstudio-connect/files/job.tpl index 089ec666..c8279a75 100644 --- a/charts/rstudio-connect/files/job.tpl +++ b/charts/rstudio-connect/files/job.tpl @@ -1,6 +1,6 @@ # Version: 2.3.1 # DO NOT MODIFY the "Version: " key -# Helm Version: v1 +# Helm Version: v3 {{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }} apiVersion: batch/v1 kind: Job @@ -151,7 +151,10 @@ spec: imagePullPolicy: {{- . | nindent 12 }} {{- end }} {{- $isShell := false }} - {{- if .Job.command }} + {{- if $templateData.pod.command }} + command: {{- toYaml $templateData.pod.command | nindent 12 }} + {{- if .Job.command }}{{- $isShell = true }}{{- end }} + {{- else if .Job.command }} command: ['/bin/sh'] {{- $isShell = true }} {{- else }} @@ -206,7 +209,7 @@ spec: name: {{ get . "secret" }} key: {{ get . "key" }} {{- end }} - {{- if .Values.pod.env }} + {{- if $templateData.pod.env }} {{- toYaml $templateData.pod.env | nindent 12 }} {{- end }} {{- end }} diff --git a/charts/rstudio-connect/files/service.tpl b/charts/rstudio-connect/files/service.tpl index 3dae4ebc..f2b506ae 100644 --- a/charts/rstudio-connect/files/service.tpl +++ b/charts/rstudio-connect/files/service.tpl @@ -1,6 +1,6 @@ # Version: 2.3.1 # DO NOT MODIFY the "Version: " key -# Helm Version: v1 +# Helm Version: v3 {{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }} apiVersion: v1 kind: Service diff --git a/charts/rstudio-connect/values.yaml b/charts/rstudio-connect/values.yaml index 67d3d435..efb75f0f 100644 --- a/charts/rstudio-connect/values.yaml +++ b/charts/rstudio-connect/values.yaml @@ -287,6 +287,8 @@ launcher: affinity: {} nodeSelector: {} priorityClassName: "" + # -- command for all pods. This is really not something we should expose and will be removed once we have a better option + command: [] job: annotations: {} labels: {} diff --git a/charts/rstudio-workbench/Chart.yaml b/charts/rstudio-workbench/Chart.yaml index 592e8937..7b3211f9 100644 --- a/charts/rstudio-workbench/Chart.yaml +++ b/charts/rstudio-workbench/Chart.yaml @@ -1,6 +1,6 @@ name: rstudio-workbench description: Official Helm chart for RStudio Workbench -version: 0.6.2 +version: 0.6.3 apiVersion: v2 appVersion: 2023.06.0 icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png diff --git a/charts/rstudio-workbench/NEWS.md b/charts/rstudio-workbench/NEWS.md index d939aaf2..f89b0c38 100644 --- a/charts/rstudio-workbench/NEWS.md +++ b/charts/rstudio-workbench/NEWS.md @@ -1,3 +1,7 @@ +# 0.6.3 + +- Fix support for `pod.env` on sessions + # 0.6.2 - Add support for [Sealed Secrets](https://github.com/bitnami-labs/sealed-secrets) diff --git a/charts/rstudio-workbench/README.md b/charts/rstudio-workbench/README.md index 40d3ad5b..a1f8cb4f 100644 --- a/charts/rstudio-workbench/README.md +++ b/charts/rstudio-workbench/README.md @@ -1,6 +1,6 @@ # RStudio Workbench -![Version: 0.6.2](https://img.shields.io/badge/Version-0.6.2-informational?style=flat-square) ![AppVersion: 2023.06.0](https://img.shields.io/badge/AppVersion-2023.06.0-informational?style=flat-square) +![Version: 0.6.3](https://img.shields.io/badge/Version-0.6.3-informational?style=flat-square) ![AppVersion: 2023.06.0](https://img.shields.io/badge/AppVersion-2023.06.0-informational?style=flat-square) #### _Official Helm chart for RStudio Workbench_ @@ -27,11 +27,11 @@ To ensure a stable production deployment, please: ## Installing the Chart -To install the chart with the release name `my-release` at version 0.6.2: +To install the chart with the release name `my-release` at version 0.6.3: ```bash helm repo add rstudio https://helm.rstudio.com -helm upgrade --install my-release rstudio/rstudio-workbench --version=0.6.2 +helm upgrade --install my-release rstudio/rstudio-workbench --version=0.6.3 ``` To explore other chart versions, take a look at: @@ -414,7 +414,7 @@ Use of [Sealed Secrets](https://github.com/bitnami-labs/sealed-secrets) disables | launcher.includeTemplateValues | bool | `true` | whether to include the templateValues rendering process | | launcher.kubernetesHealthCheck | object | `{"enabled":true,"extraCurlArgs":["-fsSL"]}` | configuration for the "Kubernetes Health Check" that the launcher entrypoint runs at startup | | launcher.namespace | string | `""` | allow customizing the namespace that sessions are launched into. Note RBAC and some config issues today | -| launcher.templateValues | object | `{"job":{"annotations":{},"labels":{}},"pod":{"affinity":{},"annotations":{},"command":[],"containerSecurityContext":{},"defaultSecurityContext":{},"extraContainers":[],"imagePullPolicy":"","imagePullSecrets":[],"initContainers":[],"labels":{},"nodeSelector":{},"securityContext":{},"serviceAccountName":"","tolerations":[],"volumeMounts":[],"volumes":[]},"service":{"annotations":{},"labels":{},"type":"ClusterIP"}}` | values that are passed along to the launcher job rendering process as a data object (in JSON). These values are then used within session templates. | +| launcher.templateValues | object | `{"job":{"annotations":{},"labels":{}},"pod":{"affinity":{},"annotations":{},"command":[],"containerSecurityContext":{},"defaultSecurityContext":{},"env":[],"extraContainers":[],"imagePullPolicy":"","imagePullSecrets":[],"initContainers":[],"labels":{},"nodeSelector":{},"securityContext":{},"serviceAccountName":"","tolerations":[],"volumeMounts":[],"volumes":[]},"service":{"annotations":{},"labels":{},"type":"ClusterIP"}}` | values that are passed along to the launcher job rendering process as a data object (in JSON). These values are then used within session templates. | | launcher.templateValues.pod.command | list | `[]` | command for all pods. This is really not something we should expose and will be removed once we have a better option | | launcher.useTemplates | bool | `false` | whether to render and use templates in the job launching process | | launcherPem | string | `""` | An inline launcher.pem key. If not provided, one will be auto-generated. See README for more details. | diff --git a/charts/rstudio-workbench/ci/launcher-template-values.yaml b/charts/rstudio-workbench/ci/launcher-template-values.yaml index bc8c2081..f32ffbda 100644 --- a/charts/rstudio-workbench/ci/launcher-template-values.yaml +++ b/charts/rstudio-workbench/ci/launcher-template-values.yaml @@ -26,6 +26,9 @@ launcher: volumeMounts: - name: test mountPath: /tmp/mnt + env: + - name: SOME_ENV_VAR + value: the-env-var-value securityContext: runAsUser: 999 defaultSecurityContext: diff --git a/charts/rstudio-workbench/files/job.tpl b/charts/rstudio-workbench/files/job.tpl index fc027def..c8279a75 100644 --- a/charts/rstudio-workbench/files/job.tpl +++ b/charts/rstudio-workbench/files/job.tpl @@ -1,6 +1,6 @@ # Version: 2.3.1 # DO NOT MODIFY the "Version: " key -# Helm Version: v2 +# Helm Version: v3 {{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }} apiVersion: batch/v1 kind: Job @@ -209,7 +209,7 @@ spec: name: {{ get . "secret" }} key: {{ get . "key" }} {{- end }} - {{- if .Values.pod.env }} + {{- if $templateData.pod.env }} {{- toYaml $templateData.pod.env | nindent 12 }} {{- end }} {{- end }} diff --git a/charts/rstudio-workbench/files/service.tpl b/charts/rstudio-workbench/files/service.tpl index 2e0ea4fc..f2b506ae 100644 --- a/charts/rstudio-workbench/files/service.tpl +++ b/charts/rstudio-workbench/files/service.tpl @@ -1,6 +1,6 @@ # Version: 2.3.1 # DO NOT MODIFY the "Version: " key -# Helm Version: v2 +# Helm Version: v3 {{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }} apiVersion: v1 kind: Service diff --git a/charts/rstudio-workbench/snapshot/complex-values.yaml.lock b/charts/rstudio-workbench/snapshot/complex-values.yaml.lock index 065ce5c7..20932a79 100644 --- a/charts/rstudio-workbench/snapshot/complex-values.yaml.lock +++ b/charts/rstudio-workbench/snapshot/complex-values.yaml.lock @@ -762,12 +762,12 @@ spec: mountPath: "/startup/user-provisioning" - name: rstudio-custom-startup mountPath: "/startup/custom" - - name: rstudio-pam - mountPath: "/etc/pam.d/pam-example" - subPath: "pam-example" - name: rstudio-pam mountPath: "/etc/pam.d/pam-example-2" subPath: "pam-example-2" + - name: rstudio-pam + mountPath: "/etc/pam.d/pam-example" + subPath: "pam-example" - name: rstudio-job-overrides-old mountPath: "/mnt/job-json-overrides" @@ -1029,12 +1029,12 @@ spec: mountPath: "/startup/user-provisioning" - name: rstudio-custom-startup mountPath: "/startup/custom" - - name: rstudio-pam - mountPath: "/etc/pam.d/pam-example" - subPath: "pam-example" - name: rstudio-pam mountPath: "/etc/pam.d/pam-example-2" subPath: "pam-example-2" + - name: rstudio-pam + mountPath: "/etc/pam.d/pam-example" + subPath: "pam-example" - name: rstudio-job-overrides-old mountPath: "/mnt/job-json-overrides" diff --git a/charts/rstudio-workbench/snapshot/launcher-template-values.yaml.lock b/charts/rstudio-workbench/snapshot/launcher-template-values.yaml.lock index bd0dde66..84b27b5b 100644 --- a/charts/rstudio-workbench/snapshot/launcher-template-values.yaml.lock +++ b/charts/rstudio-workbench/snapshot/launcher-template-values.yaml.lock @@ -142,12 +142,12 @@ metadata: data: rstudio-library-templates-data.tpl: | {{- define "rstudio-library.templates.data" -}} - {"job":{"annotations":{"seven":"eight"},"labels":{"nine":"ten"}},"pod":{"affinity":{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"kubernetes.azure.com/scalesetpriority","operator":"In","values":["spot"]}]}]}}},"annotations":{"one":"two"},"command":[],"containerSecurityContext":{"privileged":false},"defaultSecurityContext":{"fsGroupChangePolicy":"Always","runAsGroup":999},"extraContainers":[],"imagePullPolicy":"","imagePullSecrets":[],"initContainers":[],"labels":{"three":"four"},"nodeSelector":{},"securityContext":{"runAsUser":999},"serviceAccountName":"test","tolerations":[{"effect":"NoSchedule","key":"kubernetes.azure.com/scalesetpriority","operator":"Equal","value":"spot"}],"volumeMounts":[{"mountPath":"/tmp/mnt","name":"test"},{"mountPath":"/mnt/session-configmap/rstudio","name":"session-config"},{"mountPath":"/mnt/session-secret/","name":"session-secret"}],"volumes":[{"emptyDir":{},"name":"test"},{"configMap":{"defaultMode":420,"name":"release-name-rstudio-workbench-session"},"name":"session-config"},{"name":"session-secret","secret":{"defaultMode":272,"secretName":"release-name-rstudio-workbench-session-secret"}}]},"service":{"annotations":{"five":"six"},"labels":{},"type":"ClusterIP"}} + {"job":{"annotations":{"seven":"eight"},"labels":{"nine":"ten"}},"pod":{"affinity":{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"kubernetes.azure.com/scalesetpriority","operator":"In","values":["spot"]}]}]}}},"annotations":{"one":"two"},"command":[],"containerSecurityContext":{"privileged":false},"defaultSecurityContext":{"fsGroupChangePolicy":"Always","runAsGroup":999},"env":[{"name":"SOME_ENV_VAR","value":"the-env-var-value"}],"extraContainers":[],"imagePullPolicy":"","imagePullSecrets":[],"initContainers":[],"labels":{"three":"four"},"nodeSelector":{},"securityContext":{"runAsUser":999},"serviceAccountName":"test","tolerations":[{"effect":"NoSchedule","key":"kubernetes.azure.com/scalesetpriority","operator":"Equal","value":"spot"}],"volumeMounts":[{"mountPath":"/tmp/mnt","name":"test"},{"mountPath":"/mnt/session-configmap/rstudio","name":"session-config"},{"mountPath":"/mnt/session-secret/","name":"session-secret"}],"volumes":[{"emptyDir":{},"name":"test"},{"configMap":{"defaultMode":420,"name":"release-name-rstudio-workbench-session"},"name":"session-config"},{"name":"session-secret","secret":{"defaultMode":272,"secretName":"release-name-rstudio-workbench-session-secret"}}]},"service":{"annotations":{"five":"six"},"labels":{},"type":"ClusterIP"}} {{- end }} job.tpl: | # Version: 2.3.1 # DO NOT MODIFY the "Version: " key - # Helm Version: v2 + # Helm Version: v3 {{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }} apiVersion: batch/v1 kind: Job @@ -356,7 +356,7 @@ data: name: {{ get . "secret" }} key: {{ get . "key" }} {{- end }} - {{- if .Values.pod.env }} + {{- if $templateData.pod.env }} {{- toYaml $templateData.pod.env | nindent 12 }} {{- end }} {{- end }} @@ -431,7 +431,7 @@ data: service.tpl: | # Version: 2.3.1 # DO NOT MODIFY the "Version: " key - # Helm Version: v2 + # Helm Version: v3 {{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }} apiVersion: v1 kind: Service @@ -859,7 +859,7 @@ spec: template: metadata: annotations: - checksum/config-general: 55198bf3cd0c9395996d79d9d808358acf5cdc61d77ee8e4d4627d0967794601 + checksum/config-general: 61ebdf4aaea69d39d94c8360f8ef39c65b689bf8c05916942325176c4b6dbbf3 checksum/config-graphite: 9e9249a6820fceccee72ec5c0811fe22cc8a91eabd085164826ff92b3d693b36 checksum/config-prestart: 88c121990a2291900c2e9e4dda1cecda9614a767ee6c6c05068bcadd0f8e97e9 checksum/config-secret: 430b73ff69335b3048f037da394321b8a5f15f7e6415d51cbaab07cf99039fed diff --git a/charts/rstudio-workbench/values.yaml b/charts/rstudio-workbench/values.yaml index 8ec68766..7f9610d6 100644 --- a/charts/rstudio-workbench/values.yaml +++ b/charts/rstudio-workbench/values.yaml @@ -90,6 +90,7 @@ launcher: serviceAccountName: "" volumes: [] volumeMounts: [] + env: [] imagePullPolicy: "" imagePullSecrets: [] initContainers: [] diff --git a/examples/launcher-templates/helm/2.3.1-v3/job.tpl b/examples/launcher-templates/helm/2.3.1-v3/job.tpl new file mode 100644 index 00000000..c8279a75 --- /dev/null +++ b/examples/launcher-templates/helm/2.3.1-v3/job.tpl @@ -0,0 +1,282 @@ +# Version: 2.3.1 +# DO NOT MODIFY the "Version: " key +# Helm Version: v3 +{{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }} +apiVersion: batch/v1 +kind: Job +metadata: + annotations: + {{- with .Job.metadata.job.annotations }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 4 | trimPrefix (repeat 4 " ") }} + {{- end }} + {{- end }} + {{- with $templateData.job.annotations }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 4 | trimPrefix (repeat 4 " ") }} + {{- end }} + {{- end }} + labels: + app.kubernetes.io/managed-by: "launcher" + {{- with .Job.metadata.job.labels }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 4 | trimPrefix (repeat 4 " ") }} + {{- end }} + {{- end }} + {{- with $templateData.job.labels }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 4 | trimPrefix (repeat 4 " ") }} + {{- end }} + {{- end }} + generateName: {{ toYaml .Job.generateName }} +spec: + backoffLimit: 0 + template: + metadata: + annotations: + {{- if .Job.tags }} + {{- $i := 0 }} + {{- range .Job.tags }} + USER_TAG_{{ $i }}: {{ toYaml . | indent 8 | trimPrefix (repeat 8 " ") }} + {{- $i = add $i 1 }} + {{- end }} + {{- end }} + stdin: {{ toYaml .Job.stdin | indent 8 | trimPrefix (repeat 8 " ") }} + user: {{ toYaml .Job.user }} + name: {{ toYaml .Job.name }} + service_ports: {{ toYaml .Job.servicePortsJson }} + {{- if .Job.metadata }} + user_metadata: {{ toJson .Job.metadata | toYaml | indent 8 | trimPrefix (repeat 8 " ") }} + {{- end }} + {{- with .Job.metadata.pod.annotations }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 8 | trimPrefix (repeat 8 " ") }} + {{- end }} + {{- end }} + {{- with $templateData.pod.annotations }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 8 | trimPrefix (repeat 8 " ") }} + {{- end }} + {{- end }} + labels: + {{- with .Job.metadata.pod.labels }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 8 | trimPrefix (repeat 8 " ") }} + {{- end }} + {{- end }} + {{- with $templateData.pod.labels }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 8 | trimPrefix (repeat 8 " ") }} + {{- end }} + {{- end }} + generateName: {{ toYaml .Job.generateName }} + spec: + {{- if .Job.host }} + nodeName: {{ toYaml .Job.host }} + {{- end }} + restartPolicy: Never + {{- if or $templateData.pod.serviceAccountName .Job.serviceAccountName }} + serviceAccountName: {{ .Job.serviceAccountName | default $templateData.pod.serviceAccountName | quote }} + {{- end }} + shareProcessNamespace: {{ .Job.shareProcessNamespace }} + {{- if or (ne (len .Job.volumes) 0) (ne (len $templateData.pod.volumes) 0) }} + volumes: + {{- range .Job.volumes }} + - {{ nindent 10 (toYaml .) | trim -}} + {{- end }} + {{- range $templateData.pod.volumes }} + - {{ nindent 10 (toYaml .) | trim -}} + {{- end }} + {{- end }} + {{- with $templateData.pod.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $templateData.pod.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if or (ne (len .Job.placementConstraints) 0) (ne (len $templateData.pod.nodeSelector) 0) }} + nodeSelector: + {{- range .Job.placementConstraints }} + {{ .name }}: {{ toYaml .value }} + {{- end }} + {{- range $key,$val := $templateData.pod.nodeSelector }} + {{ $key }}: {{- toYaml $val | nindent 10 }} + {{- end }} + {{- end }} + {{- with $templateData.pod.priorityClassName }} + priorityClassName: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- $securityContext := $templateData.pod.defaultSecurityContext }} + {{- if .Job.container.runAsUserId }} + {{- $_ := set $securityContext "runAsUser" .Job.container.runAsUserId }} + {{- end }} + {{- if .Job.container.runAsGroupId }} + {{- $_ := set $securityContext "runAsGroup" .Job.container.runAsGroupId }} + {{- end }} + {{- if .Job.container.supplementalGroupIds }} + {{- $groupIds := list }} + {{- range .Job.container.supplementalGroupIds }} + {{- $groupIds = append $groupIds . }} + {{- end }} + {{- $_ := set $securityContext "supplementalGroups" (cat "[" ($groupIds | join ", ") "]") }} + {{- $securityContext := mergeOverwrite $securityContext $templateData.pod.securityContext }} + {{- end }} + {{- if $securityContext }} + securityContext: + {{- range $key, $val := $securityContext }} + {{ $key }}: {{ $val }} + {{- end }} + {{- end }} + {{- with $templateData.pod.imagePullSecrets }} + imagePullSecrets: {{ toYaml . | nindent 12 }} + {{- end }} + initContainers: + {{- with .Job.metadata.pod.initContainers }} + {{- range . }} + - {{ toYaml . | indent 10 | trimPrefix (repeat 10 " ") }} + {{- end }} + {{- end }} + {{- with $templateData.pod.initContainers }} + {{- range . }} + - {{ toYaml . | indent 10 | trimPrefix (repeat 10 " ") }} + {{- end }} + {{- end }} + containers: + - name: rs-launcher-container + image: {{ toYaml .Job.container.image }} + {{- with $templateData.pod.imagePullPolicy }} + imagePullPolicy: {{- . | nindent 12 }} + {{- end }} + {{- $isShell := false }} + {{- if $templateData.pod.command }} + command: {{- toYaml $templateData.pod.command | nindent 12 }} + {{- if .Job.command }}{{- $isShell = true }}{{- end }} + {{- else if .Job.command }} + command: ['/bin/sh'] + {{- $isShell = true }} + {{- else }} + command: [{{ toYaml .Job.exe }}] + {{- $isShell = false }} + {{- end }} + {{- if .Job.stdin }} + stdin: true + {{- else }} + stdin: false + {{- end }} + stdinOnce: true + {{- if .Job.workingDirectory }} + workingDir: {{ toYaml .Job.workingDirectory }} + {{- end }} + {{- if or (ne (len .Job.args) 0) $isShell }} + args: + {{- if $isShell }} + - '-c' + {{- if ne (len .Job.args) 0 }} + - {{ .Job.args | join " " | cat .Job.command | toYaml | indent 12 | trimPrefix (repeat 12 " ") }} + {{- else }} + - {{ .Job.command | toYaml | indent 12 | trimPrefix (repeat 12 " ") }} + {{- end }} + {{- else }} + {{- range .Job.args }} + - {{ toYaml . | indent 12 | trimPrefix (repeat 12 " ") }} + {{- end }} + {{- end }} + {{- end }} + {{- $secrets := list }} + {{- range .Job.config }} + {{- if eq .name "secret" }} + {{- $packedSecret := .value }} + {{- $secret := dict }} + {{- $_ := set $secret "secret" (splitList ":" $packedSecret | first) }} + {{- $_ := set $secret "key" (slice (splitList ":" $packedSecret) 1 2 | first) }} + {{- $_ := set $secret "name" (splitList ":" $packedSecret | last) }} + {{- $secrets = append $secrets $secret }} + {{- end }} + {{- end }} + {{- if or (ne (len .Job.environment) 0) (ne (len $secrets) 0) (ne (len $templateData.pod.env) 0) }} + env: + {{- range .Job.environment }} + - name: {{ toYaml .name | indent 14 | trimPrefix (repeat 14 " ") }} + value: {{ toYaml .value | indent 14 | trimPrefix (repeat 14 " ") }} + {{- end }} + {{- range $secrets }} + - name: {{ get . "name"}} + valueFrom: + secretKeyRef: + name: {{ get . "secret" }} + key: {{ get . "key" }} + {{- end }} + {{- if $templateData.pod.env }} + {{- toYaml $templateData.pod.env | nindent 12 }} + {{- end }} + {{- end }} + {{- with $templateData.pod.containerSecurityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- $exposedPorts := list }} + {{- range .Job.exposedPorts }} + {{- if .publishedPort }} + {{- $exposedPorts = append $exposedPorts . }} + {{- end }} + {{- end }} + {{- if ne (len $exposedPorts) 0 }} + ports: + {{- range $exposedPorts }} + - containerPort: {{ .targetPort }} + hostPort: {{ .publishedPort }} + {{- end }} + {{- end }} + {{- $limits := dict }} + {{- $requests := dict }} + {{- range .Job.resourceLimits }} + {{- if eq .type "cpuCount" }} + {{- $_ := set $limits "cpu" .value }} + {{- else if eq .type "CPU Request" }} + {{- $_ := set $requests "cpu" .value }} + {{- else if eq .type "memory" }} + {{- $_ := set $limits "memory" (printf "%s%s" .value "M") }} + {{- else if eq .type "Memory Request" }} + {{- $_ := set $requests "memory" (printf "%s%s" .value "M") }} + {{- else if eq .type "NVIDIA GPUs" }} + {{- $val := float64 .value }} + {{- if ne $val 0.0 }} + {{- $_ := set $limits "nvidia.com/gpu" $val }} + {{- end }} + {{- else if eq .type "AMD GPUs" }} + {{- $val := float64 .value }} + {{- if ne $val 0.0 }} + {{- $_ := set $limits "amd.com/gpu" $val }} + {{- end }} + {{- end }} + {{- end }} + {{- if any (ne (len $requests) 0) (ne (len $limits) 0) }} + resources: + {{- if ne (len $requests) 0 }} + requests: + {{- range $key, $val := $requests }} + {{ $key }}: {{ toYaml $val }} + {{- end }} + {{- end }} + {{- if ne (len $limits) 0 }} + limits: + {{- range $key, $val := $limits }} + {{ $key }}: {{ toYaml $val }} + {{- end }} + {{- end }} + {{- end }} + {{- if or (ne (len .Job.volumes) 0) (ne (len $templateData.pod.volumeMounts) 0) }} + volumeMounts: + {{- range .Job.volumeMounts }} + - {{ nindent 14 (toYaml .) | trim -}} + {{- end }} + {{- range $templateData.pod.volumeMounts }} + - {{ nindent 14 (toYaml .) | trim -}} + {{- end }} + {{- end }} + {{- with $templateData.pod.extraContainers }} + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/examples/launcher-templates/helm/2.3.1-v3/service.tpl b/examples/launcher-templates/helm/2.3.1-v3/service.tpl new file mode 100644 index 00000000..f2b506ae --- /dev/null +++ b/examples/launcher-templates/helm/2.3.1-v3/service.tpl @@ -0,0 +1,48 @@ +# Version: 2.3.1 +# DO NOT MODIFY the "Version: " key +# Helm Version: v3 +{{- $templateData := include "rstudio-library.templates.data" nil | mustFromJson }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Job.serviceName }} + annotations: + {{- with .Job.metadata.service.annotations }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 4 | trimPrefix (repeat 4 " ") }} + {{- end }} + {{- end }} + {{- with $templateData.service.annotations }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 4 | trimPrefix (repeat 4 " ") }} + {{- end }} + {{- end }} + labels: + app.kubernetes.io/managed-by: "launcher" + job-name: {{ toYaml .Job.id }} + {{- with .Job.metadata.service.labels }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 8 | trimPrefix (repeat 8 " ") }} + {{- end }} + {{- end }} + {{- with $templateData.service.labels }} + {{- range $key, $val := . }} + {{ $key }}: {{ toYaml $val | indent 8 | trimPrefix (repeat 8 " ") }} + {{- end }} + {{- end }} +spec: + ports: + {{- $i := 0 }} + {{- range .Job.exposedPorts }} + {{- if not .publishedPort }} + - name: {{ printf "port%d" $i }} + protocol: {{ .protocol }} + port: {{ .targetPort }} + targetPort: {{ .targetPort }} + {{- $i = add $i 1 }} + {{- end }} + {{- end }} + selector: + job-name: {{toYaml .Job.id }} + clusterIP: '' + type: {{ $templateData.service.type }}