Skip to content

Commit

Permalink
Merge pull request #154 from rstudio/add-other-charts
Browse files Browse the repository at this point in the history
Add other charts
  • Loading branch information
colearendt authored Feb 18, 2022
2 parents 5cc6181 + 093d0dc commit 9319511
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 11 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/chart-doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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 "[email protected]"
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 }}

Expand All @@ -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 }}

Expand All @@ -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 }}
8 changes: 8 additions & 0 deletions .github/workflows/chart-releaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
charts_dir: other-charts
charts_repo_url: https://helm.rstudio.com
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
12 changes: 6 additions & 6 deletions .github/workflows/chart-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down
97 changes: 97 additions & 0 deletions other-charts/_templates.gotmpl
Original file line number Diff line number Diff line change
@@ -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 }}
*/ -}}
31 changes: 31 additions & 0 deletions other-charts/prepull-daemonset/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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: [email protected]
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"
8 changes: 8 additions & 0 deletions other-charts/prepull-daemonset/NEWS.md
Original file line number Diff line number Diff line change
@@ -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
58 changes: 58 additions & 0 deletions other-charts/prepull-daemonset/README.md
Original file line number Diff line number Diff line change
@@ -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<sup>†</sup> 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
```

> <sup>†</sup> 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)

42 changes: 42 additions & 0 deletions other-charts/prepull-daemonset/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -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<sup>†</sup> 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
```

> <sup>†</sup> 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" . }}
34 changes: 34 additions & 0 deletions other-charts/prepull-daemonset/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 9319511

Please sign in to comment.