feat(common): Release v2.3.0 (#228)

Signed-off-by: Christopher Larivière <lariviere.c@gmail.com>
Co-authored-by: Christopher Larivière <lariviere.c@gmail.com>
This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2023-11-20 20:33:30 +01:00 committed by GitHub
parent 8bfc33eb8a
commit 0eac5ba7d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 638 additions and 17 deletions

View file

@ -1 +0,0 @@
../../../../examples/helm/values.yaml

View file

@ -0,0 +1,62 @@
controllers:
main:
strategy: Recreate
containers:
main:
image:
# -- image repository
repository: vaultwarden/server
# -- image tag
# this example is not automatically updated, so be sure to use the latest image
tag: 1.25.2
# -- image pull policy
pullPolicy: IfNotPresent
# -- environment variables.
# See [image docs](https://github.com/dani-garcia/vaultwarden/blob/main/.env.template) for more details.
env:
# -- Config dir
DATA_FOLDER: "config"
# -- Configures service settings for the chart.
service:
main:
ports:
http:
port: 80
websocket:
enabled: true
port: 3012
ingress:
# -- Enable and configure ingress settings for the chart under this key.
main:
enabled: true
hosts:
- host: chart-example.local
paths:
- path: /
pathType: Prefix
service:
name: main
port: http
- path: /notifications/hub/negotiate
pathType: Prefix
service:
name: main
port: http
- path: /notifications/hub
pathType: Prefix
service:
name: main
port: websocket
# -- Configure persistence settings for the chart under this key.
persistence:
config:
enabled: true
type: persistentVolumeClaim
accessMode: ReadWriteOnce
size: 1Gi
mountPath: /config

View file

@ -117,6 +117,11 @@ tests:
set:
controllers.main.containers.main.env:
DYNAMIC_ENV: "{{ .Release.Name }}-admin"
TEMPLATE_ENV:
valueFrom:
secretKeyRef:
name: "{{ .Release.Name }}-secret"
key: "{{ .Release.Name }}-key"
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
@ -127,6 +132,15 @@ tests:
value:
name: DYNAMIC_ENV
value: RELEASE-NAME-admin
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[1]
value:
name: TEMPLATE_ENV
valueFrom:
secretKeyRef:
key: "RELEASE-NAME-key"
name: "RELEASE-NAME-secret"
- it: Combined KeyValue with Explicit ValueFrom should pass
set:

View file

@ -15,3 +15,76 @@ tests:
- documentIndex: *StatefulSetDoc
notExists:
path: spec.volumeClaimTemplates
- it: volumeClaimTemplates should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
size: "10Gi"
accessMode: "ReadWriteOnce"
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
equal:
path: spec.volumeClaimTemplates[0]
value:
metadata:
name: storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
- it: volumeClaimTemplates with dataSource should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
size: "10Gi"
accessMode: "ReadWriteOnce"
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
equal:
path: spec.volumeClaimTemplates[0].spec.dataSource
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
- it: volumeClaimTemplates with templated dataSource name should pass
set:
controllers.main:
type: statefulset
statefulset:
volumeClaimTemplates:
- name: "storage"
size: "10Gi"
accessMode: "ReadWriteOnce"
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: "{{ .Release.Name }}-config"
asserts:
- documentIndex: &StatefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *StatefulSetDoc
equal:
path: spec.volumeClaimTemplates[0].spec.dataSource.name
value: RELEASE-NAME-config

View file

@ -0,0 +1,111 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pvc datasource
templates:
- common.yaml
tests:
- it: default should pass
set:
persistence.config.enabled: true
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSource
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSourceRef
- it: with dataSource should pass
set:
persistence.config:
enabled: true
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.dataSource
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSourceRef
- it: templated dataSource name should pass
set:
persistence.config:
enabled: true
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: "{{ .Release.Name }}-config"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.dataSource
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: RELEASE-NAME-config
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSourceRef
- it: with dataSourceRef should pass
set:
persistence.config:
enabled: true
dataSourceRef:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.dataSourceRef
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: MySnapshot
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSource
- it: templated dataSourceRef name should pass
set:
persistence.config:
enabled: true
dataSourceRef:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: "{{ .Release.Name }}-config"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.dataSourceRef
value:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
name: RELEASE-NAME-config
- documentIndex: *PersistentVolumeClaimDocument
notExists:
path: spec.dataSource

View file

@ -60,7 +60,7 @@ tests:
path: spec.hostnames[0]
value: RELEASE-NAME.local
- it: path matches should only be used for HTTPRoutes
- it: path matches should only be used for HTTPRoutes and GRPCRoutes
set:
route:
main:
@ -77,6 +77,12 @@ tests:
- path:
type: PathPrefix
value: /test
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
grpc:
enabled: true
kind: GRPCRoute
@ -91,6 +97,12 @@ tests:
- path:
type: PathPrefix
value: /test
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
tcp:
enabled: true
kind: TCPRoute
@ -105,6 +117,12 @@ tests:
- path:
type: PathPrefix
value: /test
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
tls:
enabled: true
kind: TLSRoute
@ -119,6 +137,12 @@ tests:
- path:
type: PathPrefix
value: /test
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
udp:
enabled: true
kind: UDPRoute
@ -133,13 +157,32 @@ tests:
- path:
type: PathPrefix
value: /test
filters:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
asserts:
- documentIndex: &HTTPRouteDocument 2
isKind:
of: GRPCRoute
- documentIndex: &HTTPRouteDocument 2
notExists:
equal:
path: spec.rules[0].matches
value:
- path:
type: PathPrefix
value: /test
- documentIndex: &HTTPRouteDocument 2
equal:
path: spec.rules[0].filters
value:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
- documentIndex: &HTTPRouteDocument 3
isKind:
of: HTTPRoute
@ -150,24 +193,42 @@ tests:
- path:
type: PathPrefix
value: /test
- documentIndex: &HTTPRouteDocument 3
equal:
path: spec.rules[0].filters
value:
- type: URLRewrite
urlRewrite:
path:
type: ReplacePrefixMatch
replacePrefixMatch: ""
- documentIndex: &HTTPRouteDocument 4
isKind:
of: TCPRoute
- documentIndex: &HTTPRouteDocument 4
notExists:
path: spec.rules[0].matches
- documentIndex: &HTTPRouteDocument 4
notExists:
path: spec.rules[0].filters
- documentIndex: &HTTPRouteDocument 5
isKind:
of: TLSRoute
- documentIndex: &HTTPRouteDocument 5
notExists:
path: spec.rules[0].matches
- documentIndex: &HTTPRouteDocument 5
notExists:
path: spec.rules[0].filters
- documentIndex: &HTTPRouteDocument 6
isKind:
of: UDPRoute
- documentIndex: &HTTPRouteDocument 6
notExists:
path: spec.rules[0].matches
- documentIndex: &HTTPRouteDocument 6
notExists:
path: spec.rules[0].filters
- it: hostnames shouldn't be used for TCPRoutes and UDPRoutes
set:

View file

@ -66,3 +66,15 @@ tests:
equal:
path: spec.ports[0].protocol
value: TCP
- it: explicit appProtocol should pass
set:
service.main.ports.http.appProtocol: kubernetes.io/h2c
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0].appProtocol
value: kubernetes.io/h2c

View file

@ -3,7 +3,7 @@ apiVersion: v2
name: common
description: Function library for Helm charts
type: library
version: 2.2.0
version: 2.3.0
kubeVersion: ">=1.22.0-0"
keywords:
- common
@ -16,6 +16,19 @@ annotations:
artifacthub.io/changes: |-
- kind: added
description: |-
Add support for dependsOn to initContainers and containers.
Note that using dependsOn completely disables the "order" field within the controller.
The "order" field will be removed in v3.
Add support for `appProtocol` in Kubernetes services.
- kind: added
description: |-
Add support for route filters for HTTPRoute and GRPCRoute.
- kind: added
description: |-
Add support `dataSource` and `dataSourceRef` fields in StatefulSet volumeClaimTemplates.
- kind: added
description: |-
Add support `dataSource` and `dataSourceRef` fields in persistentVolumeClaim persistence items.
- kind: fixed
description: |-
GRPCRoute support for matches was not supported.
- kind: fixed
description: |-
`valuefrom`-style environment variables can now use Helm templating again.

View file

@ -1,6 +1,6 @@
# common
![Version: 2.2.0](https://img.shields.io/badge/Version-2.2.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square)
![Version: 2.3.0](https://img.shields.io/badge/Version-2.3.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square)
Function library for Helm charts
@ -27,7 +27,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml
dependencies:
- name: common
version: 2.2.0
version: 2.3.0
repository: https://bjw-s.github.io/helm-charts/
```
@ -158,6 +158,8 @@ The following table contains an overview of available values and their descripti
| persistence | object | See below | Configure persistence for the chart here. Additional items can be added by adding a dictionary key similar to the 'config' key. [[ref]](https://bjw-s.github.io/helm-charts/docs/common-library/common-library-storage) |
| persistence.config.accessMode | string | `"ReadWriteOnce"` | AccessMode for the persistent volume. Make sure to select an access mode that is supported by your storage provider! [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) |
| persistence.config.advancedMounts | object | `{}` | Explicitly configure mounts for specific controllers and containers. Example: advancedMounts: main: # the controller with the "main" identifier main: # the container with the "main" identifier - path: /data/config.yaml readOnly: true subPath: config.yaml second-container: # the container with the "second-container" identifier - path: /appdata/config readOnly: true second-controller: # the controller with the "second-controller" identifier main: # the container with the "main" identifier - path: /data/config.yaml readOnly: false subPath: config.yaml |
| persistence.config.dataSource | object | `{}` | The optional data source for the persistentVolumeClaim. [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-populators-and-data-sources) |
| persistence.config.dataSourceRef | object | `{}` | The optional volume populator for the persistentVolumeClaim. [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-populators-and-data-sources) |
| persistence.config.enabled | bool | `false` | Enables or disables the persistence item. Defaults to true |
| persistence.config.existingClaim | string | `nil` | If you want to reuse an existing claim, the name of the existing PVC can be passed here. |
| persistence.config.globalMounts | list | `[]` | Configure mounts to all controllers and containers. By default the persistence item will be mounted to `/<name_of_the_peristence_item>`. Example: globalMounts: - path: /config readOnly: false |
@ -173,7 +175,7 @@ The following table contains an overview of available values and their descripti
| route.main.labels | object | `{}` | Provide additional labels which may be required. |
| route.main.nameOverride | string | `nil` | Override the name suffix that is used for this route. |
| route.main.parentRefs | list | `[{"group":"gateway.networking.k8s.io","kind":"Gateway","name":null,"namespace":null,"sectionName":null}]` | Configure the resource the route attaches to. |
| route.main.rules | list | `[{"backendRefs":[{"group":"","kind":"Service","name":"main","namespace":null,"port":null,"weight":1}],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Configure rules for routing. Defaults to the primary service. |
| route.main.rules | list | `[{"backendRefs":[{"group":"","kind":"Service","name":"main","namespace":null,"port":null,"weight":1}],"filters":[],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Configure rules for routing. Defaults to the primary service. |
| route.main.rules[0].backendRefs | list | `[{"group":"","kind":"Service","name":"main","namespace":null,"port":null,"weight":1}]` | Configure backends where matching requests should be sent. |
| secrets | object | See below | Use this to populate secrets with the values you specify. Be aware that these values are not encrypted by default, and could therefore visible to anybody with access to the values.yaml file. Additional Secrets can be added by adding a dictionary key similar to the 'secret' object. |
| secrets.secret.annotations | object | `{}` | Annotations to add to the Secret |
@ -191,6 +193,7 @@ The following table contains an overview of available values and their descripti
| service.main.labels | object | `{}` | Provide additional labels which may be required. |
| service.main.nameOverride | string | `nil` | Override the name suffix that is used for this service |
| service.main.ports | object | See below | Configure the Service port information here. Additional ports can be added by adding a dictionary key similar to the 'http' service. |
| service.main.ports.http.appProtocol | string | `nil` | Specify the appProtocol value for the Service. [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#application-protocol) |
| service.main.ports.http.enabled | bool | `true` | Enables or disables the port |
| service.main.ports.http.nodePort | string | `nil` | Specify the nodePort value for the LoadBalancer and NodePort service types. [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) |
| service.main.ports.http.port | string | `nil` | The port number |

View file

@ -44,4 +44,10 @@ spec:
{{- if $pvcObject.volumeName }}
volumeName: {{ $pvcObject.volumeName | quote }}
{{- end }}
{{- with $pvcObject.dataSource }}
dataSource: {{- tpl (toYaml .) $rootContext | nindent 10 }}
{{- end }}
{{- with $pvcObject.dataSourceRef }}
dataSourceRef: {{- tpl (toYaml .) $rootContext | nindent 10 }}
{{- end }}
{{- end -}}

View file

@ -69,11 +69,15 @@ spec:
port: {{ default .port $servicePrimaryPort.port }}
weight: {{ default 1 .weight }}
{{- end }}
{{- if (eq $routeKind "HTTPRoute") }}
{{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }}
{{- with .matches }}
matches:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .filters }}
filters:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -90,6 +90,9 @@ spec:
{{- if (and (eq $svcType "NodePort") (not (empty $port.nodePort))) }}
nodePort: {{ $port.nodePort }}
{{ end }}
{{- if (not (empty $port.appProtocol)) }}
appProtocol: {{ $port.appProtocol }}
{{ end }}
{{- end -}}
{{- with (merge
($serviceObject.extraSelectorLabels | default dict)

View file

@ -71,7 +71,8 @@ Env field used by the container.
{{- $output = append $output (dict "name" .name "value" .value) -}}
{{- end -}}
{{- else if hasKey . "valueFrom" -}}
{{- $output = append $output (dict "name" .name "valueFrom" .valueFrom) -}}
{{- $parsedValue := (tpl (.valueFrom | toYaml) $rootContext) | fromYaml -}}
{{- $output = append $output (dict "name" .name "valueFrom" $parsedValue) -}}
{{- else -}}
{{- $output = append $output (dict "name" .name "valueFrom" (omit . "name")) -}}
{{- end -}}

View file

@ -22,6 +22,12 @@ spec:
{{- if $values.storageClass }}
storageClassName: {{ if (eq "-" $values.storageClass) }}""{{- else }}{{ $values.storageClass | quote }}{{- end }}
{{- end }}
{{- with $values.dataSource }}
dataSource: {{- tpl (toYaml .) $rootContext | nindent 10 }}
{{- end }}
{{- with $values.dataSourceRef }}
dataSourceRef: {{- tpl (toYaml .) $rootContext | nindent 10 }}
{{- end }}
{{- end -}}
{{/*

View file

@ -163,6 +163,10 @@ controllers:
# annotations: {}
# mountPath: /data
# accessMode: "ReadWriteOnce"
# dataSourceRef:
# apiGroup: snapshot.storage.k8s.io
# kind: VolumeSnapshot
# name: MySnapshot
# size: 1Gi
# - name: backup
# labels: {}
@ -453,6 +457,10 @@ service:
# [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport)
nodePort:
# -- Specify the appProtocol value for the Service.
# [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#application-protocol)
appProtocol:
# -- Configure the ServiceMonitors for the chart here.
# Additional ServiceMonitors can be added by adding a dictionary key similar to the 'main' ServiceMonitors.
# @default -- See below
@ -593,6 +601,8 @@ route:
- path:
type: PathPrefix
value: /
## Request filters that are applied to the rules.
filters: []
# -- Configure persistence for the chart here.
# Additional items can be added by adding a dictionary key similar to the 'config' key.
@ -616,6 +626,14 @@ persistence:
# -- If you want to reuse an existing claim, the name of the existing PVC can be passed here.
existingClaim: # your-claim
# -- The optional data source for the persistentVolumeClaim.
# [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-populators-and-data-sources)
dataSource: {}
# -- The optional volume populator for the persistentVolumeClaim.
# [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-populators-and-data-sources)
dataSourceRef: {}
# -- AccessMode for the persistent volume.
# Make sure to select an access mode that is supported by your storage provider!
# [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes)