diff --git a/.github/workflows/chart-doc.yaml b/.github/workflows/chart-doc.yaml index d07d4c60..83c5c63d 100644 --- a/.github/workflows/chart-doc.yaml +++ b/.github/workflows/chart-doc.yaml @@ -11,7 +11,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - uses: r-lib/actions/pr-fetch@master + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -32,15 +32,16 @@ jobs: - name: Run helm-docs run: | ./helm-docs --chart-search-root=charts --template-files=README.md.gotmpl --template-files=./_templates.gotmpl + ./helm-docs --chart-search-root=other-charts --template-files=README.md.gotmpl --template-files=./_templates.gotmpl - name: Commit results run: | set -xe git config --local user.email "actions@github.com" git config --local user.name "GitHub Actions" - git commit charts/*/README.md -m 'Update helm-docs and README.md' || echo "No changes to commit" + git commit other-charts/*/README.md charts/*/README.md -m 'Update helm-docs and README.md' || echo "No changes to commit" - - uses: r-lib/actions/pr-push@master + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -52,7 +53,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - uses: r-lib/actions/pr-fetch@master + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -77,6 +78,6 @@ jobs: git add examples/rbac/rstudio-launcher-rbac*.yaml || echo "No files to add" git commit examples/rbac/rstudio-launcher-rbac*.yaml -m 'Update rbac yaml' || echo "No changes to commit" - - uses: r-lib/actions/pr-push@master + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/chart-releaser.yaml b/.github/workflows/chart-releaser.yaml index 1fd04116..bc696520 100644 --- a/.github/workflows/chart-releaser.yaml +++ b/.github/workflows/chart-releaser.yaml @@ -30,3 +30,11 @@ jobs: charts_repo_url: https://helm.rstudio.com env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Run chart-releaser (other) + uses: helm/chart-releaser-action@v1.2.0 + with: + charts_dir: other-charts + charts_repo_url: https://helm.rstudio.com + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/chart-test.yaml b/.github/workflows/chart-test.yaml index bfff61fc..a70c1eb0 100644 --- a/.github/workflows/chart-test.yaml +++ b/.github/workflows/chart-test.yaml @@ -30,16 +30,16 @@ jobs: - name: Run chart-testing (list-changed) id: list-changed run: | - changed=$(ct list-changed --target-branch main) + changed=$(ct list-changed --target-branch main --chart-dirs charts --chart-dirs other-charts) if [[ -n "$changed" ]]; then echo "::set-output name=changed::true" fi - name: Run chart-testing (lint changed) - run: ct lint --target-branch main + run: ct lint --target-branch main --chart-dirs charts --chart-dirs other-charts - name: Run chart-testing (lint all) - run: ct lint --target-branch main --all + run: ct lint --target-branch main --all --chart-dirs charts --chart-dirs other-charts install: runs-on: ubuntu-latest @@ -64,7 +64,7 @@ jobs: - name: Run chart-testing (list-changed) id: list-changed run: | - changed=$(ct list-changed --target-branch main) + changed=$(ct list-changed --target-branch main --chart-dirs charts --chart-dirs other-charts) if [[ -n "$changed" ]]; then echo "::set-output name=changed::true" fi @@ -76,11 +76,11 @@ jobs: # no allow-failure until https://github.com/actions/toolkit/issues/399 - name: Run chart-testing (install changed) if: ${{ github.ref != 'refs/heads/main' }} - run: ct install --target-branch main + run: ct install --target-branch main --chart-dirs charts --chart-dirs other-charts continue-on-error: true # no allow-failure until https://github.com/actions/toolkit/issues/399 - name: Run chart-testing (install all) if: ${{ github.ref == 'refs/heads/main' }} - run: ct install --target-branch main --all + run: ct install --target-branch main --all --chart-dirs charts --chart-dirs other-charts continue-on-error: true diff --git a/Justfile b/Justfile index cc15622c..7fe7b983 100644 --- a/Justfile +++ b/Justfile @@ -14,6 +14,7 @@ all-docs: docs: #!/bin/bash helm-docs --chart-search-root=charts --template-files=README.md.gotmpl --template-files=./_templates.gotmpl + helm-docs --chart-search-root=other-charts --template-files=README.md.gotmpl --template-files=./_templates.gotmpl rbac: #!/bin/bash diff --git a/README.md b/README.md index 4b1dba8e..b14b3dfc 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,15 @@ Examples: - [RStudio Connect](./examples/connect/) - [Standalone RBAC for the Job Launcher](./examples/rbac) +### Other Charts + +Supporting and miscellaneous charts with varying levels of maintenance, usefulness, and support + +- [Library Chart](./charts/rstudio-library) + - Supporting tools for building helm charts +- [Pre-pull Daemonset](./other-charts/prepull-daemonset) + - Chart for deploying a daemonset that pulls container images to nodes + ## Support **IMPORTANT:** diff --git a/other-charts/_templates.gotmpl b/other-charts/_templates.gotmpl new file mode 100644 index 00000000..22e0fef2 --- /dev/null +++ b/other-charts/_templates.gotmpl @@ -0,0 +1,97 @@ +{{- define "rstudio.blurb" }} + {{- if eq .Name "rstudio-connect" -}} +Business Users and Collaborators use R and Python data products on [RStudio Connect](https://www.rstudio.com/products/connect/) +that are published by Data Scientists. + {{- else if eq .Name "rstudio-pm" -}} +IT Administrators use [RStudio Package Manager](https://www.rstudio.com/products/package-manager/) to control and manage +R and Python packages that Data Scientists need to create and share data products. + {{- else if eq .Name "rstudio-workbench" -}} +Data Scientists use [RStudio Workbench](https://www.rstudio.com/products/workbench/) to analyze data and create data +products using R and Python. + {{- end -}} +{{- end }} + +{{- define "rstudio.description" }} + {{- print "#### _" }}{{- template "chart.description" . }}_ + {{- print "" | nindent 0 }} + {{- print "" | nindent 0 }} + {{- template "rstudio.blurb" . }} +{{- end }} + +{{- define "rstudio.header" }} + {{- if eq .Name "rstudio-connect" -}} +# RStudio Connect + {{- else if eq .Name "rstudio-pm" -}} +# RStudio Package Manager + {{- else if eq .Name "rstudio-workbench" -}} +# RStudio Workbench + {{- else -}} +{{ template "chart.header" . }} + {{- end }} +{{ print "" | nindent 0 }} +{{- end }} + + +{{- define "rstudio.disclaimer" }} + +## Disclaimer + +> This chart is "beta" quality. It will likely undergo +> breaking changes without warning as it moves towards stability. + +As a result, please: +* Ensure you "pin" the version of the Helm chart that you are using. You can do + this using the `helm dependency` command and the associated "Chart.lock" files + or the `--version` flag. IMPORTANT: This protects you from breaking changes +* Before upgrading, to avoid breaking changes, use `helm diff upgrade` to check + for breaking changes +* Pay close attention to [`NEWS.md`](./NEWS.md) for updates on breaking + changes, as well as documentation below on how to use the chart + +{{- end }} + +{{- define "rstudio.install" }} + +## Installing the Chart + +To install the chart with the release name `my-release` at version {{ template "chart.version" . }}: + +```bash +helm repo add rstudio https://helm.rstudio.com +helm install {{- if (regexMatch "[0-9]+\\.[0-9]+\\.[0-9]+-[a-zA-Z\\.0-9]+" .Version) }} --devel{{ end }} my-release rstudio/{{ template "chart.name" . }} --version={{ template "chart.version" . }} +``` + +{{- end }} + +{{ define "rstudio.examples1" -}} + {{ . }} + {{ kindOf . }} + {{ typeOf . }} + {{ typeOf .Values }} + {{ .ChartDirectory }} + + {{ toPrettyJson . }} + # Examples +{{- end }} + +{{ define "rstudio.examples" -}} +{{ . }} +{{ kindOf . }} +{{ typeOf . }} +{{ typeOf .Values }} +{{ .ChartDirectory }} + +{{ toPrettyJson . }} +# Examples +{{- end }} + +{{- /* +Interesting example that does not work... but I fought hard for... for some reason: + + {{ $currentScope := . }} + {{ range $path, $_ := $.Files.Glob "{{ .ChartDirectory }}/ci/*.yaml" }} + {{- with $currentScope }} + {{ $.Files.Get $path }} + {{- end }} + {{ end }} +*/ -}} diff --git a/other-charts/prepull-daemonset/Chart.yaml b/other-charts/prepull-daemonset/Chart.yaml new file mode 100644 index 00000000..746cfc1e --- /dev/null +++ b/other-charts/prepull-daemonset/Chart.yaml @@ -0,0 +1,31 @@ +name: prepull-daemonset +description: a daemonset to prepull images so they are cached +version: 0.0.2 +apiVersion: v2 +icon: https://rstudio.com/wp-content/uploads/2018/10/RStudio-Logo-Flat.png +home: https://www.rstudio.com +sources: + - https://github.com/rstudio/helm +maintainers: + - name: sol-eng + email: docker@rstudio.com + url: https://github.com/sol-eng +annotations: + artifacthub.io/images: | + - name: ubuntu + image: ubuntu:bionic + - name: pause + image: gcr.io/google_containers/pause + artifacthub.io/license: MIT + artifacthub.io/links: | + - name: Docker Images + url: https://github.com/rstudio/rstudio-docker-products + - name: RStudio Community + url: https://community.rstudio.com/c/r-admin/5 +keywords: + - "prepull" + - "bootstrap" + - "image-cache" + - "auto-scaling" + - "startup" + - "container" diff --git a/other-charts/prepull-daemonset/NEWS.md b/other-charts/prepull-daemonset/NEWS.md new file mode 100644 index 00000000..34082724 --- /dev/null +++ b/other-charts/prepull-daemonset/NEWS.md @@ -0,0 +1,8 @@ +# 0.0.2 + +- Add optional randomization to redeploy the daemonset on each deployment +- Add values to configure the updateStrategy + +# 0.0.1 + +- Initial release diff --git a/other-charts/prepull-daemonset/README.md b/other-charts/prepull-daemonset/README.md new file mode 100644 index 00000000..c898f5e5 --- /dev/null +++ b/other-charts/prepull-daemonset/README.md @@ -0,0 +1,58 @@ +# prepull-daemonset + +![Version: 0.0.2](https://img.shields.io/badge/Version-0.0.2-informational?style=flat-square) + +#### _a daemonset to prepull images so they are cached_ + +## Installing the Chart + +To install the chart with the release name `my-release` at version 0.0.2: + +```bash +helm repo add rstudio https://helm.rstudio.com +helm install my-release rstudio/prepull-daemonset --version=0.0.2 +``` + +## Use + +Create a `values.yaml` file somewhere that lists the images you'd like to be pre-pulled (use the `values.yaml` file in this repo for format): + +``` +images: + - name: my-first-image + image: some-id.dkr.ecr.us-east-1.amazonaws.com/my-ecr-repo:latest + - name: my-second-image + image: some-id.dkr.ecr.us-east-1.amazonaws.com/my-other-repo:latest + - name: my-third-public-image + image: ubuntu:bionic +``` + +## Pull Again + +To run the pre-pull again (i.e. to pull new images with the same tag, to ensure node +caches are fresh), there are a few options: + +``` +# by default, every upgrade is randomized / does a rollout (`--set randomize=false` to disable this behavior) +helm upgrade install prepull-daemonset rstudio/prepull-daemonset + +# or use kubectl +kubectl rollout restart daemonset/prepull-daemonset +``` + +> Kubernetes Nodes (specifically, the `kubelet` service) periodically remove images from +> the node's cache to free up disk space, especially if an image is not in use and has +> not been used lately + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| images[0].image | string | `"ubuntu:bionic"` | | +| images[0].name | string | `"ubuntu-bionic"` | | +| randomize | bool | `true` | | +| updateStrategy | object | `{}` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) + diff --git a/other-charts/prepull-daemonset/README.md.gotmpl b/other-charts/prepull-daemonset/README.md.gotmpl new file mode 100644 index 00000000..9191d4c2 --- /dev/null +++ b/other-charts/prepull-daemonset/README.md.gotmpl @@ -0,0 +1,42 @@ +{{ template "rstudio.header" . }} + +{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} + +{{ template "rstudio.description" . }} + +{{ template "rstudio.install" . }} + +## Use + +Create a `values.yaml` file somewhere that lists the images you'd like to be pre-pulled (use the `values.yaml` file in this repo for format): + +``` +images: + - name: my-first-image + image: some-id.dkr.ecr.us-east-1.amazonaws.com/my-ecr-repo:latest + - name: my-second-image + image: some-id.dkr.ecr.us-east-1.amazonaws.com/my-other-repo:latest + - name: my-third-public-image + image: ubuntu:bionic +``` + +## Pull Again + +To run the pre-pull again (i.e. to pull new images with the same tag, to ensure node +caches are fresh), there are a few options: + +``` +# by default, every upgrade is randomized / does a rollout (`--set randomize=false` to disable this behavior) +helm upgrade install prepull-daemonset rstudio/prepull-daemonset + +# or use kubectl +kubectl rollout restart daemonset/prepull-daemonset +``` + +> Kubernetes Nodes (specifically, the `kubelet` service) periodically remove images from +> the node's cache to free up disk space, especially if an image is not in use and has +> not been used lately + +{{ template "chart.valuesSection" . }} + +{{ template "helm-docs.versionFooter" . }} diff --git a/other-charts/prepull-daemonset/templates/daemonset.yaml b/other-charts/prepull-daemonset/templates/daemonset.yaml new file mode 100644 index 00000000..487786fe --- /dev/null +++ b/other-charts/prepull-daemonset/templates/daemonset.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: {{ .Chart.Name | trunc 63 | trimSuffix "-" }} + labels: + app: {{ .Chart.Name | trunc 63 | trimSuffix "-" }} +spec: + selector: + matchLabels: + name: {{ .Chart.Name | trunc 63 | trimSuffix "-" }} + {{- with .Values.updateStrategy }} + updateStrategy: + {{- toYaml . | nindent 4 }} + {{- end }} + template: + metadata: + annotations: + {{- if .Values.randomize }} + rollme: {{ randAlphaNum 10 | quote }} + {{- end }} + labels: + name: {{ .Chart.Name | trunc 63 | trimSuffix "-" }} + spec: + initContainers: + {{- range .Values.images }} + - name: prepull-{{ .name }} + image: {{ .image }} + imagePullPolicy: Always + command: ["echo"] + args: ["Finished pre-pull"] + {{- end }} + containers: + - name: pause + image: gcr.io/google_containers/pause diff --git a/other-charts/prepull-daemonset/values.yaml b/other-charts/prepull-daemonset/values.yaml new file mode 100644 index 00000000..3f5a558b --- /dev/null +++ b/other-charts/prepull-daemonset/values.yaml @@ -0,0 +1,7 @@ +images: + - name: ubuntu-bionic + image: ubuntu:bionic + +updateStrategy: {} + +randomize: true