Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ charts
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

__snapshot__
2 changes: 2 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
.idea/
*.tmprojt
tests/

__snapshot__/
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ The following table lists the configurable parameters of the Concourse chart and
| `web.ingress.ingressClassName` | IngressClass to register to | `nil` |
| `web.ingress.rulesOverride` | Concourse Web Ingress rules (override) (alternate to `web.ingress.hosts`) | `[]` |
| `web.ingress.tls` | Concourse Web Ingress TLS configuration | `[]` |
| `web.route.annotations` | Concourse Web HTTPRoute annotations | `{}` |
| `web.route.enabled` | Enable Concourse Web HTTPRoute | `false` |
| `web.route.hostnames` | Concourse Web HTTPRoutes Hostnames | `[]` |
| `web.route.parentRefs` | Concourse Web HTTPRoute parentRefs (gateways) | `[]` |
| `web.route.labels` | Concourse Web HTTPRoute labels | `[]` |
| `web.keySecretsPath` | Specify the mount directory of the web keys secrets | `/concourse-keys` |
| `web.labels`| Additional labels to be added to the web deployment `metadata.labels` | `{}` |
| `web.deploymentAnnotations` | Additional annotations to be added to the web deployment `metadata.annotations` | `{}` |
Expand Down Expand Up @@ -768,3 +773,25 @@ Instead, you may add a comment specifying the default, such as
This prevents the behaviour drifting from that of the binary in case the binary's default values change.

We understand that the comment stating the binary's default can become stale. The current solution is a suboptimal one. It may be improved in the future by generating a list of the default values from the binary.

## Helm Unit Test

When running unit tests for helm, from the root of the repository, you can simply run the following.

```bash
helm unittest -f test/unittest/**/*.yaml .
```

If you are debugging specific tests, simply target the folder or yaml file you want to run tests on.

`Folder`

```bash
helm unittest -f test/unittest/gateway-apis/*.yaml .
```

`Specific Test Suite`

```bash
helm unittest -f test/unittest/gateway-apis/web-route-test.yaml .
```
42 changes: 42 additions & 0 deletions templates/web-route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- if .Values.web.enabled -}}
{{- if .Values.web.route.enabled -}}
{{- $route := .Values.web.route -}}
{{- $releaseName := .Release.Name -}}
{{- $serviceName := include "concourse.web.fullname" . -}}
{{- $servicePort := .Values.concourse.web.bindPort -}}
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: {{ template "concourse.web.fullname" . }}
labels:
app: {{ template "concourse.web.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- with $route.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $route.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and $route.parentRefs (gt (len $route.parentRefs) 0) }}
parentRefs:
{{- toYaml $route.parentRefs | nindent 2 }}
{{- end }}
{{- if and $route.hostnames (gt (len $route.hostnames) 0) }}
hostnames:
{{- toYaml $route.hostnames | nindent 2 }}
{{- end }}
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: {{ $serviceName }}
port: {{ $servicePort }}
namespace: {{ .Release.Namespace | quote }}
{{- end -}}
{{- end -}}
151 changes: 151 additions & 0 deletions test/unittest/gateway-apis/web-route-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
suite: GatewayApis

tests:
- it: Route Disabled
set:
web:
route:
enabled: false
template: web-route.yaml
asserts:
- hasDocuments:
count: 0

- it: Route Exposure
set:
web:
route:
enabled: true
parentRefs:
- name: test-parent
namespace: test-namespace
group: gateway.networking.k8s.io
sectionName: test-section
kind: Gateway
hostnames:
- concourse.example.com
template: web-route.yaml
asserts:
- equal:
path: spec.hostnames[0]
value: concourse.example.com
- equal:
path: spec.parentRefs[0].name
value: test-parent
- equal:
path: spec.parentRefs[0].namespace
value: test-namespace
- equal:
path: spec.parentRefs[0].group
value: gateway.networking.k8s.io
- equal:
path: spec.parentRefs[0].sectionName
value: test-section
- equal:
path: spec.parentRefs[0].kind
value: Gateway

- it: Route Extra Annotations
set:
web:
route:
enabled: true
annotations:
test.annotation: test-annotation
parentRefs:
- name: test-parent
namespace: test-namespace
hostnames:
- concourse.example.com
template: templates/web-route.yaml
asserts:
- equal:
path: metadata.annotations["test.annotation"]
value: test-annotation

- it: Route Extra Labels
set:
web:
route:
enabled: true
labels:
test.label: test-label
parentRefs:
- name: test-parent
namespace: test-namespace
hostnames:
- concourse.example.com
template: web-route.yaml
asserts:
- equal:
path: metadata.labels["test.label"]
value: test-label

- it: Route Service Exposure
set:
web:
route:
enabled: true
parentRefs:
- name: test-parent
namespace: test-namespace
hostnames:
- concourse.example.com
template: web-route.yaml
asserts:
- equal:
path: spec.rules[0].backendRefs[0].name
value: RELEASE-NAME-web
- equal:
path: spec.rules[0].matches[0].path.value
value: /
- equal:
path: spec.rules[0].backendRefs[0].port
value: 8080

- it: Multiple Hostnames
set:
web:
route:
enabled: true
parentRefs:
- name: test-parent
namespace: test-namespace
hostnames:
- concourse.example.com
- concourse.alternate.com
template: web-route.yaml
asserts:
- equal:
path: spec.hostnames[0]
value: concourse.example.com
- equal:
path: spec.hostnames[1]
value: concourse.alternate.com
- lengthEqual:
path: spec.hostnames
count: 2

- it: Multiple ParentRefs
set:
web:
route:
enabled: true
parentRefs:
- name: test-parent-1
namespace: test-namespace-1
- name: test-parent-2
namespace: test-namespace-2
hostnames:
- concourse.example.com
template: web-route.yaml
asserts:
- equal:
path: spec.parentRefs[0].name
value: test-parent-1
- equal:
path: spec.parentRefs[1].name
value: test-parent-2
- lengthEqual:
path: spec.parentRefs
count: 2
35 changes: 35 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2441,6 +2441,41 @@ web:
##
tls:

## Route configuration
## Ref: https://gateway-api.sigs.k8s.io/api-types/httproute/
##
route:

## Enable HTTPRoutes
##
enabled: false

## Label to be added to the web route.
## Example:
## my.label: my-label-value
##
labels: {}

## Annotations to be added to the web route.
## Example:
## my.annotation: my-annotation-value
##
annotations: {}

## Gateway API Parent Refs
## Example
## - name: envoy
## namespace: networking
## sectionName: https
## group: gateway.networking.k8s.io
## kind: Gateway
parentRefs: []

## Hosts to attach to the HTTPRoute
## Example:
## - "concourse.example.com"
hostnames: []

## Configuration values for Concourse Worker components.
## For more information regarding the characteristics of
## Concourse Workers, see https://concourse-ci.org/concourse-worker.html
Expand Down