diff --git a/.ci/mkdocs/requirements.txt b/.ci/mkdocs/requirements.txt index 7f9a03cc..b4846713 100644 --- a/.ci/mkdocs/requirements.txt +++ b/.ci/mkdocs/requirements.txt @@ -1,5 +1,5 @@ mkdocs==1.4.2 mkdocs-macros-plugin ==0.7.0 -mkdocs-material ==8.5.7 +mkdocs-material ==8.5.9 mkdocs-minify-plugin==0.6.1 mkdocs-redirects==1.2.0 diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index a4592901..6a2639a0 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v2 name: common description: Function library for Helm charts type: library -version: 1.0.1 +version: 1.1.0 kubeVersion: ">=1.22.0-0" keywords: - common @@ -14,27 +14,25 @@ maintainers: email: me@bjw-s.dev annotations: artifacthub.io/changes: |- - - kind: removed - description: "**BREAKING**: Removed support for HorizontalPodAutoscaler" - - kind: added - description: Added support for `httpGet` probes - - kind: added - description: Added support for setting labels / annotations on volumeClaimTemplates - - kind: added - description: Support services have extraSelectorLabels - - kind: changed - description: "**BREAKING**: Restructure of template components. All Helm template names have changed!" - - kind: changed - description: "**BREAKING**: Raised minimum supported k8s version to 1.22" - - kind: changed - description: "**BREAKING**: Renamed `configmap` key to `configMaps`" - - kind: changed - description: "**BREAKING**: Moved `serviceMonitor` from `service` to its own key" - - kind: changed - description: "**BREAKING**: Renamed `secret` key to `secrets`, which now works similar to `configMaps`" - - kind: changed - description: Updated code-server image to v4.8.2 - - kind: changed - description: Updated gluetun image to v3.32.0 - kind: fixed - description: Fix NOTES always showing ingress protocol as http + description: Fixed code-server add-on Service rendering + - kind: fixed + description: Fixed httpGet probe whitespace rendering + - 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 + - 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 diff --git a/charts/library/common/README.md b/charts/library/common/README.md index 62ae167f..8b811bf0 100644 --- a/charts/library/common/README.md +++ b/charts/library/common/README.md @@ -1,6 +1,6 @@ # common -![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) +![Version: 1.1.0](https://img.shields.io/badge/Version-1.1.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.0.0 + version: 1.1.0 repository: https://bjw-s.github.io/helm-charts/ ``` @@ -61,7 +61,7 @@ N/A | addons.codeserver.git.deployKeySecret | string | `""` | Existing secret containing SSH private key The chart expects it to be present under the `id_rsa` key. | | addons.codeserver.image.pullPolicy | string | `"IfNotPresent"` | Specify the code-server image pull policy | | addons.codeserver.image.repository | string | `"ghcr.io/coder/code-server"` | Specify the code-server image | -| addons.codeserver.image.tag | string | `"4.8.2"` | Specify the code-server image tag | +| addons.codeserver.image.tag | string | `"4.8.3"` | Specify the code-server image tag | | addons.codeserver.ingress.enabled | bool | `false` | Enable an ingress for the code-server add-on. | | addons.codeserver.ingress.ingressClassName | string | `nil` | Set the ingressClass that is used for this ingress. | | addons.codeserver.service.enabled | bool | `true` | Enable a service for the code-server add-on. | @@ -72,24 +72,14 @@ N/A | addons.netshoot.env | object | `{}` | Set any environment variables for netshoot here | | addons.netshoot.image.pullPolicy | string | `"IfNotPresent"` | Specify the netshoot image pull policy | | addons.netshoot.image.repository | string | `"ghcr.io/nicolaka/netshoot"` | Specify the netshoot image | -| addons.netshoot.image.tag | string | `"v0.7"` | Specify the netshoot image tag | -| addons.promtail | object | See values.yaml | The common library supports adding a promtail add-on to to access logs and ship them to loki. It can be configured under this key. | -| addons.promtail.args | list | `[]` | Set promtail command line arguments | -| addons.promtail.enabled | bool | `false` | Enable running a promtail container in the pod | -| addons.promtail.env | object | `{}` | Set any environment variables for promtail here | -| addons.promtail.image.pullPolicy | string | `"IfNotPresent"` | Specify the promtail image pull policy | -| addons.promtail.image.repository | string | `"docker.io/grafana/promtail"` | Specify the promtail image | -| addons.promtail.image.tag | string | `"2.6.1"` | Specify the promtail image tag | -| addons.promtail.logs | list | `[]` | The paths to logs on the volume | -| addons.promtail.loki | string | `""` | The URL to Loki | -| addons.promtail.volumeMounts | list | `[]` | Specify a list of volumes that get mounted in the promtail container. At least 1 volumeMount is required! | +| addons.netshoot.image.tag | string | `"v0.8"` | Specify the netshoot image tag | | addons.vpn | object | See values.yaml | The common chart supports adding a VPN add-on. It can be configured under this key. | | addons.vpn.args | list | `[]` | Override the args for the vpn sidecar container | | addons.vpn.configFile | string | `nil` | Provide a customized vpn configuration file to be used by the VPN. | | addons.vpn.configFileSecret | string | `nil` | Reference an existing secret that contains the VPN configuration file The chart expects it to be present under the `vpnConfigfile` key. | | addons.vpn.enabled | bool | `false` | Enable running a VPN in the pod to route traffic through a VPN | | addons.vpn.env | object | `{}` | All variables specified here will be added to the vpn sidecar container See the documentation of the VPN image for all config values | -| addons.vpn.gluetun | object | See below | Gluetun specific configuration -- Make sure to read the [documentation](https://github.com/qdm12/gluetun/wiki) to see how to configure this addon! | +| addons.vpn.gluetun | object | See below | Make sure to read the [documentation](https://github.com/qdm12/gluetun/wiki) to see how to configure this addon! | | addons.vpn.gluetun.image.pullPolicy | string | `"IfNotPresent"` | Specify the Gluetun image pull policy | | addons.vpn.gluetun.image.repository | string | `"docker.io/qmcgaw/gluetun"` | Specify the Gluetun image | | addons.vpn.gluetun.image.tag | string | `"v3.32.0"` | Specify the Gluetun image tag | @@ -173,7 +163,7 @@ N/A | podLabels | object | `{}` | Set labels on the pod | | podSecurityContext | object | `{}` | Configure the Security Context for the Pod | | priorityClassName | string | `nil` | Custom priority class for different treatment by the scheduler | -| probes | object | See below | Probe configuration -- [[ref]](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) | +| probes | object | See below | [[ref]](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) | | probes.liveness | object | See below | Liveness probe configuration | | probes.liveness.custom | bool | `false` | Set this to `true` if you wish to specify your own livenessProbe | | probes.liveness.enabled | bool | `true` | Enable the liveness probe | @@ -190,6 +180,15 @@ N/A | probes.startup.spec | object | See below | The spec field contains the values for the default startupProbe. If you selected `custom: true`, this field holds the definition of the startupProbe. | | probes.startup.type | string | "TCP" | sets the probe type when not using a custom probe | | resources | object | `{}` | Set the resource requests / limits for the main container. | +| route | object | See below | Configure the gateway routes for the chart here. Additional routes can be added by adding a dictionary key similar to the 'main' route. [[ref]](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io%2fv1alpha2) | +| route.main.annotations | object | `{}` | Provide additional annotations which may be required. | +| route.main.enabled | bool | `false` | Enables or disables the route | +| route.main.hostnames | list | `[]` | Host addresses | +| 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.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) | | schedulerName | string | `nil` | Allows specifying a custom scheduler name | | 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. | @@ -201,7 +200,7 @@ N/A | service | object | See below | Configure the services for the chart here. Additional services can be added by adding a dictionary key similar to the 'main' service. | | service.main.annotations | object | `{}` | Provide additional annotations which may be required. | | service.main.enabled | bool | `true` | Enables or disables the service | -| service.main.externalTrafficPolicy | string | `nil` | Specify the externalTrafficPolicy for the service. Options: Cluster, Local -- [[ref](https://kubernetes.io/docs/tutorials/services/source-ip/)] | +| service.main.externalTrafficPolicy | string | `nil` | [[ref](https://kubernetes.io/docs/tutorials/services/source-ip/)] | | service.main.ipFamilies | list | `[]` | The ip families that should be used. Options: IPv4, IPv6 | | service.main.ipFamilyPolicy | string | `nil` | Specify the ip policy. Options: SingleStack, PreferDualStack, RequireDualStack | | service.main.labels | object | `{}` | Provide additional labels which may be required. | @@ -226,10 +225,10 @@ N/A | serviceMonitor.main.labels | object | `{}` | Provide additional labels which may be required. | | serviceMonitor.main.nameOverride | string | `nil` | Override the name suffix that is used for this serviceMonitor. | | serviceMonitor.main.selector | object | `{}` | Configures a custom selector for the serviceMonitor, this takes precedence over specifying a service name. Helm templates can be used. | -| serviceMonitor.main.serviceName | string | `"main"` | Configures the target Service for the serviceMonitor. Helm templates can be used. | -| termination.gracePeriodSeconds | string | `nil` | Duration in seconds the pod needs to terminate gracefully -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)] | -| termination.messagePath | string | `nil` | Configure the path at which the file to which the main container's termination message will be written. -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] | -| termination.messagePolicy | string | `nil` | Indicate how the main container's termination message should be populated. Valid options are `File` and `FallbackToLogsOnError`. -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] | +| serviceMonitor.main.serviceName | string | `"{{ include \"bjw-s.common.lib.chart.names.fullname\" $ }}"` | Configures the target Service for the serviceMonitor. Helm templates can be used. | +| termination.gracePeriodSeconds | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)] | +| termination.messagePath | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] | +| termination.messagePolicy | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] | | tolerations | list | `[]` | Specify taint tolerations [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) | | topologySpreadConstraints | list | `[]` | Defines topologySpreadConstraint rules. [[ref]](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) | | volumeClaimTemplates | list | `[]` | Used in conjunction with `controller.type: statefulset` to create individual disks for each instance. | @@ -241,4 +240,4 @@ N/A - Join the k8s-at-home [Discord](https://discord.gg/sTMX7Vh) community ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v0.1.1](https://github.com/k8s-at-home/helm-docs/releases/v0.1.1) +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/charts/library/common/templates/addons/code-server/_addon.tpl b/charts/library/common/templates/addons/code-server/_addon.tpl index 6c25c243..3ea25ed1 100644 --- a/charts/library/common/templates/addons/code-server/_addon.tpl +++ b/charts/library/common/templates/addons/code-server/_addon.tpl @@ -14,7 +14,7 @@ It will include / inject the required templates based on the given values. {{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 -}} {{- $deployKeySecret := include "bjw-s.common.addon.codeserver.deployKeySecret" . -}} {{- if $deployKeySecret -}} - {{- $_ := set .Values.secrets "addon-codeserver-deploykey" (dict "enabled" "true" "stringData" ($deployKeySecret | fromYaml)) -}} + {{- $_ := set .Values.secrets "addon-codeserver-deploykey" (dict "enabled" true "stringData" ($deployKeySecret | fromYaml)) -}} {{- end -}} {{- end -}} @@ -22,12 +22,18 @@ It will include / inject the required templates based on the given values. {{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 .Values.addons.codeserver.git.deployKeySecret }} {{- $volume := include "bjw-s.common.addon.codeserver.deployKeyVolumeSpec" . | fromYaml -}} {{- if $volume -}} - {{- $_ := set .Values.persistence "deploykey" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}} + {{- $_ := set .Values.persistence "deploykey" (dict "enabled" true "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}} {{- end -}} {{- end -}} {{/* Add the code-server service */}} - {{- $_ := set .Values.service "addon-codeserver" .Values.addons.codeserver.service -}} + {{- if .Values.addons.codeserver.service.enabled -}} + {{- $serviceValues := .Values.addons.codeserver.service -}} + {{- $_ := set $serviceValues "nameOverride" "addon-codeserver" -}} + {{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}} + {{- include "bjw-s.common.class.service" $ -}} + {{- $_ := unset $.ObjectValues "service" -}} + {{- end -}} {{/* Add the code-server ingress */}} {{- $svcName := printf "%v-addon-codeserver" (include "bjw-s.common.lib.chart.names.fullname" .) -}} diff --git a/charts/library/common/templates/addons/promtail/_addon.tpl b/charts/library/common/templates/addons/promtail/_addon.tpl deleted file mode 100644 index b0e994ef..00000000 --- a/charts/library/common/templates/addons/promtail/_addon.tpl +++ /dev/null @@ -1,25 +0,0 @@ -{{/* -Template to render promtail addon -It will include / inject the required templates based on the given values. -*/}} -{{- define "bjw-s.common.addon.promtail" -}} -{{- if .Values.addons.promtail.enabled -}} - {{/* Append the promtail container to the additionalContainers */}} - {{- $container := include "bjw-s.common.addon.promtail.container" . | fromYaml -}} - {{- if $container -}} - {{- $_ := set .Values.additionalContainers "addon-promtail" $container -}} - {{- end -}} - - {{/* Append the promtail configMap to the configmaps dict */}} - {{- $configmap := include "bjw-s.common.addon.promtail.configmap" . -}} - {{- if $configmap -}} - {{- $_ := set .Values.configMaps "addon-promtail" (dict "enabled" "true" "data" ($configmap | fromYaml)) -}} - {{- end -}} - - {{/* Append the promtail config volume to the volumes */}} - {{- $volume := include "bjw-s.common.addon.promtail.volumeSpec" . | fromYaml -}} - {{- if $volume -}} - {{- $_ := set .Values.persistence "addon-promtail" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}} - {{- end -}} -{{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/addons/promtail/_configmap.tpl b/charts/library/common/templates/addons/promtail/_configmap.tpl deleted file mode 100644 index 49bc09cb..00000000 --- a/charts/library/common/templates/addons/promtail/_configmap.tpl +++ /dev/null @@ -1,25 +0,0 @@ -{{/* -The promtail config to be included. -*/}} -{{- define "bjw-s.common.addon.promtail.configmap" -}} -promtail.yaml: | - server: - http_listen_port: 9080 - grpc_listen_port: 0 - positions: - filename: /tmp/positions.yaml - {{- with .Values.addons.promtail.loki }} - client: - url: {{ . }} - {{- end }} - scrape_configs: - {{- range .Values.addons.promtail.logs }} - - job_name: {{ .name }} - static_configs: - - targets: - - localhost - labels: - job: {{ .name }} - __path__: "{{ .path }}" - {{- end }} -{{- end -}} diff --git a/charts/library/common/templates/addons/promtail/_container.tpl b/charts/library/common/templates/addons/promtail/_container.tpl deleted file mode 100644 index 1c74a330..00000000 --- a/charts/library/common/templates/addons/promtail/_container.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{{/* -The promtail sidecar container to be inserted. -*/}} -{{- define "bjw-s.common.addon.promtail.container" -}} -{{- if lt (len .Values.addons.promtail.volumeMounts) 1 }} -{{- fail "At least 1 volumeMount is required for the promtail container" }} -{{- end -}} -name: promtail -image: "{{ .Values.addons.promtail.image.repository }}:{{ .Values.addons.promtail.image.tag }}" -imagePullPolicy: {{ .Values.addons.promtail.pullPolicy }} -{{- with .Values.addons.promtail.securityContext }} -securityContext: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.addons.promtail.env }} -env: -{{- range $k, $v := . }} - - name: {{ $k }} - value: {{ $v | quote }} -{{- end }} -{{- end }} -args: -{{- range .Values.addons.promtail.args }} -- {{ . | quote }} -{{- end }} -- "-config.file=/etc/promtail/promtail.yaml" -volumeMounts: - - name: addon-promtail - mountPath: /etc/promtail/promtail.yaml - subPath: promtail.yaml - readOnly: true -{{- with .Values.addons.promtail.volumeMounts }} - {{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.addons.promtail.resources }} -resources: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- end -}} diff --git a/charts/library/common/templates/addons/promtail/_volume.tpl b/charts/library/common/templates/addons/promtail/_volume.tpl deleted file mode 100644 index c04712bd..00000000 --- a/charts/library/common/templates/addons/promtail/_volume.tpl +++ /dev/null @@ -1,7 +0,0 @@ -{{/* -The volume (referencing config) to be inserted into additionalVolumes. -*/}} -{{- define "bjw-s.common.addon.promtail.volumeSpec" -}} -configMap: - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-promtail -{{- end -}} diff --git a/charts/library/common/templates/addons/vpn/_addon.tpl b/charts/library/common/templates/addons/vpn/_addon.tpl index 9e7b0262..d7a5c0df 100644 --- a/charts/library/common/templates/addons/vpn/_addon.tpl +++ b/charts/library/common/templates/addons/vpn/_addon.tpl @@ -12,7 +12,7 @@ It will include / inject the required templates based on the given values. {{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down }} {{- $configmap := include "bjw-s.common.addon.vpn.configmap" . -}} {{- if $configmap -}} - {{- $_ := set .Values.configMaps "addon-vpn" (dict "enabled" "true" "data" ($configmap | fromYaml)) -}} + {{- $_ := set .Values.configMaps "addon-vpn" (dict "enabled" true "data" ($configmap | fromYaml)) -}} {{- end -}} {{- end -}} @@ -20,20 +20,20 @@ It will include / inject the required templates based on the given values. {{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) }} {{- $secret := include "bjw-s.common.addon.vpn.secret" . -}} {{- if $secret -}} - {{- $_ := set .Values.secrets "addon-vpn-config" (dict "enabled" "true" "stringData" ($secret | fromYaml)) -}} + {{- $_ := set .Values.secrets "addon-vpn-config" (dict "enabled" true "stringData" ($secret | fromYaml)) -}} {{- end -}} {{- end -}} {{/* Append the vpn scripts volume to the volumes */}} {{- $scriptVolume := include "bjw-s.common.addon.vpn.scriptsVolumeSpec" . | fromYaml -}} {{- if $scriptVolume -}} - {{- $_ := set .Values.persistence "vpnscript" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $scriptVolume) -}} + {{- $_ := set .Values.persistence "vpnscript" (dict "enabled" true "mountPath" "-" "type" "custom" "volumeSpec" $scriptVolume) -}} {{- end -}} {{/* Append the vpn config volume to the volumes */}} {{- $configVolume := include "bjw-s.common.addon.vpn.configVolumeSpec" . | fromYaml }} {{ if $configVolume -}} - {{- $_ := set .Values.persistence "vpnconfig" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $configVolume) -}} + {{- $_ := set .Values.persistence "vpnconfig" (dict "enabled" true "mountPath" "-" "type" "custom" "volumeSpec" $configVolume) -}} {{- end -}} {{/* Include the networkpolicy if not empty */}} diff --git a/charts/library/common/templates/classes/_route.tpl b/charts/library/common/templates/classes/_route.tpl new file mode 100644 index 00000000..2c9298e0 --- /dev/null +++ b/charts/library/common/templates/classes/_route.tpl @@ -0,0 +1,71 @@ +{{/* +This template serves as a blueprint for all Route objects that are created +within the common library. +*/}} +{{- define "bjw-s.common.class.route" -}} +{{- $values := .Values.route -}} +{{- if hasKey . "ObjectValues" -}} + {{- with .ObjectValues.route -}} + {{- $values = . -}} + {{- end -}} +{{ end -}} + +{{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}} +{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} + {{- $fullName = printf "%v-%v" $fullName $values.nameOverride -}} +{{ end -}} +{{- $routeKind := $values.kind | default "HTTPRoute" -}} +{{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}} +{{- $defaultServiceName := $fullName -}} +{{- if and (hasKey $primaryService "nameOverride") $primaryService.nameOverride -}} + {{- $defaultServiceName = printf "%v-%v" $defaultServiceName $primaryService.nameOverride -}} +{{- end -}} +{{- $defaultServicePort := get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $primaryService)) -}} +--- +apiVersion: gateway.networking.k8s.io/v1alpha2 +{{- if and (ne $routeKind "GRPCRoute") (ne $routeKind "HTTPRoute") (ne $routeKind "TCPRoute") (ne $routeKind "TLSRoute") (ne $routeKind "UDPRoute") }} + {{- fail (printf "Not a valid route kind (%s)" $routeKind) }} +{{- end }} +kind: {{ $routeKind }} +metadata: + name: {{ $fullName }} + {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} + labels: {{- toYaml . | nindent 4 }} + {{- end }} + {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} + annotations: {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRefs: + {{- range $values.parentRefs }} + - group: {{ default "gateway.networking.k8s.io" .group }} + 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}} + {{- end }} + {{- if and (ne $routeKind "TCPRoute") (ne $routeKind "UDPRoute") $values.hostnames }} + hostnames: + {{- with $values.hostnames }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + rules: + {{- range $values.rules }} + - backendRefs: + {{- range .backendRefs }} + - group: {{ default "" .group | quote}} + kind: {{ default "Service" .kind }} + name: {{ default $defaultServiceName .name }} + namespace: {{ default $.Release.Namespace .namespace }} + port: {{ default $defaultServicePort.port .port }} + weight: {{ default 1 .weight }} + {{- end }} + {{- if (eq $routeKind "HTTPRoute") }} + {{- with .matches }} + matches: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/library/common/templates/classes/_secret.tpl b/charts/library/common/templates/classes/_secret.tpl index ec4f5fcc..29f59046 100644 --- a/charts/library/common/templates/classes/_secret.tpl +++ b/charts/library/common/templates/classes/_secret.tpl @@ -19,6 +19,9 @@ within the common library. --- apiVersion: v1 kind: Secret +{{- with $values.type }} +type: {{ . }} +{{- end }} metadata: name: {{ $secretName }} {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} @@ -27,8 +30,8 @@ metadata: {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} annotations: {{- toYaml . | nindent 4 }} {{- end }} -stringData: {{- with $values.stringData }} +stringData: {{- tpl (toYaml .) $ | nindent 2 }} {{- end }} {{- end -}} diff --git a/charts/library/common/templates/classes/_service.tpl b/charts/library/common/templates/classes/_service.tpl index b8ca08e6..d53184a9 100644 --- a/charts/library/common/templates/classes/_service.tpl +++ b/charts/library/common/templates/classes/_service.tpl @@ -15,6 +15,7 @@ within the common library. {{- $serviceName = printf "%v-%v" $serviceName $values.nameOverride -}} {{ end -}} {{- $svcType := $values.type | default "" -}} +{{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "serviceName" $serviceName "values" $values) | fromYaml }} {{- $primaryPort := get $values.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $values)) }} --- apiVersion: v1 @@ -76,25 +77,23 @@ spec: {{ toYaml . | nindent 4 }} {{- end }} ports: - {{- range $name, $port := $values.ports }} - {{- if $port.enabled }} - - port: {{ $port.port }} - targetPort: {{ $port.targetPort | default $name }} - {{- if $port.protocol }} - {{- if or ( eq $port.protocol "HTTP" ) ( eq $port.protocol "HTTPS" ) ( eq $port.protocol "TCP" ) }} - protocol: TCP - {{- else }} - protocol: {{ $port.protocol }} - {{- end }} - {{- else }} - protocol: TCP - {{- end }} - name: {{ $name }} - {{- if (and (eq $svcType "NodePort") (not (empty $port.nodePort))) }} - nodePort: {{ $port.nodePort }} - {{ end }} - {{- end }} - {{- end }} + {{- range $name, $port := $enabledPorts }} + - port: {{ $port.port }} + targetPort: {{ $port.targetPort | default $name }} + {{- if $port.protocol }} + {{- if or ( eq $port.protocol "HTTP" ) ( eq $port.protocol "HTTPS" ) ( eq $port.protocol "TCP" ) }} + protocol: TCP + {{- else }} + protocol: {{ $port.protocol }} + {{- end }} + {{- else }} + protocol: TCP + {{- end }} + name: {{ $name }} + {{- if (and (eq $svcType "NodePort") (not (empty $port.nodePort))) }} + nodePort: {{ $port.nodePort }} + {{ end }} + {{- end -}} {{- with (merge ($values.extraSelectorLabels | default dict) (include "bjw-s.common.lib.metadata.selectorLabels" . | fromYaml)) }} selector: {{- toYaml . | nindent 4 }} {{- end }} diff --git a/charts/library/common/templates/classes/_serviceAccount.tpl b/charts/library/common/templates/classes/_serviceAccount.tpl index 1505b11b..7f806857 100644 --- a/charts/library/common/templates/classes/_serviceAccount.tpl +++ b/charts/library/common/templates/classes/_serviceAccount.tpl @@ -8,8 +8,12 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ include "bjw-s.common.lib.chart.names.serviceAccountName" . }} - labels: {{- include "bjw-s.common.lib.metadata.allLabels" $ | nindent 4 }} + {{- with include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml }} + labels: {{- toYaml . | nindent 4 }} + {{- end }} {{- with (merge (.Values.serviceAccount.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} annotations: {{- toYaml . | nindent 4 }} {{- end }} +secrets: + - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-sa-token {{- end -}} diff --git a/charts/library/common/templates/lib/container/_ports.tpl b/charts/library/common/templates/lib/container/_ports.tpl index 2b1404ef..c1575cfa 100644 --- a/charts/library/common/templates/lib/container/_ports.tpl +++ b/charts/library/common/templates/lib/container/_ports.tpl @@ -3,19 +3,18 @@ Ports included by the controller. */}} {{- define "bjw-s.common.lib.container.ports" -}} {{- $ports := list -}} - {{- range .Values.service -}} - {{- if .enabled -}} - {{- range $name, $port := .ports -}} - {{- $_ := set $port "name" $name -}} - {{- $ports = mustAppend $ports $port -}} - {{- end }} + {{- range $servicename, $service := .Values.service -}} + {{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "serviceName" $servicename "values" $service) | fromYaml }} + {{- range $portname, $port := ($enabledPorts | default dict) -}} + {{- $_ := set $port "name" $portname -}} + {{- $ports = mustAppend $ports $port -}} {{- end }} {{- end }} {{/* export/render the list of ports */}} {{- if $ports -}} {{- range $_ := $ports }} -{{- if .enabled }} +{{- if default true .enabled | }} - name: {{ .name }} {{- if and .targetPort (kindIs "string" .targetPort) }} {{- fail (printf "Our charts do not support named ports for targetPort. (port name %s, targetPort %s)" .name .targetPort) }} diff --git a/charts/library/common/templates/lib/container/_probes.tpl b/charts/library/common/templates/lib/container/_probes.tpl index 38fe7554..20742437 100644 --- a/charts/library/common/templates/lib/container/_probes.tpl +++ b/charts/library/common/templates/lib/container/_probes.tpl @@ -22,7 +22,7 @@ Probes selection logic. {{- else -}} {{- $probeType = $probe.type | default "TCP" -}} {{- end }} - {{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}} + {{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) }} httpGet: path: {{ $probe.path }} scheme: {{ $probeType }} diff --git a/charts/library/common/templates/lib/service/_enabled_ports.tpl b/charts/library/common/templates/lib/service/_enabled_ports.tpl new file mode 100644 index 00000000..9df2bf7d --- /dev/null +++ b/charts/library/common/templates/lib/service/_enabled_ports.tpl @@ -0,0 +1,23 @@ +{{/* +Return the enabled ports for a given Service object. +*/}} +{{- define "bjw-s.common.lib.service.enabledPorts" -}} + {{- $enabledPorts := dict -}} + + {{- range $name, $port := .values.ports -}} + {{- if kindIs "map" $port -}} + {{- $portEnabled := true -}} + {{- if hasKey $port "enabled" -}} + {{- $portEnabled = $port.enabled -}} + {{- end -}} + {{- if $portEnabled -}} + {{- $_ := set $enabledPorts $name . -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- if eq 0 (len $enabledPorts) }} + {{- fail (printf "No ports are enabled for service \"%s\"!" (.serviceName | default "")) }} + {{- end }} + {{- $enabledPorts | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/service/_enabled_services.tpl b/charts/library/common/templates/lib/service/_enabled_services.tpl new file mode 100644 index 00000000..c5d14627 --- /dev/null +++ b/charts/library/common/templates/lib/service/_enabled_services.tpl @@ -0,0 +1,18 @@ +{{/* +Return the enabled services. +*/}} +{{- define "bjw-s.common.lib.service.enabledServices" -}} + {{- $enabledServices := dict -}} + {{- range $name, $service := .Values.service -}} + {{- if kindIs "map" $service -}} + {{- $serviceEnabled := true -}} + {{- if hasKey $service "enabled" -}} + {{- $serviceEnabled = $service.enabled -}} + {{- end -}} + {{- if $serviceEnabled -}} + {{- $_ := set $enabledServices $name . -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- $enabledServices | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/service/_primary.tpl b/charts/library/common/templates/lib/service/_primary.tpl index e6bdd4d9..da168ee3 100644 --- a/charts/library/common/templates/lib/service/_primary.tpl +++ b/charts/library/common/templates/lib/service/_primary.tpl @@ -2,12 +2,7 @@ Return the primary service object */}} {{- define "bjw-s.common.lib.service.primary" -}} - {{- $enabledServices := dict -}} - {{- range $name, $service := .Values.service -}} - {{- if $service.enabled -}} - {{- $_ := set $enabledServices $name . -}} - {{- end -}} - {{- end -}} + {{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" $ | fromYaml ) }} {{- $result := "" -}} {{- range $name, $service := $enabledServices -}} diff --git a/charts/library/common/templates/lib/service/_primary_port.tpl b/charts/library/common/templates/lib/service/_primary_port.tpl index 04660581..0cb7aeee 100644 --- a/charts/library/common/templates/lib/service/_primary_port.tpl +++ b/charts/library/common/templates/lib/service/_primary_port.tpl @@ -2,16 +2,7 @@ Return the primary port for a given Service object. */}} {{- define "bjw-s.common.lib.service.primaryPort" -}} - {{- $enabledPorts := dict -}} - {{- range $name, $port := .values.ports -}} - {{- if $port.enabled -}} - {{- $_ := set $enabledPorts $name . -}} - {{- end -}} - {{- end -}} - - {{- if eq 0 (len $enabledPorts) }} - {{- fail (printf "No ports are enabled for service \"%s\"!" .serviceName) }} - {{- end }} + {{- $enabledPorts := (include "bjw-s.common.lib.service.enabledPorts" . | fromYaml) }} {{- $result := "" -}} {{- range $name, $port := $enabledPorts -}} diff --git a/charts/library/common/templates/loader/_generate.tpl b/charts/library/common/templates/loader/_generate.tpl index 2afbee4d..0c0fa214 100644 --- a/charts/library/common/templates/loader/_generate.tpl +++ b/charts/library/common/templates/loader/_generate.tpl @@ -12,23 +12,19 @@ Secondary entrypoint and primary loader for the common chart {{- include "bjw-s.common.addon.vpn" . | nindent 0 -}} {{- end -}} - {{- /* Enable promtail add-on if required */ -}} - {{- if .Values.addons.promtail.enabled -}} - {{- include "bjw-s.common.addon.promtail" . | nindent 0 -}} - {{- end -}} - {{- /* Enable netshoot add-on if required */ -}} {{- if .Values.addons.netshoot.enabled -}} {{- include "bjw-s.common.addon.netshoot" . | nindent 0 -}} {{- end -}} {{- /* Build the templates */ -}} - {{- include "bjw-s.common.render.configmaps" . | nindent 0 -}} - {{- include "bjw-s.common.render.secrets" . | nindent 0 -}} {{- include "bjw-s.common.render.pvcs" . | nindent 0 -}} {{- include "bjw-s.common.render.serviceAccount" . | nindent 0 -}} {{- include "bjw-s.common.render.controller" . | nindent 0 -}} {{- include "bjw-s.common.render.services" . | nindent 0 -}} {{- include "bjw-s.common.render.ingresses" . | nindent 0 -}} {{- include "bjw-s.common.render.serviceMonitors" . | nindent 0 -}} + {{- include "bjw-s.common.render.routes" . | nindent 0 -}} + {{- include "bjw-s.common.render.configmaps" . | nindent 0 -}} + {{- include "bjw-s.common.render.secrets" . | nindent 0 -}} {{- end -}} diff --git a/charts/library/common/templates/render/_routes.tpl b/charts/library/common/templates/render/_routes.tpl new file mode 100644 index 00000000..d84e431e --- /dev/null +++ b/charts/library/common/templates/render/_routes.tpl @@ -0,0 +1,18 @@ +{{/* Renders the Route objects required by the chart */}} +{{- define "bjw-s.common.render.routes" -}} + {{- /* Generate named routes as required */ -}} + {{- range $name, $route := .Values.route }} + {{- if $route.enabled -}} + {{- $routeValues := $route -}} + + {{/* set defaults */}} + {{- if not $routeValues.nameOverride -}} + {{- $_ := set $routeValues "nameOverride" $name -}} + {{- end -}} + + {{- $_ := set $ "ObjectValues" (dict "route" $routeValues) -}} + {{- include "bjw-s.common.class.route" $ | nindent 0 -}} + {{- $_ := unset $.ObjectValues "route" -}} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/library/common/templates/render/_serviceaccount.tpl b/charts/library/common/templates/render/_serviceaccount.tpl index 8212c040..afdbcab0 100644 --- a/charts/library/common/templates/render/_serviceaccount.tpl +++ b/charts/library/common/templates/render/_serviceaccount.tpl @@ -3,6 +3,21 @@ Renders the serviceAccount object required by the chart. */}} {{- define "bjw-s.common.render.serviceAccount" -}} {{- if .Values.serviceAccount.create -}} + + {{- /* Create a service account secret */ -}} + {{- $_ := set .Values.secrets "sa-token" (dict "enabled" true "type" "kubernetes.io/service-account-token") -}} + {{- include "bjw-s.common.class.serviceAccount" $ | nindent 0 -}} {{- end -}} {{- end -}} + +# serviceAccount: +# # -- Specifies whether a service account should be created +# create: false + +# # -- Annotations to add to the service account +# annotations: {} + +# # -- The name of the service account to use. +# # If not set and create is true, a name is generated using the fullname template +# name: "" diff --git a/charts/library/common/templates/render/_services.tpl b/charts/library/common/templates/render/_services.tpl index c270fa1c..3e7097c4 100644 --- a/charts/library/common/templates/render/_services.tpl +++ b/charts/library/common/templates/render/_services.tpl @@ -4,7 +4,7 @@ Renders the Service objects required by the chart. {{- define "bjw-s.common.render.services" -}} {{- /* Generate named services as required */ -}} {{- range $name, $service := .Values.service -}} - {{- if $service.enabled -}} + {{- if ($service.enabled | default true ) -}} {{- $serviceValues := $service -}} {{/* set the default nameOverride to the service name */}} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index 8fc2a4f1..b6ccc47a 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -400,6 +400,60 @@ ingress: # hosts: # - chart-example.local +# -- Configure the gateway routes for the chart here. +# Additional routes can be added by adding a dictionary key similar to the 'main' route. +# [[ref]](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io%2fv1alpha2) +# @default -- See below +route: + main: + # -- Enables or disables the route + enabled: false + + # -- Set the route kind + # Valid options are GRPCRoute, HTTPRoute, TCPRoute, TLSRoute, UDPRoute + kind: HTTPRoute + + # -- Override the name suffix that is used for this route. + nameOverride: + + # -- Provide additional annotations which may be required. + annotations: {} + + # -- Provide additional labels which may be required. + labels: {} + + ## -- Configure the resource the route attaches to. + parentRefs: + - # Group of the referent resource. + group: gateway.networking.k8s.io + # Kind of the referent resource. + kind: Gateway + # Name of the referent resource + name: + # Namespace of the referent resource + namespace: + # Name of the section within the target resource. + sectionName: "" + + # -- Host addresses + hostnames: [] + + # -- Configure rules for routing. Defaults to the primary service. + rules: + - # -- Configure backends where matching requests should be sent. + backendRefs: + - group: "" + kind: Service + name: + namespace: + port: + weight: 1 + ## Configure conditions used for matching incoming requests. Only for HTTPRoutes + matches: + - path: + type: PathPrefix + value: / + # -- 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) @@ -639,7 +693,7 @@ addons: # -- Specify the code-server image repository: ghcr.io/coder/code-server # -- Specify the code-server image tag - tag: 4.8.2 + tag: 4.8.3 # -- Specify the code-server image pull policy pullPolicy: IfNotPresent @@ -720,44 +774,6 @@ addons: securityContext: runAsUser: 0 - # -- The common library supports adding a promtail add-on to to access logs and ship them to loki. It can be configured under this key. - # @default -- See values.yaml - promtail: - # -- Enable running a promtail container in the pod - enabled: false - - image: - # -- Specify the promtail image - repository: docker.io/grafana/promtail - # -- Specify the promtail image tag - tag: 2.6.1 - # -- Specify the promtail image pull policy - pullPolicy: IfNotPresent - - # -- Set any environment variables for promtail here - env: {} - - # -- Set promtail command line arguments - args: [] - - # -- The URL to Loki - loki: "" - - # -- The paths to logs on the volume - logs: [] - # - name: log - # path: /config/logs/*.log - - # -- Specify a list of volumes that get mounted in the promtail container. - # At least 1 volumeMount is required! - volumeMounts: [] - # - name: config - # mountPath: /config - # readOnly: true - - securityContext: - runAsUser: 0 - # -- The common library supports adding a netshoot add-on to troubleshoot network issues within a Pod. It can be configured under this key. # @default -- See values.yaml netshoot: @@ -768,7 +784,7 @@ addons: # -- Specify the netshoot image repository: ghcr.io/nicolaka/netshoot # -- Specify the netshoot image tag - tag: v0.7 + tag: v0.8 # -- Specify the netshoot image pull policy pullPolicy: IfNotPresent diff --git a/charts/other/app-template/Chart.yaml b/charts/other/app-template/Chart.yaml index 38ed752d..600aec0f 100644 --- a/charts/other/app-template/Chart.yaml +++ b/charts/other/app-template/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 description: A common powered chart template. This can be useful for small projects that don't have their own chart. name: app-template -version: 1.0.1 +version: 1.1.0 kubeVersion: ">=1.22.0-0" maintainers: - name: bjw-s @@ -10,12 +10,12 @@ maintainers: dependencies: - name: common repository: https://bjw-s.github.io/helm-charts - version: 1.0.1 + version: 1.1.0 annotations: artifacthub.io/changes: |- - kind: changed description: | - **BREAKING**: Updated library version to 1.0.1. + Updated library version to 1.1.0. links: - name: Common library chart definition url: https://github.com/bjw-s/helm-charts/blob/main/charts/library/common/Chart.yaml diff --git a/charts/other/app-template/ci/promtail-values.yaml b/charts/other/app-template/ci/promtail-values.yaml deleted file mode 100644 index 0d6e837e..00000000 --- a/charts/other/app-template/ci/promtail-values.yaml +++ /dev/null @@ -1,29 +0,0 @@ -image: - repository: ghcr.io/k8s-at-home/qbittorrent - tag: latest - pullPolicy: IfNotPresent - -service: - main: - ports: - http: - port: 8080 - -persistence: - config: - enabled: true - emptyDir: - enabled: true - mountPath: /config - -addons: - promtail: - enabled: true - loki: http://loki.monitoring.svc.cluster.local:3100/loki/api/v1/push - logs: - - name: qbittorrent - path: /config/data/qBittorrent/logs/*.log - volumeMounts: - - name: config - mountPath: /config - readOnly: true diff --git a/charts/other/app-template/tests/addons/codeserver_test.yaml b/charts/other/app-template/tests/addons/codeserver_test.yaml index e76a849b..377fe9ea 100644 --- a/charts/other/app-template/tests/addons/codeserver_test.yaml +++ b/charts/other/app-template/tests/addons/codeserver_test.yaml @@ -29,13 +29,13 @@ tests: asserts: - hasDocuments: count: 3 - - documentIndex: &DeploymentDocument 0 + - documentIndex: &DeploymentDocument 1 isKind: of: Deployment - - documentIndex: &AddonServiceDocument 2 + - documentIndex: &AddonServiceDocument 0 isKind: of: Service - - documentIndex: 1 + - documentIndex: &ApplicationServiceDocument 2 isKind: of: Service - documentIndex: *DeploymentDocument @@ -45,7 +45,7 @@ tests: - documentIndex: *AddonServiceDocument equal: path: metadata.name - value: RELEASE-NAME + value: RELEASE-NAME-addon-codeserver - it: addon enabled with deployKey should pass set: @@ -60,7 +60,7 @@ tests: asserts: - hasDocuments: count: 4 - - documentIndex: &AddonDeployKeySecretDocument 0 + - documentIndex: &AddonDeployKeySecretDocument 3 isKind: of: Secret - documentIndex: &DeploymentDocument 1 @@ -102,7 +102,7 @@ tests: asserts: - hasDocuments: count: 4 - - documentIndex: &AddonDeployKeySecretDocument 0 + - documentIndex: &AddonDeployKeySecretDocument 3 isKind: of: Secret - documentIndex: &DeploymentDocument 1 @@ -144,7 +144,7 @@ tests: asserts: - hasDocuments: count: 3 - - documentIndex: &DeploymentDocument 0 + - documentIndex: &DeploymentDocument 1 isKind: of: Deployment - documentIndex: *DeploymentDocument diff --git a/charts/other/app-template/tests/addons/vpn_test.yaml b/charts/other/app-template/tests/addons/vpn_test.yaml index 7f37d61c..45b0ee44 100644 --- a/charts/other/app-template/tests/addons/vpn_test.yaml +++ b/charts/other/app-template/tests/addons/vpn_test.yaml @@ -46,10 +46,10 @@ tests: asserts: - hasDocuments: count: 3 - - documentIndex: &AddonVPNConfigSecretDocument 0 + - documentIndex: &AddonVPNConfigSecretDocument 2 isKind: of: Secret - - documentIndex: &DeploymentDocument 1 + - documentIndex: &DeploymentDocument 0 isKind: of: Deployment - documentIndex: *DeploymentDocument @@ -87,10 +87,10 @@ tests: asserts: - hasDocuments: count: 3 - - documentIndex: &AddonVPNConfigConfigMapDocument 0 + - documentIndex: &AddonVPNConfigConfigMapDocument 2 isKind: of: ConfigMap - - documentIndex: &DeploymentDocument 1 + - documentIndex: &DeploymentDocument 0 isKind: of: Deployment - documentIndex: *DeploymentDocument diff --git a/charts/other/app-template/tests/configmap/metadata_test.yaml b/charts/other/app-template/tests/configmap/metadata_test.yaml index df42f001..0bb677f3 100644 --- a/charts/other/app-template/tests/configmap/metadata_test.yaml +++ b/charts/other/app-template/tests/configmap/metadata_test.yaml @@ -8,7 +8,9 @@ tests: config: enabled: true asserts: - - documentIndex: &ConfigmapDocument 0 + - hasDocuments: + count: 3 + - documentIndex: &ConfigmapDocument 2 isKind: of: ConfigMap - documentIndex: *ConfigmapDocument @@ -21,7 +23,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 - it: custom metadata should pass set: @@ -33,7 +35,9 @@ tests: labels: test_label: test asserts: - - documentIndex: &ConfigmapDocument 0 + - hasDocuments: + count: 3 + - documentIndex: &ConfigmapDocument 2 isKind: of: ConfigMap - documentIndex: *ConfigmapDocument @@ -48,7 +52,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test - it: custom metadata with global metadata should pass @@ -66,7 +70,9 @@ tests: labels: test_label: test asserts: - - documentIndex: &ConfigmapDocument 0 + - hasDocuments: + count: 3 + - documentIndex: &ConfigmapDocument 2 isKind: of: ConfigMap - documentIndex: *ConfigmapDocument @@ -83,5 +89,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test diff --git a/charts/other/app-template/tests/configmap/names_test.yaml b/charts/other/app-template/tests/configmap/names_test.yaml index b00ae5ea..dea7e9c8 100644 --- a/charts/other/app-template/tests/configmap/names_test.yaml +++ b/charts/other/app-template/tests/configmap/names_test.yaml @@ -44,16 +44,16 @@ tests: asserts: - hasDocuments: count: 4 - - documentIndex: 0 + - documentIndex: &FirstConfigmapDocument 2 isKind: of: ConfigMap - - documentIndex: 0 + - documentIndex: *FirstConfigmapDocument isNotNull: path: metadata.name - - documentIndex: 1 + - documentIndex: &SecondConfigmapDocument 3 isKind: of: ConfigMap - - documentIndex: 1 + - documentIndex: *SecondConfigmapDocument isNotNull: path: metadata.name @@ -65,10 +65,10 @@ tests: asserts: - hasDocuments: count: 3 - - documentIndex: 0 + - documentIndex: &ConfigmapDocument 2 isKind: of: ConfigMap - - documentIndex: 0 + - documentIndex: *ConfigmapDocument equal: path: metadata.name value: RELEASE-NAME-config @@ -82,10 +82,10 @@ tests: asserts: - hasDocuments: count: 3 - - documentIndex: 0 + - documentIndex: &ConfigmapDocument 2 isKind: of: ConfigMap - - documentIndex: 0 + - documentIndex: *ConfigmapDocument equal: path: metadata.name value: RELEASE-NAME-http diff --git a/charts/other/app-template/tests/configmap/pod_metadata_test.yaml b/charts/other/app-template/tests/configmap/pod_metadata_test.yaml index bc181e45..93ab0a36 100644 --- a/charts/other/app-template/tests/configmap/pod_metadata_test.yaml +++ b/charts/other/app-template/tests/configmap/pod_metadata_test.yaml @@ -10,7 +10,7 @@ tests: data: test: value 1 asserts: - - documentIndex: &ControllerDoc 1 + - documentIndex: &ControllerDoc 0 isKind: of: Deployment - documentIndex: *ControllerDoc diff --git a/charts/other/app-template/tests/container/probes_test.yaml b/charts/other/app-template/tests/container/probes_test.yaml new file mode 100644 index 00000000..661f34ec --- /dev/null +++ b/charts/other/app-template/tests/container/probes_test.yaml @@ -0,0 +1,313 @@ +suite: container probes +templates: + - common.yaml +tests: + - it: default should pass + set: + service: + main: + ports: + http: + enabled: true + port: &port 80 + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].livenessProbe + value: + failureThreshold: 3 + initialDelaySeconds: 0 + periodSeconds: 10 + tcpSocket: + port: *port + timeoutSeconds: 1 + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].readinessProbe + value: + failureThreshold: 3 + initialDelaySeconds: 0 + periodSeconds: 10 + tcpSocket: + port: *port + timeoutSeconds: 1 + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].startupProbe + value: + failureThreshold: 30 + initialDelaySeconds: 0 + periodSeconds: 5 + tcpSocket: + port: *port + timeoutSeconds: 1 + + - it: custom primary port should pass + set: + service: + main: + ports: + http: + enabled: true + port: 80 + test: + enabled: true + primary: true + port: &port 8080 + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].livenessProbe + value: + failureThreshold: 3 + initialDelaySeconds: 0 + periodSeconds: 10 + tcpSocket: + port: *port + timeoutSeconds: 1 + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].readinessProbe + value: + failureThreshold: 3 + initialDelaySeconds: 0 + periodSeconds: 10 + tcpSocket: + port: *port + timeoutSeconds: 1 + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].startupProbe + value: + failureThreshold: 30 + initialDelaySeconds: 0 + periodSeconds: 5 + tcpSocket: + port: *port + timeoutSeconds: 1 + + - it: disabled service should pass + set: + service: + main: + enabled: false + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].livenessProbe + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].readinessProbe + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].startupProbe + + - it: AUTO type probe should pass + set: + service: + main: + ports: + http: + port: &port 80 + + probes: + liveness: + enabled: true + type: AUTO + path: /api/version + + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].livenessProbe + value: + httpGet: + path: /api/version + port: *port + scheme: HTTP + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + - it: HTTP type probe should pass + set: + service: + main: + ports: + http: + port: &port 80 + + probes: + liveness: + enabled: true + type: HTTP + path: /api/version + + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].livenessProbe + value: + httpGet: + path: /api/version + port: *port + scheme: HTTP + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + - it: HTTPS type probe should pass + set: + service: + main: + ports: + http: + port: &port 80 + + probes: + liveness: + enabled: true + type: HTTPS + path: /api/version + + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].livenessProbe + value: + httpGet: + path: /api/version + port: *port + scheme: HTTPS + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + - it: custom liveness probe should pass + set: + service: + main: + ports: + http: + port: &port 80 + + probes: + liveness: + enabled: true + custom: true + spec: + httpGet: + path: /api/version + port: *port + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].livenessProbe + value: + httpGet: + path: /api/version + port: *port + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + - it: custom readiness probe should pass + set: + service: + main: + ports: + http: + port: &port 80 + + probes: + readiness: + enabled: true + custom: true + spec: + httpGet: + path: /api/version + port: *port + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].readinessProbe + value: + httpGet: + path: /api/version + port: *port + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + - it: custom startup probe should pass + set: + service: + main: + ports: + http: + port: &port 80 + + probes: + startup: + enabled: true + custom: true + spec: + httpGet: + path: /api/version + port: *port + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].startupProbe + value: + httpGet: + path: /api/version + port: *port + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 diff --git a/charts/other/app-template/tests/controller/metadata_daemonset_test.yaml b/charts/other/app-template/tests/controller/metadata_daemonset_test.yaml index 9f2bbc67..225bf4b5 100644 --- a/charts/other/app-template/tests/controller/metadata_daemonset_test.yaml +++ b/charts/other/app-template/tests/controller/metadata_daemonset_test.yaml @@ -19,7 +19,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 - it: custom metadata should pass set: @@ -45,7 +45,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test - it: custom metadata with global metadata should pass @@ -79,5 +79,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test diff --git a/charts/other/app-template/tests/controller/metadata_deployment_test.yaml b/charts/other/app-template/tests/controller/metadata_deployment_test.yaml index d91d202a..9f84b720 100644 --- a/charts/other/app-template/tests/controller/metadata_deployment_test.yaml +++ b/charts/other/app-template/tests/controller/metadata_deployment_test.yaml @@ -19,7 +19,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 - it: custom metadata should pass set: @@ -45,7 +45,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test - it: custom metadata with global metadata should pass @@ -79,5 +79,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test diff --git a/charts/other/app-template/tests/controller/metadata_statefulset_test.yaml b/charts/other/app-template/tests/controller/metadata_statefulset_test.yaml index 483c3aa0..68d0cd5d 100644 --- a/charts/other/app-template/tests/controller/metadata_statefulset_test.yaml +++ b/charts/other/app-template/tests/controller/metadata_statefulset_test.yaml @@ -19,7 +19,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 - it: custom metadata should pass set: @@ -45,7 +45,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test - it: custom metadata with global metadata should pass @@ -79,5 +79,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test diff --git a/charts/other/app-template/tests/ingress/metadata_test.yaml b/charts/other/app-template/tests/ingress/metadata_test.yaml index 7b2b0d8a..2d090f4f 100644 --- a/charts/other/app-template/tests/ingress/metadata_test.yaml +++ b/charts/other/app-template/tests/ingress/metadata_test.yaml @@ -19,7 +19,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 - it: custom metadata should pass set: @@ -45,7 +45,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test - it: custom metadata with global metadata should pass @@ -79,5 +79,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test diff --git a/charts/other/app-template/tests/pvc/metadata_test.yaml b/charts/other/app-template/tests/pvc/metadata_test.yaml index bb0ec42a..98088e06 100644 --- a/charts/other/app-template/tests/pvc/metadata_test.yaml +++ b/charts/other/app-template/tests/pvc/metadata_test.yaml @@ -19,7 +19,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 - it: retain enabled should pass set: @@ -42,7 +42,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 - it: custom metadata should pass set: @@ -68,7 +68,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test - it: custom metadata with global metadata should pass @@ -102,5 +102,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test diff --git a/charts/other/app-template/tests/route/metadata_test.yaml b/charts/other/app-template/tests/route/metadata_test.yaml new file mode 100644 index 00000000..46ba8b79 --- /dev/null +++ b/charts/other/app-template/tests/route/metadata_test.yaml @@ -0,0 +1,93 @@ +suite: route metadata +templates: + - common.yaml +tests: + - it: default metadata should pass + set: + route.main: + enabled: true + parentRefs: + - name: test + namespace: test + asserts: + - documentIndex: &routeDocument 2 + isKind: + of: HTTPRoute + - documentIndex: *routeDocument + isNull: + path: metadata.annotations + - documentIndex: *routeDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: RELEASE-NAME + helm.sh/chart: app-template-1.1.0 + + - it: custom metadata should pass + set: + route.main: + enabled: true + annotations: + test_annotation: test + labels: + test_label: test + parentRefs: + - name: test + namespace: test + asserts: + - documentIndex: &routeDocument 2 + isKind: + of: HTTPRoute + - documentIndex: *routeDocument + equal: + path: metadata.annotations + value: + test_annotation: test + - documentIndex: *routeDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: RELEASE-NAME + helm.sh/chart: app-template-1.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + route.main: + enabled: true + annotations: + test_annotation: test + labels: + test_label: test + parentRefs: + - name: test + namespace: test + asserts: + - documentIndex: &routeDocument 2 + isKind: + of: HTTPRoute + - documentIndex: *routeDocument + equal: + path: metadata.annotations + value: + global_annotation: test + test_annotation: test + - documentIndex: *routeDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: RELEASE-NAME + global_label: test + helm.sh/chart: app-template-1.1.0 + test_label: test diff --git a/charts/other/app-template/tests/route/presence_test.yaml b/charts/other/app-template/tests/route/presence_test.yaml new file mode 100644 index 00000000..c3b87603 --- /dev/null +++ b/charts/other/app-template/tests/route/presence_test.yaml @@ -0,0 +1,84 @@ +suite: route presence +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: HTTPRoute + - documentIndex: 1 + not: true + isKind: + of: HTTPRoute + + - it: explicitly disabled should pass + set: + route.main.enabled: false + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: HTTPRoute + - documentIndex: 1 + not: true + isKind: + of: HTTPRoute + + - it: explicitly enabled should pass + set: + route.main: + enabled: true + parentRefs: + - name: test + namespace: test + asserts: + - hasDocuments: + count: 3 + - documentIndex: 0 + not: true + isKind: + of: HTTPRoute + - documentIndex: 1 + not: true + isKind: + of: HTTPRoute + - documentIndex: 2 + isKind: + of: HTTPRoute + + - it: multiple enabled should pass + set: + route: + main: + enabled: true + parentRefs: + - name: main + namespace: main + test: + enabled: true + parentRefs: + - name: test + namespace: test + asserts: + - hasDocuments: + count: 4 + - documentIndex: 0 + not: true + isKind: + of: HTTPRoute + - documentIndex: 1 + not: true + isKind: + of: HTTPRoute + - documentIndex: 2 + isKind: + of: HTTPRoute + - documentIndex: 3 + isKind: + of: HTTPRoute diff --git a/charts/other/app-template/tests/route/service_reference_test.yaml b/charts/other/app-template/tests/route/service_reference_test.yaml new file mode 100644 index 00000000..a3c74589 --- /dev/null +++ b/charts/other/app-template/tests/route/service_reference_test.yaml @@ -0,0 +1,54 @@ +suite: ingress service reference +templates: + - common.yaml +tests: + - it: default should pass + set: + route.main: + enabled: true + parentRefs: + - name: parentName + namespace: parentNamespace + asserts: + - documentIndex: &HTTPRouteDocument 2 + isKind: + of: HTTPRoute + - documentIndex: *HTTPRouteDocument + equal: + path: spec.rules[0].backendRefs[0] + value: + group: "" + kind: Service + name: RELEASE-NAME-main + namespace: NAMESPACE + port: null + weight: 1 + + - it: custom service reference should pass + set: + route.main: + enabled: true + parentRefs: + - name: parentName + namespace: parentNamespace + rules: + - backendRefs: + - group: test + name: pathService + port: 1234 + namespace: serviceNamespace + weight: 123 + asserts: + - documentIndex: &HTTPRouteDocument 2 + isKind: + of: HTTPRoute + - documentIndex: *HTTPRouteDocument + equal: + path: spec.rules[0].backendRefs[0] + value: + group: test + kind: Service + name: pathService + namespace: serviceNamespace + port: 1234 + weight: 123 diff --git a/charts/other/app-template/tests/route/values_test.yaml b/charts/other/app-template/tests/route/values_test.yaml new file mode 100644 index 00000000..1a655545 --- /dev/null +++ b/charts/other/app-template/tests/route/values_test.yaml @@ -0,0 +1,183 @@ +suite: route values +templates: + - common.yaml +tests: + - it: setting gateway should pass + set: + route.main: + enabled: true + parentRefs: + - name: parentName + namespace: parentNamespace + asserts: + - documentIndex: &HTTPRouteDocument 2 + isKind: + of: HTTPRoute + - documentIndex: *HTTPRouteDocument + equal: + path: spec.parentRefs[0].name + value: parentName + - documentIndex: *HTTPRouteDocument + equal: + path: spec.parentRefs[0].namespace + value: parentNamespace + + - it: custom host and path should pass + set: + route.main: + enabled: true + parentRefs: + - name: parentName + namespace: parentNamespace + hostnames: + - chart-test.local + asserts: + - documentIndex: &HTTPRouteDocument 2 + isKind: + of: HTTPRoute + - documentIndex: *HTTPRouteDocument + equal: + path: spec.hostnames[0] + value: chart-test.local + + - it: path matches should only be used for HTTPRoutes + set: + route: + main: + enabled: true + kind: HTTPRoute + parentRefs: + - name: parentName + namespace: parentNamespace + rules: + - backendRefs: + - name: test + namespace: test + matches: + - path: + type: PathPrefix + value: /test + grpc: + enabled: true + kind: GRPCRoute + parentRefs: + - name: parentName + namespace: parentNamespace + rules: + - backendRefs: + - name: test + namespace: test + matches: + - path: + type: PathPrefix + value: /test + tcp: + enabled: true + kind: TCPRoute + parentRefs: + - name: parentName + namespace: parentNamespace + rules: + - backendRefs: + - name: test + namespace: test + matches: + - path: + type: PathPrefix + value: /test + tls: + enabled: true + kind: TLSRoute + parentRefs: + - name: parentName + namespace: parentNamespace + rules: + - backendRefs: + - name: test + namespace: test + matches: + - path: + type: PathPrefix + value: /test + udp: + enabled: true + kind: UDPRoute + parentRefs: + - name: parentName + namespace: parentNamespace + rules: + - backendRefs: + - name: test + namespace: test + matches: + - path: + type: PathPrefix + value: /test + asserts: + - documentIndex: &HTTPRouteDocument 2 + isKind: + of: GRPCRoute + - documentIndex: &HTTPRouteDocument 2 + isNull: + path: spec.rules[0].matches + - documentIndex: &HTTPRouteDocument 3 + isKind: + of: HTTPRoute + - documentIndex: &HTTPRouteDocument 3 + equal: + path: spec.rules[0].matches + value: + - path: + type: PathPrefix + value: /test + - documentIndex: &HTTPRouteDocument 4 + isKind: + of: TCPRoute + - documentIndex: &HTTPRouteDocument 4 + isNull: + path: spec.rules[0].matches + - documentIndex: &HTTPRouteDocument 5 + isKind: + of: TLSRoute + - documentIndex: &HTTPRouteDocument 5 + isNull: + path: spec.rules[0].matches + - documentIndex: &HTTPRouteDocument 6 + isKind: + of: UDPRoute + - documentIndex: &HTTPRouteDocument 6 + isNull: + path: spec.rules[0].matches + + - it: hostnames shouldn't be used for TCPRoutes and UDPRoutes + set: + route: + main: + enabled: true + kind: TCPRoute + hostnames: + - chart-test.local + parentRefs: + - name: parentName + namespace: parentNamespace + udp: + enabled: true + kind: UDPRoute + hostnames: + - chart-test.local + parentRefs: + - name: parentName + namespace: parentNamespace + asserts: + - documentIndex: &HTTPRouteDocument 2 + isKind: + of: TCPRoute + - documentIndex: &HTTPRouteDocument 2 + isNull: + path: spec.hostnames + - documentIndex: &HTTPRouteDocument 3 + isKind: + of: UDPRoute + - documentIndex: &HTTPRouteDocument 3 + isNull: + path: spec.hostnames diff --git a/charts/other/app-template/tests/secret/metadata_test.yaml b/charts/other/app-template/tests/secret/metadata_test.yaml new file mode 100644 index 00000000..476e0900 --- /dev/null +++ b/charts/other/app-template/tests/secret/metadata_test.yaml @@ -0,0 +1,110 @@ +suite: secret metadata +templates: + - common.yaml +tests: + - it: default metadata should pass + set: + secrets: + secret: + enabled: true + asserts: + - hasDocuments: + count: 3 + - documentIndex: &SecretDocument 2 + isKind: + of: Secret + - documentIndex: *SecretDocument + isNull: + path: metadata.annotations + - documentIndex: *SecretDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: RELEASE-NAME + helm.sh/chart: app-template-1.1.0 + + - it: custom metadata should pass + set: + secrets: + secret: + enabled: true + annotations: + test_annotation: test + labels: + test_label: test + asserts: + - hasDocuments: + count: 3 + - documentIndex: &SecretDocument 2 + isKind: + of: Secret + - documentIndex: *SecretDocument + equal: + path: metadata.annotations + value: + test_annotation: test + - documentIndex: *SecretDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: RELEASE-NAME + helm.sh/chart: app-template-1.1.0 + test_label: test + + - it: custom metadata with global metadata should pass + set: + global: + labels: + global_label: test + annotations: + global_annotation: test + secrets: + secret: + enabled: true + annotations: + test_annotation: test + labels: + test_label: test + asserts: + - hasDocuments: + count: 3 + - documentIndex: &SecretDocument 2 + isKind: + of: Secret + - documentIndex: *SecretDocument + equal: + path: metadata.annotations + value: + global_annotation: test + test_annotation: test + - documentIndex: *SecretDocument + equal: + path: metadata.labels + value: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: RELEASE-NAME + global_label: test + helm.sh/chart: app-template-1.1.0 + test_label: test + + - it: custom secret type should pass + set: + secrets: + secret: + enabled: true + type: &type kubernetes.io/service-account-token + asserts: + - hasDocuments: + count: 3 + - documentIndex: &SecretDocument 2 + isKind: + of: Secret + - documentIndex: *SecretDocument + equal: + path: type + value: *type diff --git a/charts/other/app-template/tests/secret/names_test.yaml b/charts/other/app-template/tests/secret/names_test.yaml new file mode 100644 index 00000000..bdac6cd6 --- /dev/null +++ b/charts/other/app-template/tests/secret/names_test.yaml @@ -0,0 +1,91 @@ +suite: secret names +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: Secret + - documentIndex: 1 + not: true + isKind: + of: Secret + + - it: with disabled secret should pass + set: + secrets: + secret: + enabled: false + asserts: + - hasDocuments: + count: 2 + - documentIndex: 0 + not: true + isKind: + of: Secret + - documentIndex: 1 + not: true + isKind: + of: Secret + + - it: with multiple secrets should pass + set: + secrets: + secret: + enabled: true + data: + foo: bar + secondary: + enabled: true + asserts: + - hasDocuments: + count: 4 + - documentIndex: &FirstSecretDocument 2 + isKind: + of: Secret + - documentIndex: *FirstSecretDocument + isNotNull: + path: metadata.name + - documentIndex: &SecondSecretDocument 3 + isKind: + of: Secret + - documentIndex: *SecondSecretDocument + isNotNull: + path: metadata.name + + - it: default name should pass + set: + secrets: + secret: + enabled: true + asserts: + - hasDocuments: + count: 3 + - documentIndex: &SecretDocument 2 + isKind: + of: Secret + - documentIndex: *SecretDocument + equal: + path: metadata.name + value: RELEASE-NAME-secret + + - it: with nameOverride should pass + set: + secrets: + secret: + enabled: true + nameOverride: http + asserts: + - hasDocuments: + count: 3 + - documentIndex: &SecretDocument 2 + isKind: + of: Secret + - documentIndex: *SecretDocument + equal: + path: metadata.name + value: RELEASE-NAME-http diff --git a/charts/other/app-template/tests/service/metadata_test.yaml b/charts/other/app-template/tests/service/metadata_test.yaml index 58a44da6..094df61e 100644 --- a/charts/other/app-template/tests/service/metadata_test.yaml +++ b/charts/other/app-template/tests/service/metadata_test.yaml @@ -18,7 +18,7 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 - it: custom metadata should pass set: @@ -45,7 +45,7 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test - it: custom metadata with global metadata should pass @@ -80,5 +80,5 @@ tests: app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.0.1 + helm.sh/chart: app-template-1.1.0 test_label: test diff --git a/charts/other/app-template/tests/service/values_test.yaml b/charts/other/app-template/tests/service/values_test.yaml index b7edd82f..e23af99f 100644 --- a/charts/other/app-template/tests/service/values_test.yaml +++ b/charts/other/app-template/tests/service/values_test.yaml @@ -2,6 +2,24 @@ suite: service values templates: - common.yaml tests: + - it: ports and services are enabled by default + set: + service: + second: + type: ClusterIP + ports: + first: + port: 80 + asserts: + - hasDocuments: + count: 3 + - documentIndex: &FirstServiceDocument 1 + isKind: + of: Service + - documentIndex: &SecondServiceDocument 2 + isKind: + of: Service + - it: externalTrafficPolicy should pass for NodePort service set: service: diff --git a/charts/other/app-template/tests/serviceAccount/serviceaccount_test.yaml b/charts/other/app-template/tests/serviceAccount/serviceaccount_test.yaml new file mode 100644 index 00000000..bb3d532a --- /dev/null +++ b/charts/other/app-template/tests/serviceAccount/serviceaccount_test.yaml @@ -0,0 +1,95 @@ +suite: serviceAccount values +templates: + - common.yaml +tests: + - it: a serviceAccount is not created by default + asserts: + - hasDocuments: + count: 2 + - documentIndex: &DeploymentDocument 0 + isKind: + of: Deployment + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + + - it: a serviceAccount is not created when disabled + set: + serviceAccount: + create: false + asserts: + - hasDocuments: + count: 2 + - documentIndex: &DeploymentDocument 0 + isKind: + of: Deployment + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + + - it: a serviceAccount and Secret are created when enabled + set: + serviceAccount: + create: true + asserts: + - hasDocuments: + count: 4 + - documentIndex: &ServiceAccountDocument 0 + isKind: + of: ServiceAccount + - documentIndex: &DeploymentDocument 1 + isKind: + of: Deployment + - documentIndex: &ServiceDocument 2 + isKind: + of: Service + - documentIndex: &SecretDocument 3 + isKind: + of: Secret + - documentIndex: *ServiceAccountDocument + equal: + path: metadata.name + value: &ServiceAccountName RELEASE-NAME + - documentIndex: *ServiceAccountDocument + equal: + path: secrets + value: + - name: RELEASE-NAME-sa-token + - documentIndex: *DeploymentDocument + equal: + path: spec.template.spec.serviceAccountName + value: *ServiceAccountName + + - it: a serviceAccount and Secret are created with custom name + set: + serviceAccount: + create: true + name: &ServiceAccountName myAccount + asserts: + - hasDocuments: + count: 4 + - documentIndex: &ServiceAccountDocument 0 + isKind: + of: ServiceAccount + - documentIndex: &DeploymentDocument 1 + isKind: + of: Deployment + - documentIndex: &ServiceDocument 2 + isKind: + of: Service + - documentIndex: &SecretDocument 3 + isKind: + of: Secret + - documentIndex: *ServiceAccountDocument + equal: + path: metadata.name + value: *ServiceAccountName + - documentIndex: *ServiceAccountDocument + equal: + path: secrets + value: + - name: RELEASE-NAME-sa-token + - documentIndex: *DeploymentDocument + equal: + path: spec.template.spec.serviceAccountName + value: *ServiceAccountName