feat(common): Release version 1.2.0 (#92)

* fix(common): fix incorrect route default values (#91)
* fix(common): make `sectionName` optional for route parentRefs
* fix(common): name primary route correctly
* feat(common): add controller.type of cronjob (#87)
* fix(common): Fix invalid persistence type message (#85)
* feat(common): Allow setting container restartPolicy

Co-authored-by: András Maróy <andras@maroy.hu>
Co-authored-by: loeken <loeken@internetz.me>
Co-authored-by: Han Cen <hi@chamburr.com>
This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2022-12-05 14:36:41 +01:00 committed by GitHub
parent 8f2a1ba9b4
commit 72670526a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 351 additions and 66 deletions

View file

@ -3,7 +3,7 @@ apiVersion: v2
name: common
description: Function library for Helm charts
type: library
version: 1.1.3
version: 1.2.0
kubeVersion: ">=1.22.0-0"
keywords:
- common
@ -15,24 +15,12 @@ maintainers:
annotations:
artifacthub.io/changes: |-
- kind: fixed
description: Fixed code-server add-on Service rendering
description: Fixed sectionName not being optional for gateway routes
- kind: fixed
description: Fixed httpGet probe whitespace rendering
description: Fixed primary gateway route having incorrect name
- kind: fixed
description: Fixed serviceAccount definition to be compatible with k8s 1.25
links:
- name: Secret management for ServiceAccounts
url: https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#manual-secret-management-for-serviceaccounts
description: Fixed invalid persistence type message
- kind: added
description: Added support for Gateway API Routes
links:
- name: Gateway API docs
url: https://gateway-api.sigs.k8s.io
- kind: changed
description: Services and their ports are now assumed enabled by default
- kind: changed
description: Updated netshoot image to v0.8
- kind: changed
description: Updated code-server image to v4.8.3
- kind: removed
description: Removed promtail add-on
description: Added cronjob as controller.type
- kind: added
description: Allow setting container restartPolicy

View file

@ -1,6 +1,6 @@
# common
![Version: 1.1.1](https://img.shields.io/badge/Version-1.1.1-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square)
![Version: 1.2.0](https://img.shields.io/badge/Version-1.2.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square)
Function library for Helm charts
@ -29,7 +29,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml
dependencies:
- name: common
version: 1.1.1
version: 1.2.0
repository: https://bjw-s.github.io/helm-charts/
```
@ -101,17 +101,24 @@ N/A
| configMaps.config.data | object | `{}` | configMap data content. Helm template enabled. |
| configMaps.config.enabled | bool | `false` | Enables or disables the configMap |
| configMaps.config.labels | object | `{}` | Labels to add to the configMap |
| controller.annotations | object | `{}` | Set annotations on the deployment/statefulset/daemonset |
| controller.annotations | object | `{}` | Set annotations on the deployment/statefulset/daemonset/cronjob |
| controller.cronjob | object | See below | CronJob configuration. Required only when using `controller.type: cronjob`. |
| controller.cronjob.concurrencyPolicy | string | `"Forbid"` | Specifies how to treat concurrent executions of a job that is created by this cron job, valid values are Allow, Forbid or Replace |
| controller.cronjob.failedJobsHistory | int | `1` | The number of failed Jobs to keep |
| controller.cronjob.schedule | string | `"*/20 * * * *"` | Sets the CronJob time when to execute your jobs |
| controller.cronjob.startingDeadlineSeconds | int | `30` | The deadline in seconds for starting the job if it misses its scheduled time for any reason |
| controller.cronjob.successfulJobsHistory | int | `1` | The number of succesful Jobs to keep |
| controller.enabled | bool | `true` | enable the controller. |
| controller.labels | object | `{}` | Set labels on the deployment/statefulset/daemonset |
| controller.labels | object | `{}` | Set labels on the deployment/statefulset/daemonset/cronjob |
| controller.podManagementPolicy | string | `nil` | Set statefulset podManagementPolicy, valid values are Parallel and OrderedReady (default). |
| controller.replicas | int | `1` | Number of desired pods |
| controller.restartPolicy | string | `Always`. When `controller.type` is `cronjob` it defaults to `Never`. | Set Container restart policy. |
| controller.revisionHistoryLimit | int | `3` | ReplicaSet revision history limit |
| controller.rollingUpdate.partition | string | `nil` | Set statefulset RollingUpdate partition |
| controller.rollingUpdate.surge | string | `nil` | Set deployment RollingUpdate max surge |
| controller.rollingUpdate.unavailable | string | `nil` | Set deployment RollingUpdate max unavailable |
| controller.strategy | string | `nil` | Set the controller upgrade strategy For Deployments, valid values are Recreate (default) and RollingUpdate. For StatefulSets, valid values are OnDelete and RollingUpdate (default). DaemonSets ignore this. |
| controller.type | string | `"deployment"` | Set the controller type. Valid options are deployment, daemonset or statefulset |
| controller.strategy | string | `nil` | Set the controller upgrade strategy For Deployments, valid values are Recreate (default) and RollingUpdate. For StatefulSets, valid values are OnDelete and RollingUpdate (default). DaemonSets/CronJobs ignore this. |
| controller.type | string | `"deployment"` | Set the controller type. Valid options are deployment, daemonset, statefulset or cronjob |
| dnsConfig | object | `{}` | Optional DNS settings, configuring the ndots option may resolve nslookup issues on some Kubernetes setups. |
| dnsPolicy | string | `nil` | Defaults to "ClusterFirst" if hostNetwork is false and "ClusterFirstWithHostNet" if hostNetwork is true. |
| enableServiceLinks | bool | `true` | Enable/disable the generation of environment variables for services. [[ref]](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service) |
@ -187,6 +194,7 @@ N/A
| route.main.kind | string | `"HTTPRoute"` | Set the route kind Valid options are GRPCRoute, HTTPRoute, TCPRoute, TLSRoute, UDPRoute |
| 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":null,"namespace":null,"port":null,"weight":1}],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Configure rules for routing. Defaults to the primary service. |
| route.main.rules[0].backendRefs | list | `[{"group":"","kind":"Service","name":null,"namespace":null,"port":null,"weight":1}]` | Configure backends where matching requests should be sent. |
| runtimeClassName | string | `nil` | Allow specifying a runtimeClassName other than the default one (ie: nvidia) |

View file

@ -0,0 +1,43 @@
{{/*
This template serves as a blueprint for Cronjob objects that are created
using the common library.
*/}}
{{- define "bjw-s.common.class.cronjob" -}}
{{- $restartPolicy := default "Never" .Values.controller.restartPolicy -}}
{{- if and (ne $restartPolicy "Never") (ne $restartPolicy "OnFailure") -}}
{{- fail (printf "Not a valid restartPolicy for CronJob (%s)" $restartPolicy) -}}
{{- end -}}
{{- $_ := set .Values.controller "restartPolicy" $restartPolicy -}}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
{{- with include "bjw-s.common.lib.controller.metadata.labels" . }}
labels: {{- . | nindent 4 }}
{{- end }}
{{- with include "bjw-s.common.lib.controller.metadata.annotations" . }}
annotations: {{- . | nindent 4 }}
{{- end }}
spec:
concurrencyPolicy: "{{ .Values.controller.cronjob.concurrencyPolicy }}"
startingDeadlineSeconds: {{ .Values.controller.cronjob.startingDeadlineSeconds }}
schedule: "{{ .Values.controller.cronjob.schedule }}"
successfulJobsHistoryLimit: {{ .Values.controller.cronjob.successfulJobsHistory }}
failedJobsHistoryLimit: {{ .Values.controller.cronjob.failedJobsHistory }}
jobTemplate:
spec:
template:
metadata:
{{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }}
annotations:
{{- . | nindent 8 }}
{{- end }}
labels:
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 12 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
{{- include "bjw-s.common.lib.controller.pod" . | nindent 10 }}
{{- end -}}

View file

@ -42,7 +42,9 @@ spec:
kind: {{ default "Gateway" .kind }}
name: {{ required (printf "parentRef name is required for %v %v" $routeKind $fullName) .name }}
namespace: {{ required (printf "parentRef namespace is required for %v %v" $routeKind $fullName) .namespace }}
sectionName: {{ default "" .sectionName | quote}}
{{- if .sectionName }}
sectionName: {{ .sectionName | quote }}
{{- end }}
{{- end }}
{{- if and (ne $routeKind "TCPRoute") (ne $routeKind "UDPRoute") $values.hostnames }}
hostnames:

View file

@ -102,4 +102,7 @@ topologySpreadConstraints:
tolerations:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- with .Values.controller.restartPolicy }}
restartPolicy: {{ . }}
{{- end }}
{{- end -}}

View file

@ -61,7 +61,7 @@ Volumes included by the controller.
{{- else if eq $persistence.type "custom" }}
{{- toYaml $persistence.volumeSpec | nindent 2 }}
{{- else }}
{{- fail (printf "Not a valid persistence.type (%s)" .Values.persistence.type) }}
{{- fail (printf "Not a valid persistence.type (%s)" $persistence.type) }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,21 @@
{{/* Return the name of the primary route object */}}
{{- define "bjw-s.common.lib.route.primary" -}}
{{- $enabledRoutes := dict -}}
{{- range $name, $route := .Values.route -}}
{{- if $route.enabled -}}
{{- $_ := set $enabledRoutes $name . -}}
{{- end -}}
{{- end -}}
{{- $result := "" -}}
{{- range $name, $route := $enabledRoutes -}}
{{- if and (hasKey $route "primary") $route.primary -}}
{{- $result = $name -}}
{{- end -}}
{{- end -}}
{{- if not $result -}}
{{- $result = keys $enabledRoutes | first -}}
{{- end -}}
{{- $result -}}
{{- end -}}

View file

@ -5,6 +5,8 @@ Renders the controller object required by the chart.
{{- if .Values.controller.enabled -}}
{{- if eq .Values.controller.type "deployment" -}}
{{- include "bjw-s.common.class.deployment" . | nindent 0 -}}
{{- else if eq .Values.controller.type "cronjob" -}}
{{- include "bjw-s.common.class.cronjob" . | nindent 0 -}}
{{ else if eq .Values.controller.type "daemonset" -}}
{{- include "bjw-s.common.class.daemonset" . | nindent 0 -}}
{{ else if eq .Values.controller.type "statefulset" -}}

View file

@ -6,7 +6,7 @@
{{- $routeValues := $route -}}
{{/* set defaults */}}
{{- if not $routeValues.nameOverride -}}
{{- if and (not $routeValues.nameOverride) (ne $name (include "bjw-s.common.lib.route.primary" $)) -}}
{{- $_ := set $routeValues "nameOverride" $name -}}
{{- end -}}

View file

@ -12,18 +12,18 @@ controller:
# -- enable the controller.
enabled: true
# -- Set the controller type.
# Valid options are deployment, daemonset or statefulset
# Valid options are deployment, daemonset, statefulset or cronjob
type: deployment
# -- Set annotations on the deployment/statefulset/daemonset
# -- Set annotations on the deployment/statefulset/daemonset/cronjob
annotations: {}
# -- Set labels on the deployment/statefulset/daemonset
# -- Set labels on the deployment/statefulset/daemonset/cronjob
labels: {}
# -- Number of desired pods
replicas: 1
# -- Set the controller upgrade strategy
# For Deployments, valid values are Recreate (default) and RollingUpdate.
# For StatefulSets, valid values are OnDelete and RollingUpdate (default).
# DaemonSets ignore this.
# DaemonSets/CronJobs ignore this.
strategy:
rollingUpdate:
# -- Set deployment RollingUpdate max unavailable
@ -36,6 +36,22 @@ controller:
revisionHistoryLimit: 3
# -- Set statefulset podManagementPolicy, valid values are Parallel and OrderedReady (default).
podManagementPolicy:
# -- Set Container restart policy.
# @default -- `Always`. When `controller.type` is `cronjob` it defaults to `Never`.
restartPolicy:
# -- CronJob configuration. Required only when using `controller.type: cronjob`.
# @default -- See below
cronjob:
# -- Specifies how to treat concurrent executions of a job that is created by this cron job, valid values are Allow, Forbid or Replace
concurrencyPolicy: Forbid
# -- Sets the CronJob time when to execute your jobs
schedule: "*/20 * * * *"
# -- The deadline in seconds for starting the job if it misses its scheduled time for any reason
startingDeadlineSeconds: 30
# -- The number of succesful Jobs to keep
successfulJobsHistory: 1
# -- The number of failed Jobs to keep
failedJobsHistory: 1
image:
# -- image repository
@ -422,7 +438,7 @@ route:
# -- Provide additional labels which may be required.
labels: {}
## -- Configure the resource the route attaches to.
# -- Configure the resource the route attaches to.
parentRefs:
- # Group of the referent resource.
group: gateway.networking.k8s.io
@ -433,7 +449,7 @@ route:
# Namespace of the referent resource
namespace:
# Name of the section within the target resource.
sectionName: ""
sectionName:
# -- Host addresses
hostnames: []