Skip to content

Commit

Permalink
Merge pull request #119 from d-m/ingress-networking-v1-api
Browse files Browse the repository at this point in the history
Use `k8s.networking.io/v1` Ingress API on Kubernetes 1.19+
  • Loading branch information
colearendt authored Dec 22, 2021
2 parents 7cae58e + 21330e6 commit a2f8c86
Show file tree
Hide file tree
Showing 31 changed files with 292 additions and 64 deletions.
12 changes: 12 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ update-lock:
docs:
#!/bin/bash
helm-docs --chart-search-root=charts --template-files=README.md.gotmpl --template-files=./_templates.gotmpl
just rbac

rbac:
#!/bin/bash
cd ./charts/rstudio-launcher-rbac && helm dependency update && helm dependency build && cd -
helm template -n rstudio rstudio-launcher-rbac ./charts/rstudio-launcher-rbac --set removeNamespaceReferences=true > examples/rbac/rstudio-launcher-rbac.yaml
CHART_VERSION=$(helm show chart ./charts/rstudio-launcher-rbac | grep '^version' | cut -d ' ' -f 2)
cp examples/rbac/rstudio-launcher-rbac.yaml examples/rbac/rstudio-launcher-rbac-${CHART_VERSION}.yaml

lint:
#!/bin/bash
ct lint ./charts --target-branch main
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.18
digest: sha256:9170e3975a7cdd32ed8dee2aadce77562b3723afcb616d19c40059bbfb9a5c0c
generated: "2021-12-07T08:46:45.926756-05:00"
version: 0.1.19
digest: sha256:3a52152a14dd67c078b2b6b66747e31618aaa97abbe3e8255b59762766bbb463
generated: "2021-12-17T12:28:47.58543-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.15
version: 0.2.16
apiVersion: v2
appVersion: 2021.12.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.18
version: 0.1.19
repository: file://../rstudio-library
annotations:
artifacthub.io/images: |
Expand Down
5 changes: 5 additions & 0 deletions charts/rstudio-connect/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.2.16

- Update `rstudio-library` chart version. This adds a helper for rendering `Ingress` resources
- Create `k8s.networking.io/v1` `Ingress` resource when `ingress.enabled: true` and Kubernetes version is >=1.19 ([#117](https://github.com/rstudio/helm/issues/117))

# 0.2.15

- Bump Connect version to 2021.12.0
Expand Down
7 changes: 4 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.15](https://img.shields.io/badge/Version-0.2.15-informational?style=flat-square) ![AppVersion: 2021.12.0](https://img.shields.io/badge/AppVersion-2021.12.0-informational?style=flat-square)
![Version: 0.2.16](https://img.shields.io/badge/Version-0.2.16-informational?style=flat-square) ![AppVersion: 2021.12.0](https://img.shields.io/badge/AppVersion-2021.12.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.15:
To install the chart with the release name `my-release` at version 0.2.16:

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

## Required Configuration
Expand Down Expand Up @@ -77,6 +77,7 @@ The Helm `config` values are converted into the `rstudio-connect.gcfg` service c
| ingress.annotations | object | `{}` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts | string | `nil` | |
| ingress.ingressClassName | string | `""` | The ingressClassName for the ingress resource. Only used for clusters that support networking.k8s.io/v1 Ingress resources |
| ingress.tls | list | `[]` | |
| initContainers | bool | `false` | The initContainer spec that will be used verbatim |
| launcher.contentInitContainer | object | `{"repository":"ghcr.io/rstudio/rstudio-connect-content-init","tag":""}` | Image definition for the RStudio Connect Content InitContainer |
Expand Down
11 changes: 11 additions & 0 deletions charts/rstudio-connect/ci/complex-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ pod:
image: "busybox"
imagePullPolicy: "IfNotPresent"

ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: traefik

# Defines network routing in the traefik configuration.
hosts:
- host: connect.rstudio.com
paths:
- /

initContainers:
- name: example-init
image: busybox
Expand Down
16 changes: 9 additions & 7 deletions charts/rstudio-connect/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{{- if .Values.ingress.enabled -}}
{{- $apiVersion := include "rstudio-library.ingress.apiVersion" . -}}
{{- $fullName := include "rstudio-connect.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand All @@ -16,6 +13,9 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and (.Values.ingress.ingressClassName) (include "rstudio-library.ingress.supportsIngressClassName" $apiVersion) }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
Expand All @@ -33,9 +33,11 @@ spec:
paths:
{{- range .paths }}
- path: {{ . }}
{{- if include "rstudio-library.ingress.supportsPathType" $apiVersion }}
pathType: Prefix
{{- end }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- include "rstudio-library.ingress.backend" (dict "apiVersion" $apiVersion "svcName" $fullName "svcPort" $svcPort) | nindent 14 }}
{{- end }}
{{- end }}
{{- end }}
5 changes: 3 additions & 2 deletions charts/rstudio-connect/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ pod:
# -- An array of containers that will be run alongside the main pod
sidecar: false


# -- The pod's run command. By default, it uses the container's default
command: []
# -- The pod's run arguments. By default, it uses the container's default
Expand Down Expand Up @@ -168,6 +167,9 @@ initContainers: false

ingress:
enabled: false
# -- The ingressClassName for the ingress resource. Only used for clusters that support
# networking.k8s.io/v1 Ingress resources
ingressClassName: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
Expand All @@ -179,7 +181,6 @@ ingress:
# hosts:
# - chart-example.local


launcher:
# -- Whether to enable the launcher
enabled: false
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.18
digest: sha256:9170e3975a7cdd32ed8dee2aadce77562b3723afcb616d19c40059bbfb9a5c0c
generated: "2021-12-07T08:46:52.08596-05:00"
version: 0.1.19
digest: sha256:3a52152a14dd67c078b2b6b66747e31618aaa97abbe3e8255b59762766bbb463
generated: "2021-12-22T09:57:49.943264-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.8
appVersion: 0.2.8
version: 0.2.9
appVersion: 0.2.9
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.18
version: 0.1.19
repository: file://../rstudio-library
keywords:
- "data science"
Expand Down
4 changes: 4 additions & 0 deletions charts/rstudio-launcher-rbac/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.2.9

- Update `rstudio-library` chart dependency

# 0.2.8

- Update `rstudio-library` chart dependency
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.8](https://img.shields.io/badge/Version-0.2.8-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.8](https://img.shields.io/badge/AppVersion-0.2.8-informational?style=flat-square)
![Version: 0.2.9](https://img.shields.io/badge/Version-0.2.9-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.9](https://img.shields.io/badge/AppVersion-0.2.9-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.8:
To install the chart with the release name `my-release` at version 0.2.9:

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

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

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

- Add an `Ingress` helper
- Provides template for rendering `Ingress` `apiVersion` based on
Kubernetes version
- Provides template for rendering `Ingress` `backend` based on
`apiVersion`
- Provides template for determining if `Ingress` `apiVersion` supports
the `ingressClassName` field
- Provides template for determining if `Ingress` `apiVersion` supports
the `pathType` field

# 0.1.18

- Add newlines between array entries for `config.dcf` generation ([#108](https://github.com/rstudio/helm/issues/108))
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.18](https://img.shields.io/badge/Version-0.1.18-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.18](https://img.shields.io/badge/AppVersion-0.1.18-informational?style=flat-square)
![Version: 0.1.19](https://img.shields.io/badge/Version-0.1.19-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.19](https://img.shields.io/badge/AppVersion-0.1.19-informational?style=flat-square)

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

Expand Down
61 changes: 61 additions & 0 deletions charts/rstudio-library/templates/_ingress.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- /*
Determine and return the Ingress API version
*/ -}}
{{- define "rstudio-library.ingress.apiVersion" -}}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion }}
networking.k8s.io/v1beta1
{{- else -}}
extensions/v1beta1
{{- end -}}
{{- end -}}{{- /* end define template */ -}}

{{- /*
Define the backend for an Ingress path
Takes a dict:
"apiVersion": "the API version for the Ingress resource"
"svcName": "the target service name"
"svcPort": "The target service port"
*/ -}}
{{- define "rstudio-library.ingress.backend" -}}
{{- if or (eq .apiVersion "extensions/v1beta1") (eq .apiVersion "networking.k8s.io/v1beta1") -}}
serviceName: {{ .svcName }}
servicePort: {{ .svcPort }}
{{- else -}}
service:
name: {{ .svcName }}
port:
{{- if typeIs "string" .svcPort }}
name: {{ .svcPort }}
{{- else if or (typeIs "int" .svcPort) (typeIs "float64" .svcPort) }}
number: {{ .svcPort | int }}
{{- end }}
{{- end -}}
{{- end -}}{{- /* end define template */ -}}

{{- /*
Return true if the apiVersion supports ingressClassName and false otherwise
Takes an Ingress API version:
"the API version for the Ingress resource"
*/ -}}
{{- define "rstudio-library.ingress.supportsIngressClassName" -}}
{{- if or (eq . "extensions/v1beta1") (eq . "networking.k8s.io/v1beta1") -}}
false
{{- else -}}
true
{{- end -}}
{{- end -}}{{- /* end define template */ -}}

{{- /*
Return true if the apiVersion supports pathType and false otherwise
Takes an Ingress API version:
"the API version for the Ingress resource"
*/ -}}
{{- define "rstudio-library.ingress.supportsPathType" -}}
{{- if or (eq . "extensions/v1beta1") (eq . "networking.k8s.io/v1beta1") -}}
false
{{- else -}}
true
{{- end -}}
{{- end -}}{{- /* end define template */ -}}
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.18
digest: sha256:9170e3975a7cdd32ed8dee2aadce77562b3723afcb616d19c40059bbfb9a5c0c
generated: "2021-12-07T08:46:58.937118-05:00"
version: 0.1.19
digest: sha256:3a52152a14dd67c078b2b6b66747e31618aaa97abbe3e8255b59762766bbb463
generated: "2021-12-17T12:30:43.992325-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.2.9
version: 0.2.10
apiVersion: v2
appVersion: 2021.09.0-1
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.18
version: 0.1.19
repository: file://../rstudio-library
annotations:
artifacthub.io/images: |
Expand Down
5 changes: 5 additions & 0 deletions charts/rstudio-pm/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.2.10

- Update `rstudio-library` chart version. This adds a helper for rendering `Ingress` resources
- Create `k8s.networking.io/v1` `Ingress` resource when `ingress.enabled: true` and Kubernetes version is >=1.19 ([#117](https://github.com/rstudio/helm/issues/117))

# 0.2.9

- Add `serviceMonitor` values for use with a Prometheus Operator
Expand Down
7 changes: 4 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.2.9](https://img.shields.io/badge/Version-0.2.9-informational?style=flat-square) ![AppVersion: 2021.09.0-1](https://img.shields.io/badge/AppVersion-2021.09.0--1-informational?style=flat-square)
![Version: 0.2.10](https://img.shields.io/badge/Version-0.2.10-informational?style=flat-square) ![AppVersion: 2021.09.0-1](https://img.shields.io/badge/AppVersion-2021.09.0--1-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.2.9:
To install the chart with the release name `my-release` at version 0.2.10:

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

## Required Configuration
Expand Down Expand Up @@ -96,6 +96,7 @@ The Helm `config` values are converted into the `rstudio-pm.gcfg` service config
| ingress.annotations | object | `{}` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts | string | `nil` | |
| ingress.ingressClassName | string | `""` | The ingressClassName for the ingress resource. Only used for clusters that support networking.k8s.io/v1 Ingress resources |
| ingress.tls | list | `[]` | |
| initContainers | bool | `false` | the initContainer spec that will be used verbatim |
| 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 |
Expand Down
Loading

0 comments on commit a2f8c86

Please sign in to comment.