From 5421846c1fea2f5f217dc0490c90d3661354064e Mon Sep 17 00:00:00 2001 From: Julien Cabillot Date: Wed, 29 Dec 2021 16:21:53 -0500 Subject: [PATCH] first import --- charts/cv/.helmignore | 26 + charts/cv/Chart.yaml | 33 + charts/cv/README.md | 160 ++++ charts/cv/README.md.gotmpl | 146 ++++ charts/cv/README_CHANGELOG.md.gotmpl | 56 ++ charts/cv/README_CONFIG.md.gotmpl | 9 + .../cv/charts/helm-library-common/.helmignore | 28 + .../cv/charts/helm-library-common/Chart.yaml | 19 + .../cv/charts/helm-library-common/README.md | 485 ++++++++++++ .../helm-library-common/README.md.gotmpl | 99 +++ .../README_CHANGELOG.md.gotmpl | 262 +++++++ .../README_CONFIG.md.gotmpl | 29 + .../helm-library-common/templates/_all.tpl | 58 ++ .../templates/_configmap.tpl | 19 + .../templates/_daemonset.tpl | 38 + .../templates/_deployment.tpl | 56 ++ .../templates/_ingress.tpl | 39 + .../helm-library-common/templates/_notes.tpl | 56 ++ .../helm-library-common/templates/_pvc.tpl | 16 + .../helm-library-common/templates/_secret.tpl | 17 + .../templates/_service.tpl | 43 ++ .../templates/_serviceaccount.tpl | 16 + .../templates/_statefulset.tpl | 64 ++ .../addons/code-server/_codeserver.tpl | 50 ++ .../addons/code-server/_container.tpl | 46 ++ .../templates/addons/code-server/_secret.tpl | 22 + .../templates/addons/code-server/_volume.tpl | 17 + .../templates/addons/netshoot/_container.tpl | 27 + .../templates/addons/netshoot/_netshoot.tpl | 13 + .../templates/addons/promtail/_configmap.tpl | 35 + .../templates/addons/promtail/_container.tpl | 39 + .../templates/addons/promtail/_promtail.tpl | 25 + .../templates/addons/promtail/_volume.tpl | 7 + .../templates/addons/vpn/_configmap.tpl | 23 + .../templates/addons/vpn/_networkpolicy.tpl | 33 + .../templates/addons/vpn/_secret.tpl | 19 + .../templates/addons/vpn/_volume.tpl | 37 + .../templates/addons/vpn/_vpn.tpl | 45 ++ .../templates/addons/vpn/openvpn/_addon.tpl | 17 + .../addons/vpn/openvpn/_container.tpl | 61 ++ .../templates/addons/vpn/openvpn/_secret.tpl | 16 + .../templates/addons/vpn/wireguard/_addon.tpl | 11 + .../addons/vpn/wireguard/_container.tpl | 52 ++ .../classes/_HorizontalPodAutoscaler.tpl | 37 + .../templates/classes/_configmap.tpl | 37 + .../templates/classes/_ingress.tpl | 85 +++ .../templates/classes/_pvc.tpl | 49 ++ .../templates/classes/_service.tpl | 100 +++ .../templates/classes/_service_ports.tpl | 27 + .../templates/lib/chart/_capabilities.tpl | 19 + .../templates/lib/chart/_labels.tpl | 15 + .../templates/lib/chart/_names.tpl | 58 ++ .../templates/lib/chart/_values.tpl | 9 + .../templates/lib/controller/_container.tpl | 84 +++ .../templates/lib/controller/_pod.tpl | 90 +++ .../templates/lib/controller/_ports.tpl | 36 + .../templates/lib/controller/_probes.tpl | 33 + .../lib/controller/_volumemounts.tpl | 56 ++ .../templates/lib/controller/_volumes.tpl | 64 ++ .../tests/addon_codeserver_test.go | 136 ++++ .../tests/addon_netshoot_test.go | 64 ++ .../tests/addon_vpn_test.go | 129 ++++ .../tests/configmap_test.go | 98 +++ .../tests/container_test.go | 304 ++++++++ .../tests/controller_test.go | 59 ++ .../tests/horizontal_pod_autoscaler_test.go | 107 +++ .../helm-library-common/tests/ingress_test.go | 222 ++++++ .../tests/persistentvolumeclaim_test.go | 166 ++++ .../helm-library-common/tests/pod_test.go | 386 ++++++++++ .../helm-library-common/tests/service_test.go | 138 ++++ .../cv/charts/helm-library-common/values.yaml | 707 ++++++++++++++++++ charts/cv/templates/NOTES.txt | 1 + charts/cv/templates/common.yaml | 5 + charts/cv/values.yaml | 40 + 74 files changed, 5730 insertions(+) create mode 100644 charts/cv/.helmignore create mode 100644 charts/cv/Chart.yaml create mode 100644 charts/cv/README.md create mode 100644 charts/cv/README.md.gotmpl create mode 100644 charts/cv/README_CHANGELOG.md.gotmpl create mode 100644 charts/cv/README_CONFIG.md.gotmpl create mode 100644 charts/cv/charts/helm-library-common/.helmignore create mode 100644 charts/cv/charts/helm-library-common/Chart.yaml create mode 100644 charts/cv/charts/helm-library-common/README.md create mode 100644 charts/cv/charts/helm-library-common/README.md.gotmpl create mode 100644 charts/cv/charts/helm-library-common/README_CHANGELOG.md.gotmpl create mode 100644 charts/cv/charts/helm-library-common/README_CONFIG.md.gotmpl create mode 100644 charts/cv/charts/helm-library-common/templates/_all.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_configmap.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_daemonset.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_deployment.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_ingress.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_notes.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_pvc.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_secret.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_service.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_serviceaccount.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/_statefulset.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/code-server/_codeserver.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/code-server/_container.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/code-server/_secret.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/code-server/_volume.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/netshoot/_container.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/netshoot/_netshoot.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/promtail/_configmap.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/promtail/_container.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/promtail/_promtail.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/promtail/_volume.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/_configmap.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/_networkpolicy.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/_secret.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/_volume.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/_vpn.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_addon.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_container.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_secret.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/wireguard/_addon.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/addons/vpn/wireguard/_container.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/classes/_HorizontalPodAutoscaler.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/classes/_configmap.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/classes/_ingress.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/classes/_pvc.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/classes/_service.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/classes/_service_ports.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/chart/_capabilities.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/chart/_labels.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/chart/_names.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/chart/_values.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/controller/_container.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/controller/_pod.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/controller/_ports.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/controller/_probes.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/controller/_volumemounts.tpl create mode 100644 charts/cv/charts/helm-library-common/templates/lib/controller/_volumes.tpl create mode 100644 charts/cv/charts/helm-library-common/tests/addon_codeserver_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/addon_netshoot_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/addon_vpn_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/configmap_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/container_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/controller_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/horizontal_pod_autoscaler_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/ingress_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/persistentvolumeclaim_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/pod_test.go create mode 100644 charts/cv/charts/helm-library-common/tests/service_test.go create mode 100644 charts/cv/charts/helm-library-common/values.yaml create mode 100644 charts/cv/templates/NOTES.txt create mode 100644 charts/cv/templates/common.yaml create mode 100644 charts/cv/values.yaml diff --git a/charts/cv/.helmignore b/charts/cv/.helmignore new file mode 100644 index 0000000..4379e2b --- /dev/null +++ b/charts/cv/.helmignore @@ -0,0 +1,26 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +# OWNERS file for Kubernetes +OWNERS +# helm-docs templates +*.gotmpl diff --git a/charts/cv/Chart.yaml b/charts/cv/Chart.yaml new file mode 100644 index 0000000..2f56916 --- /dev/null +++ b/charts/cv/Chart.yaml @@ -0,0 +1,33 @@ +apiVersion: v2 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +#appVersion: "1.16.0" +appVersion: "latest" + +description: Helm chart for cv +name: cv +version: 0.0.1 +kubeVersion: ">=1.16.0-0" +keywords: +- cv +#TODO: +home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/lidarr +#TODO: +icon: https://github.com/lidarr/Lidarr/blob/develop/Logo/512.png?raw=true +#TODO: +sources: +- https://github.com/Lidarr/Lidarr +- https://github.com/k8s-at-home/container-images +maintainers: +- name: jcabillot + # TODO: + email: todo@todo +dependencies: +- name: helm-library-common + #TODO: pas de helm repository = pas de partage + #repository: https://library-charts.k8s-at-home.com + repository: "file://charts/helm-library-common" + version: 4.2.0 diff --git a/charts/cv/README.md b/charts/cv/README.md new file mode 100644 index 0000000..ec1e9ff --- /dev/null +++ b/charts/cv/README.md @@ -0,0 +1,160 @@ +# lidarr + +![Version: 13.1.1](https://img.shields.io/badge/Version-13.1.1-informational?style=flat-square) ![AppVersion: v1.0.0.2255](https://img.shields.io/badge/AppVersion-v1.0.0.2255-informational?style=flat-square) + +Looks and smells like Sonarr but made for music + +**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)** + +## Source Code + +* +* + +## Requirements + +Kubernetes: `>=1.16.0-0` + +## Dependencies + +| Repository | Name | Version | +|------------|------|---------| +| https://library-charts.k8s-at-home.com | common | 4.2.0 | + +## TL;DR + +```console +helm repo add k8s-at-home https://k8s-at-home.com/charts/ +helm repo update +helm install lidarr k8s-at-home/lidarr +``` + +## Installing the Chart + +To install the chart with the release name `lidarr` + +```console +helm install lidarr k8s-at-home/lidarr +``` + +## Uninstalling the Chart + +To uninstall the `lidarr` deployment + +```console +helm uninstall lidarr +``` + +The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release. + +## Configuration + +Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values. +Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common). + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +```console +helm install lidarr \ + --set env.TZ="America/New York" \ + k8s-at-home/lidarr +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. + +```console +helm install lidarr k8s-at-home/lidarr -f values.yaml +``` + +## Custom configuration + +N/A + +## Values + +**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common) + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| env | object | See below | environment variables. | +| env.TZ | string | `"UTC"` | Set the container timezone | +| image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| image.repository | string | `"ghcr.io/k8s-at-home/lidarr"` | image repository | +| image.tag | string | `"v1.0.0.2255"` | image tag | +| ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | +| metrics.enabled | bool | See values.yaml | Enable and configure Exportarr sidecar and Prometheus serviceMonitor. | +| metrics.exporter.env.additionalMetrics | bool | `false` | Set to true to enable gathering of additional metrics (slow) | +| metrics.exporter.env.port | int | `9792` | metrics port | +| metrics.exporter.env.unknownQueueItems | bool | `false` | Set to true to enable gathering unknown queue items | +| metrics.exporter.image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| metrics.exporter.image.repository | string | `"ghcr.io/onedr0p/exportarr"` | image repository | +| metrics.exporter.image.tag | string | `"v0.6.2"` | image tag | +| metrics.prometheusRule | object | See values.yaml | Enable and configure Prometheus Rules for the chart under this key. | +| metrics.prometheusRule.rules | list | See prometheusrules.yaml | Configure additionial rules for the chart under this key. | +| metrics.serviceMonitor.interval | string | `"3m"` | | +| metrics.serviceMonitor.labels | object | `{}` | | +| metrics.serviceMonitor.scrapeTimeout | string | `"1m"` | | +| persistence | object | See values.yaml | Configure persistence settings for the chart under this key. | +| probes | object | See values.yaml | Configures the probes for the main Pod. | +| service | object | See values.yaml | Configures service settings for the chart. | + +## Changelog + +All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common#changelog). + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +### [13.0.0] + +#### Changed + +- **BREAKING**: Refactored Prometheus metrics section to add rules. Enabling metrics automatically enables the serviceMonitor and exporter sidecar. + +### [12.0.0] + +#### Changed + +- Refactoring of the Exportarr sidecar and Prometheus podMonitor. This is a breaking change if it was enabled previously. + +### [11.0.0] + +#### Changed + +- Upgraded the common library dependency to version 4.0.0. This introduced (potentially) breaking changes to `initContainers` and `additionalContainers`. Be sure to check out the [library chart](https://github.com/k8s-at-home/library-charts/blob/common-4.0.0/charts/stable/common/) for the up-to-date values. + +### [10.0.0] + +#### Changed + +- **BREAKING**: Upgraded the common library dependency to version 3.0.2. This introduces several breaking changes (`service`, `ingress` and `persistence` keys have been refactored). + Be sure to check out the [library chart](https://github.com/k8s-at-home/library-charts/blob/common-3.0.2/charts/stable/common/) for the up-to-date values. +- Changed image tag to `v1.0.0.2226`. + +### [9.0.0] + +#### Changed + +- **Breaking**: swap linuxserver.io images for k8s@home image + +### [1.0.0] + +#### Added + +- Initial version + +[13.0.0]: #1300 +[12.0.0]: #1200 +[11.0.0]: #1100 +[10.0.0]: #1000 +[9.0.0]: #900 +[1.0.0]: #100 + +## Support + +- See the [Docs](https://docs.k8s-at-home.com/our-helm-charts/getting-started/) +- Open an [issue](https://github.com/k8s-at-home/charts/issues/new/choose) +- Ask a [question](https://github.com/k8s-at-home/organization/discussions) +- Join our [Discord](https://discord.gg/sTMX7Vh) community + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) diff --git a/charts/cv/README.md.gotmpl b/charts/cv/README.md.gotmpl new file mode 100644 index 0000000..358abe3 --- /dev/null +++ b/charts/cv/README.md.gotmpl @@ -0,0 +1,146 @@ +{{- define "custom.repository.organization" -}} +k8s-at-home +{{- end -}} + +{{- define "custom.repository.url" -}} +https://github.com/k8s-at-home/charts +{{- end -}} + +{{- define "custom.helm.url" -}} +https://k8s-at-home.com/charts/ +{{- end -}} + +{{- define "custom.helm.path" -}} +{{ template "custom.repository.organization" . }}/{{ template "chart.name" . }} +{{- end -}} + +{{- define "custom.notes" -}} +**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)** +{{- end -}} + +{{- define "custom.requirements" -}} +## Requirements + +{{ template "chart.kubeVersionLine" . }} +{{- end -}} + +{{- define "custom.dependencies" -}} +## Dependencies + +{{ template "chart.requirementsTable" . }} +{{- end -}} + +{{- define "custom.install.tldr" -}} +## TL;DR + +```console +helm repo add {{ template "custom.repository.organization" . }} {{ template "custom.helm.url" . }} +helm repo update +helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} +``` +{{- end -}} + +{{- define "custom.install" -}} +## Installing the Chart + +To install the chart with the release name `{{ template "chart.name" . }}` + +```console +helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} +``` +{{- end -}} + +{{- define "custom.uninstall" -}} +## Uninstalling the Chart + +To uninstall the `{{ template "chart.name" . }}` deployment + +```console +helm uninstall {{ template "chart.name" . }} +``` + +The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release. +{{- end -}} + +{{- define "custom.configuration.header" -}} +## Configuration +{{- end -}} + +{{- define "custom.configuration.readValues" -}} +Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values. +Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common). +{{- end -}} + +{{- define "custom.configuration.example.set" -}} +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +```console +helm install {{ template "chart.name" . }} \ + --set env.TZ="America/New York" \ + {{ template "custom.helm.path" . }} +``` +{{- end -}} + +{{- define "custom.configuration.example.file" -}} +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. + +```console +helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} -f values.yaml +``` +{{- end -}} + +{{- define "custom.valuesSection" -}} +## Values + +**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common) + +{{ template "chart.valuesTable" . }} +{{- end -}} + +{{- define "custom.support" -}} +## Support + +- See the [Docs](https://docs.k8s-at-home.com/our-helm-charts/getting-started/) +- Open an [issue](https://github.com/k8s-at-home/charts/issues/new/choose) +- Ask a [question](https://github.com/k8s-at-home/organization/discussions) +- Join our [Discord](https://discord.gg/sTMX7Vh) community +{{- end -}} + +{{ template "chart.header" . }} + +{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} + +{{ template "chart.description" . }} + +{{ template "custom.notes" . }} + +{{ template "chart.sourcesSection" . }} + +{{ template "custom.requirements" . }} + +{{ template "custom.dependencies" . }} + +{{ template "custom.install.tldr" . }} + +{{ template "custom.install" . }} + +{{ template "custom.uninstall" . }} + +{{ template "custom.configuration.header" . }} + +{{ template "custom.configuration.readValues" . }} + +{{ template "custom.configuration.example.set" . }} + +{{ template "custom.configuration.example.file" . }} + +{{ template "custom.custom.configuration" . }} + +{{ template "custom.valuesSection" . }} + +{{ template "custom.changelog" . }} + +{{ template "custom.support" . }} + +{{ template "helm-docs.versionFooter" . }} +{{ "" }} diff --git a/charts/cv/README_CHANGELOG.md.gotmpl b/charts/cv/README_CHANGELOG.md.gotmpl new file mode 100644 index 0000000..05b0de4 --- /dev/null +++ b/charts/cv/README_CHANGELOG.md.gotmpl @@ -0,0 +1,56 @@ +{{- define "custom.changelog.header" -}} +## Changelog +{{- end -}} + +{{- define "custom.changelog" -}} +{{ template "custom.changelog.header" . }} + +All notable changes to this application Helm chart will be documented in this file but does not include changes from our common library. To read those click [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common#changelog). + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +### [13.0.0] + +#### Changed + +- **BREAKING**: Refactored Prometheus metrics section to add rules. Enabling metrics automatically enables the serviceMonitor and exporter sidecar. + +### [12.0.0] + +#### Changed + +- Refactoring of the Exportarr sidecar and Prometheus podMonitor. This is a breaking change if it was enabled previously. + +### [11.0.0] + +#### Changed + +- Upgraded the common library dependency to version 4.0.0. This introduced (potentially) breaking changes to `initContainers` and `additionalContainers`. Be sure to check out the [library chart](https://github.com/k8s-at-home/library-charts/blob/common-4.0.0/charts/stable/common/) for the up-to-date values. + +### [10.0.0] + +#### Changed + +- **BREAKING**: Upgraded the common library dependency to version 3.0.2. This introduces several breaking changes (`service`, `ingress` and `persistence` keys have been refactored). + Be sure to check out the [library chart](https://github.com/k8s-at-home/library-charts/blob/common-3.0.2/charts/stable/common/) for the up-to-date values. +- Changed image tag to `v1.0.0.2226`. + +### [9.0.0] + +#### Changed + +- **Breaking**: swap linuxserver.io images for k8s@home image + +### [1.0.0] + +#### Added + +- Initial version + +[13.0.0]: #1300 +[12.0.0]: #1200 +[11.0.0]: #1100 +[10.0.0]: #1000 +[9.0.0]: #900 +[1.0.0]: #100 +{{- end -}} diff --git a/charts/cv/README_CONFIG.md.gotmpl b/charts/cv/README_CONFIG.md.gotmpl new file mode 100644 index 0000000..e93d80b --- /dev/null +++ b/charts/cv/README_CONFIG.md.gotmpl @@ -0,0 +1,9 @@ +{{- define "custom.custom.configuration.header" -}} +## Custom configuration +{{- end -}} + +{{- define "custom.custom.configuration" -}} +{{ template "custom.custom.configuration.header" . }} + +N/A +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/.helmignore b/charts/cv/charts/helm-library-common/.helmignore new file mode 100644 index 0000000..c62cbf8 --- /dev/null +++ b/charts/cv/charts/helm-library-common/.helmignore @@ -0,0 +1,28 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +# OWNERS file for Kubernetes +OWNERS +# helm-docs templates +*.gotmpl +# Test files +tests/ diff --git a/charts/cv/charts/helm-library-common/Chart.yaml b/charts/cv/charts/helm-library-common/Chart.yaml new file mode 100644 index 0000000..5c797ab --- /dev/null +++ b/charts/cv/charts/helm-library-common/Chart.yaml @@ -0,0 +1,19 @@ +apiVersion: v2 +name: helm-library-common +description: Function library for k8s-at-home charts +type: library +version: 4.2.0 +kubeVersion: ">=1.16.0-0" +keywords: + - k8s-at-home + - common +home: https://github.com/k8s-at-home/library-charts/tree/main/stable/common +maintainers: + - name: bjw-s + email: me@bjw-s.dev + - name: onedr0p + email: devin.kray@gmail.com + - name: nicholaswilde + email: ncwilde43@gmail.com + - name: dirtycajunrice + email: nick@cajun.pro diff --git a/charts/cv/charts/helm-library-common/README.md b/charts/cv/charts/helm-library-common/README.md new file mode 100644 index 0000000..a5a1ffb --- /dev/null +++ b/charts/cv/charts/helm-library-common/README.md @@ -0,0 +1,485 @@ +# common + +![Version: 4.2.0](https://img.shields.io/badge/Version-4.2.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) + +Function library for k8s-at-home charts + +Since a lot of the k8s-at-home charts follow a similar pattern, this library was built to reduce maintenance cost between the charts that use it and try achieve a goal of being DRY. + +## Requirements + +Kubernetes: `>=1.16.0-0` + +## Dependencies + +| Repository | Name | Version | +|------------|------|---------| + +## Installing the Chart + +This is a [Helm Library Chart](https://helm.sh/docs/topics/library_charts/#helm). + +**WARNING: THIS CHART IS NOT MEANT TO BE INSTALLED DIRECTLY** + +## Using this library + +Include this chart as a dependency in your `Chart.yaml` e.g. + +```yaml +# Chart.yaml +dependencies: +- name: common + version: 3.0.0 + repository: https://k8s-at-home.com/charts/ +``` + +For more information, take a look at the [Docs](http://docs.k8s-at-home.com/our-helm-charts/common-library/). + +## Configuration + +Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values. + +## Custom configuration + +N/A + +## Values + +**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common) + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| additionalContainers | object | `{}` | Specify any additional containers here as dictionary items. Each additional container should have its own key. Helm templates can be used. | +| addons | object | See below | The common chart supports several add-ons. These can be configured under this key. | +| addons.codeserver | object | See values.yaml | The common library supports adding a code-server add-on to access files. It can be configured under this key. For more info, check out [our docs](http://docs.k8s-at-home.com/our-helm-charts/common-library-add-ons/#code-server) | +| addons.codeserver.args | list | `["--auth","none"]` | Set codeserver command line arguments. Consider setting --user-data-dir to a persistent location to preserve code-server setting changes | +| addons.codeserver.enabled | bool | `false` | Enable running a code-server container in the pod | +| addons.codeserver.env | object | `{}` | Set any environment variables for code-server here | +| addons.codeserver.git | object | See below | Optionally allow access a Git repository by passing in a private SSH key | +| addons.codeserver.git.deployKey | string | `""` | Raw SSH private key | +| addons.codeserver.git.deployKeyBase64 | string | `""` | Base64-encoded SSH private key. When both variables are set, the raw SSH key takes precedence. | +| 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 | `"codercom/code-server"` | Specify the code-server image | +| addons.codeserver.image.tag | string | `"3.9.2"` | Specify the code-server image tag | +| addons.codeserver.ingress.enabled | bool | `false` | Enable an ingress for the code-server add-on. | +| addons.codeserver.service.enabled | bool | `true` | Enable a service for the code-server add-on. | +| addons.codeserver.service.ipFamilies | list | `["IPv4"]` | The ip families that should be used. Options: IPv4, IPv6 | +| addons.codeserver.service.ipFamilyPolicy | string | `"SingleStack"` | Specify the ip policy. Options: SingleStack, PreferDualStack, RequireDualStack | +| addons.codeserver.volumeMounts | list | `[]` | Specify a list of volumes that get mounted in the code-server container. At least 1 volumeMount is required! | +| addons.codeserver.workingDir | string | `""` | Specify the working dir that will be opened when code-server starts If not given, the app will default to the mountpah of the first specified volumeMount | +| addons.netshoot | object | See values.yaml | The common library supports adding a netshoot add-on to troubleshoot network issues within a Pod. It can be configured under this key. | +| addons.netshoot.enabled | bool | `false` | Enable running a netshoot container in the pod | +| addons.netshoot.env | object | `{}` | Set any environment variables for netshoot here | +| addons.netshoot.image.pullPolicy | string | `"Always"` | Specify the netshoot image pull policy | +| addons.netshoot.image.repository | string | `"nicolaka/netshoot"` | Specify the netshoot image | +| addons.netshoot.image.tag | string | `"latest"` | 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 | `"grafana/promtail"` | Specify the promtail image | +| addons.promtail.image.tag | string | `"2.2.0"` | 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.vpn | object | See values.yaml | The common chart supports adding a VPN add-on. It can be configured under this key. For more info, check out [our docs](http://docs.k8s-at-home.com/our-helm-charts/common-library-add-ons/#wireguard-vpn) | +| 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.livenessProbe | object | `{}` | Optionally specify a livenessProbe, e.g. to check if the connection is still being protected by the VPN | +| addons.vpn.networkPolicy.annotations | object | `{}` | Provide additional annotations which may be required. | +| addons.vpn.networkPolicy.egress | string | `nil` | The egress configuration for your network policy, All outbound traffic from the pod will be blocked unless specified here. [[ref]](https://kubernetes.io/docs/concepts/services-networking/network-policies/) [[recipes]](https://github.com/ahmetb/kubernetes-network-policy-recipes) | +| addons.vpn.networkPolicy.enabled | bool | `false` | If set to true, will deploy a network policy that blocks all outbound traffic except traffic specified as allowed | +| addons.vpn.networkPolicy.labels | object | `{}` | Provide additional labels which may be required. | +| addons.vpn.networkPolicy.podSelectorLabels | object | `{}` | Provide additional podSelector labels which may be required. | +| addons.vpn.openvpn | object | See below | OpenVPN specific configuration | +| addons.vpn.openvpn.auth | string | `nil` | Credentials to connect to the VPN Service (used with -a) | +| addons.vpn.openvpn.authSecret | string | `nil` | Optionally specify an existing secret that contains the credentials. Credentials should be stored under the `VPN_AUTH` key | +| addons.vpn.openvpn.image.pullPolicy | string | `"IfNotPresent"` | Specify the openvpn client image pull policy | +| addons.vpn.openvpn.image.repository | string | `"dperson/openvpn-client"` | Specify the openvpn client image | +| addons.vpn.openvpn.image.tag | string | `"latest"` | Specify the openvpn client image tag | +| addons.vpn.scripts | object | See values.yaml | Provide custom up/down scripts that can be used by the vpn configuration. | +| addons.vpn.securityContext | object | See values.yaml | Set the VPN container securityContext | +| addons.vpn.type | string | `"openvpn"` | Specify the VPN type. Valid options are openvpn or wireguard | +| addons.vpn.wireguard | object | See below | WireGuard specific configuration | +| addons.vpn.wireguard.image.pullPolicy | string | `"IfNotPresent"` | Specify the WireGuard image pull policy | +| addons.vpn.wireguard.image.repository | string | `"ghcr.io/k8s-at-home/wireguard"` | Specify the WireGuard image | +| addons.vpn.wireguard.image.tag | string | `"v1.0.20210914"` | Specify the WireGuard image tag | +| affinity | object | `{}` | Defines affinity constraint rules. [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) | +| args | list | `[]` | Override the args for the default container | +| automountServiceAccountToken | bool | `true` | Specifies whether a service account token should be automatically mounted. | +| autoscaling | object | | Add a Horizontal Pod Autoscaler | +| command | list | `[]` | Override the command(s) for the default container | +| configmap | object | See below | Configure configMaps for the chart here. Additional configMaps can be added by adding a dictionary key similar to the 'config' object. | +| configmap.config.annotations | object | `{}` | Annotations to add to the configMap | +| configmap.config.data | object | `{}` | configMap data content. Helm template enabled. | +| configmap.config.enabled | bool | `false` | Enables or disables the configMap | +| configmap.config.labels | object | `{}` | Labels to add to the configMap | +| controller.annotations | object | `{}` | Set annotations on the deployment/statefulset/daemonset | +| controller.enabled | bool | `true` | enable the controller. | +| controller.labels | object | `{}` | Set labels on the deployment/statefulset/daemonset | +| controller.replicas | int | `1` | Number of desired pods | +| 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 | +| 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) | +| env | string | `nil` | Main environment variables. Template enabled. Syntax options: A) TZ: UTC B) PASSWD: '{{ .Release.Name }}' C) PASSWD: envFrom: ... D) - name: TZ value: UTC E) - name: TZ value: '{{ .Release.Name }}' | +| global.fullnameOverride | string | `nil` | Set the entire name definition | +| global.nameOverride | string | `nil` | Set an override for the prefix of the fullname | +| hostAliases | list | `[]` | Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. [[ref]](https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/) | +| hostNetwork | bool | `false` | When using hostNetwork make sure you set dnsPolicy to `ClusterFirstWithHostNet` | +| hostname | string | `nil` | Allows specifying explicit hostname setting | +| image.pullPolicy | string | `nil` | image pull policy | +| image.repository | string | `nil` | image repository | +| image.tag | string | `nil` | image tag | +| ingress | object | See below | Configure the ingresses for the chart here. Additional ingresses can be added by adding a dictionary key similar to the 'main' ingress. | +| ingress.main.annotations | object | `{}` | Provide additional annotations which may be required. | +| ingress.main.enabled | bool | `false` | Enables or disables the ingress | +| ingress.main.hosts[0].host | string | `"chart-example.local"` | Host address. Helm template can be passed. | +| ingress.main.hosts[0].paths[0].path | string | `"/"` | Path. Helm template can be passed. | +| ingress.main.hosts[0].paths[0].pathType | string | `"Prefix"` | Ignored if not kubeVersion >= 1.14-0 | +| ingress.main.hosts[0].paths[0].service.name | string | `nil` | Overrides the service name reference for this path | +| ingress.main.hosts[0].paths[0].service.port | string | `nil` | Overrides the service port reference for this path | +| ingress.main.ingressClassName | string | `nil` | Set the ingressClass that is used for this ingress. Requires Kubernetes >=1.19 | +| ingress.main.labels | object | `{}` | Provide additional labels which may be required. | +| ingress.main.nameOverride | string | `nil` | Override the name suffix that is used for this ingress. | +| ingress.main.primary | bool | `true` | Make this the primary ingress (used in probes, notes, etc...). If there is more than 1 ingress, make sure that only 1 ingress is marked as primary. | +| ingress.main.tls | list | `[]` | Configure TLS for the ingress. Both secretName and hosts can process a Helm template. | +| initContainers | object | `{}` | Specify any initContainers here as dictionary items. Each initContainer should have its own key. The dictionary item key will determine the order. Helm templates can be used. | +| lifecycle | object | `{}` | Configure the lifecycle for the main container | +| nodeSelector | object | `{}` | Node selection constraint [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) | +| persistence | object | See below | Configure persistence for the chart here. Additional items can be added by adding a dictionary key similar to the 'config' key. [[ref]](http://docs.k8s-at-home.com/our-helm-charts/common-library-storage) | +| persistence.config | object | See below | Default persistence for configuration files. | +| persistence.config.accessMode | string | `"ReadWriteOnce"` | AccessMode for the persistent volume. Make sure to select an access mode that is supported by your storage provider! [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) | +| persistence.config.enabled | bool | `false` | Enables or disables the persistence item | +| persistence.config.existingClaim | string | `nil` | If you want to reuse an existing claim, the name of the existing PVC can be passed here. | +| persistence.config.mountPath | string | `nil` | Where to mount the volume in the main container. Defaults to `/`, setting to '-' creates the volume but disables the volumeMount. | +| persistence.config.nameOverride | string | `nil` | Override the name suffix that is used for this volume. | +| persistence.config.readOnly | bool | `false` | Specify if the volume should be mounted read-only. | +| persistence.config.retain | bool | `false` | Set to true to retain the PVC upon `helm uninstall` | +| persistence.config.size | string | `"1Gi"` | The amount of storage that is requested for the persistent volume. | +| persistence.config.storageClass | string | `nil` | Storage Class for the config volume. If set to `-`, dynamic provisioning is disabled. If set to something else, the given storageClass is used. If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. | +| persistence.config.subPath | string | `nil` | Used in conjunction with `existingClaim`. Specifies a sub-path inside the referenced volume instead of its root | +| persistence.config.type | string | `"pvc"` | Sets the persistence type Valid options are pvc, emptyDir, hostPath, secret, configMap or custom | +| persistence.shared | object | See below | Create an emptyDir volume to share between all containers [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) | +| persistence.shared.medium | string | `nil` | Set the medium to "Memory" to mount a tmpfs (RAM-backed filesystem) instead of the storage medium that backs the node. | +| persistence.shared.sizeLimit | string | `nil` | If the `SizeMemoryBackedVolumes` feature gate is enabled, you can specify a size for memory backed volumes. | +| podAnnotations | object | `{}` | Set annotations on the pod | +| 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.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 | +| probes.liveness.spec | object | See below | The spec field contains the values for the default livenessProbe. If you selected `custom: true`, this field holds the definition of the livenessProbe. | +| probes.readiness | object | See below | Redainess probe configuration | +| probes.readiness.custom | bool | `false` | Set this to `true` if you wish to specify your own readinessProbe | +| probes.readiness.enabled | bool | `true` | Enable the readiness probe | +| probes.readiness.spec | object | See below | The spec field contains the values for the default readinessProbe. If you selected `custom: true`, this field holds the definition of the readinessProbe. | +| probes.startup | object | See below | Startup probe configuration | +| probes.startup.custom | bool | `false` | Set this to `true` if you wish to specify your own startupProbe | +| probes.startup.enabled | bool | `true` | Enable the startup probe | +| 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. | +| resources | object | `{}` | Set the resource requests / limits for the main container. | +| schedulerName | string | `nil` | Allows specifying a custom scheduler name | +| secret | object | `{}` | Use this to populate a secret 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. | +| securityContext | object | `{}` | Configure the Security Context for the main container | +| 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.labels | object | `{}` | Provide additional labels which may be required. | +| service.main.nameOverride | string | `nil` | Override the name suffix that is used for this service | +| service.main.ports | object | See below | Configure the Service port information here. Additional ports can be added by adding a dictionary key similar to the 'http' service. | +| service.main.ports.http.enabled | bool | `true` | Enables or disables the port | +| service.main.ports.http.nodePort | string | `nil` | Specify the nodePort value for the LoadBalancer and NodePort service types. [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) | +| service.main.ports.http.port | string | `nil` | The port number | +| service.main.ports.http.primary | bool | `true` | Make this the primary port (used in probes, notes, etc...) If there is more than 1 service, make sure that only 1 port is marked as primary. | +| service.main.ports.http.protocol | string | `"HTTP"` | Port protocol. Support values are `HTTP`, `HTTPS`, `TCP` and `UDP`. HTTPS and HTTPS spawn a TCP service and get used for internal URL and name generation | +| service.main.ports.http.targetPort | string | `nil` | Specify a service targetPort if you wish to differ the service port from the application port. If `targetPort` is specified, this port number is used in the container definition instead of the `port` value. Therefore named ports are not supported for this field. | +| service.main.primary | bool | `true` | Make this the primary service (used in probes, notes, etc...). If there is more than 1 service, make sure that only 1 service is marked as primary. | +| service.main.type | string | `"ClusterIP"` | Set the service type | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.create | bool | `false` | Specifies whether a service account should be created | +| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| 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)] | +| 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. | + +## Changelog + +All notable changes to this library Helm chart will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +### [4.2.0] + +#### Added + +- Support for defining ipFamilyPolicy and ipFamilies in service resources + +### [4.1.0] + +#### Changed + +- Updated Wireguard add-on image tag to `v1.0.20210914`. + +#### Added + +- Support for specifying whether a pod should auto mount a service account token. +- Support for specifying configMaps directly in values.yaml. +- Support for specifying annotations/labels on the VPN add-on `NetworkPolicy`. +- Support for specifying custom podSelector labels on the VPN add-on `NetworkPolicy`. +- Added `secret` and `configMap` as persistence types. [[ref]](http://docs.k8s-at-home.com/our-helm-charts/common-library-storage/). + +### [4.0.1] + +#### Fixed + +- Fixed an issue where users weren't able to set custom ingress labels. + +### [4.0.0] + +#### Added + +- Support for specifying container termination message path and policy (#77). +- Support for specifying Pod termination grace period. +- Support for specifying PVC labels for `persistence` items. + +#### Changed + +- **BREAKING**: Renamed the `skipuninstall` key to `retain` for `persistence` items. +- **BREAKING**: `initContainers` now expects a dictionary instead of a list to make merging less error-prone. initContainers are ordered by their key. +- **BREAKING**: `additionalContainers` now expects a dictionary instead of a list to make merging less error-prone. + +### [3.3.0] + +#### Added + +- Support ability to specify the [mountPropagation](https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation) key under persistence items (https://github.com/k8s-at-home/library-charts/issues/74). + +#### Changed + +- Changed the docstring for `persistence` to better reference [our documentation](http://docs.k8s-at-home.com/our-helm-charts/common-library-storage/) regarding Storage options. + +#### Fixed + +- Fixed an issue where the default `repository` value for the Wireguard addon was incorrect (https://github.com/k8s-at-home/library-charts/issues/69). +- Fixed an issue where probes were not referencing the service `targetPort`. + +### [3.2.0] + +#### Added + +- Support for specifying [topologySpreadConstraints](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) for a pod. +- Support for specifying multiple `subPath` items under `persistence` keys. + +#### Removed + +- Removed persistence examples from the `values.yaml` file. These will be documented instead in [our documentation](http://docs.k8s-at-home.com/our-helm-charts/common-library/). + +### [3.1.1] + +#### Fixed + +- Fixed an issue where the default service would not be determined correctly for Ingress objects. +- Fixed an issue where the code-server addon ingress would reference the wrong service when multiple hosts were specified (https://github.com/k8s-at-home/library-charts/issues/64). + +### [3.1.0] + +#### Added + +- Support to disable the controller when no container is deployed. + +#### Fixed + +- Fixed an issue where the code-server addon ingress would reference the wrong service. + +### [3.0.2] + +#### Fixed + +- Fixed an issue where the `common.names.fullname` template would not properly render. + +### [3.0.1] + +#### Fixed + +- Fixed an issue where the `nameOverride` and `fullnameOverride` could throw an error. + +### [3.0.0] + +#### Added + +- It is now possible to flag an ingress / service / port as primary. This will then be used + by default in the chart notes, probes, etc. +- Individual ports can now be enabled / disabled. +- Allow setting Pod labels using the `podLabels` field. +- Allow setting `volumeName` for PVC's. +- Annotated the values.yaml to better describe what fields do. This is also reflected in the [README.md](README.md) file. +- Added a [netshoot](https://github.com/nicolaka/netshoot) add-on. This allows for injecting a network trouble-shooting swiss-army sidecar container. + +#### Changed + +- Probes are now automatically disabled (except for custom defined probes) when no service is enabled. +- Moved the primary ingress from `ingress` to `ingress.main`. +- Moved the primary service from `service` to `service.main`. +- Multiple ingress objects can now be specified under the `ingress` key. +- Multiple service objects can now be specified under the `service` key. +- `nameSuffix` has been renamed to `nameOverride`. +- `hostPathMounts` has been integrated with `persistence`. +- `additionalVolumes` has been integrated with `persistence`. +- Test framework has been rewritten from Ruby to Go. + +#### Fixed + +- Cleaned up YAML document separators (`---`). +- Fixed indenting of the `lifecycle` field. + +#### Removed + +- Removed support for `ingress.additionalIngresses`. +- Removed support for `services.additionalServices`. +- Removed support for TrueNAS SCALE features. These are out of scope for our project. + +### [2.5.0] + +#### Added + +- Added `Horizontal Pod Autoscaler` +- Can now use "HTTP" or "HTTPS" as port protocol (which use TCP under-the-hood) +- Setting the port protocol to "HTTPS" adds traefik annotation to use https towards the backend service +- Add option to automatically generate a configmap for use with the TrueNAS SCALE UI portal-button +- Added option to use TrueNAS SCALE default storageClass by using `SCALE-ZFS` storageClass +- It is now possible to set the `serviceName` and `servicePort` per Ingress path + +#### Changed + +- Port protocol gets used to determine install-notes URL (http or https) + +### [2.4.0] + +#### Added + +- `hostPathMounts` to mount hostPaths with a single values.yaml setting +- Automated ownership fixing job for `hostPathMounts` +- `envList` to use a list of environment variables in addition to the current dict or template + +#### Changed + +- Set `dnsPolicy` default based on `hostNetwork` setting + +#### Fixed + +- Fixed unit-tests not correctly testing no-env scenario's + +### [2.3.1] + +#### Fixed + +- Fixed the VPN addon secret name when providing inline VPN configuration. + +### [2.3.0] + +#### Added + +- Allow `configFileSecret` to be specified under the VPN add-on, to reference an existing secret. +- Allow `git.deployKey` to be specified under the codeserver add-on. Please refer to `values.yaml` for more details. + +#### Changed + +- Modified unit tests to no longer depend on `jq`. + +#### Fixed + +- `secretName` is now truly optional under Ingress TLS configuration. + +### [2.2.0] + +#### Added + +- Persistence `nameSuffix` can now be set to `-` to disable suffixing that PVC. +- Support for configuring `lifecycle` +- Support for configuring `pathTpl` in Ingress (#15). + +#### Fixed + +- Ingress `pathType` is now actually configurable. Fixes #16. +- PVC's are always forced to a newline. Fixes #17. + +### [2.1.0] + +#### Added + +- Added support for shipping logs to Loki using the new `promtail` add-on. + +#### Changed + +- Upgraded the default image in the `codeserver` add-on to `v3.9.2` + +### [2.0.1] + +#### Fixed + +- Volumes referencing persistentVolumeClaims actually reference the PVC again. +- Items under persistence now default their `mountPath` to the item name, as they should have been doing. + +### [2.0.0] + +#### Added + +- Added support for using Helm template language in `additionalContainers`. + +#### Changed + +- **Breaking:** `persistence.emptyDir` was changed to allow more configuration options, such as `medium` and `sizeLimit`. + +### [1.0.0] + +#### Changed + +- Moved common library chart to separate repository + +#### Fixed + +- The `command` and `args` values now properly support both string and list values. + +[4.0.0]: #400 +[3.3.0]: #330 +[3.2.0]: #320 +[3.1.1]: #311 +[3.1.0]: #310 +[3.0.2]: #302 +[3.0.1]: #301 +[3.0.0]: #300 +[2.5.0]: #250 +[2.4.0]: #240 +[2.3.1]: #231 +[2.3.0]: #230 +[2.2.0]: #220 +[2.1.0]: #210 +[2.0.1]: #201 +[2.0.0]: #200 +[1.0.0]: #100 + +## Support + +- See the [Docs](https://docs.k8s-at-home.com/our-helm-charts/getting-started/) +- Open an [issue](https://github.com/k8s-at-home/charts/issues/new/choose) +- Ask a [question](https://github.com/k8s-at-home/organization/discussions) +- Join our [Discord](https://discord.gg/sTMX7Vh) community + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) diff --git a/charts/cv/charts/helm-library-common/README.md.gotmpl b/charts/cv/charts/helm-library-common/README.md.gotmpl new file mode 100644 index 0000000..a5d5a8c --- /dev/null +++ b/charts/cv/charts/helm-library-common/README.md.gotmpl @@ -0,0 +1,99 @@ +{{- define "custom.repository.organization" -}} +k8s-at-home +{{- end -}} + +{{- define "custom.repository.url" -}} +https://github.com/k8s-at-home/charts +{{- end -}} + +{{- define "custom.helm.url" -}} +https://k8s-at-home.com/charts/ +{{- end -}} + +{{- define "custom.helm.path" -}} +{{ template "custom.repository.organization" . }}/{{ template "chart.name" . }} +{{- end -}} + +{{- define "custom.notes" -}} +{{- end -}} + +{{- define "custom.requirements" -}} +## Requirements + +{{ template "chart.kubeVersionLine" . }} +{{- end -}} + +{{- define "custom.dependencies" -}} +## Dependencies + +{{ template "chart.requirementsTable" . }} +{{- end -}} + +{{- define "custom.install" -}} +## Installing the Chart + +This is a [Helm Library Chart](https://helm.sh/docs/topics/library_charts/#helm). + +**WARNING: THIS CHART IS NOT MEANT TO BE INSTALLED DIRECTLY** +{{- end -}} + +{{- define "custom.usage" -}} +{{- end -}} + +{{- define "custom.configuration.header" -}} +## Configuration +{{- end -}} + +{{- define "custom.configuration.readValues" -}} +Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values. +{{- end -}} + +{{- define "custom.valuesSection" -}} +## Values + +**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common) + +{{ template "chart.valuesTable" . }} +{{- end -}} + +{{- define "custom.support" -}} +## Support + +- See the [Docs](https://docs.k8s-at-home.com/our-helm-charts/getting-started/) +- Open an [issue](https://github.com/k8s-at-home/charts/issues/new/choose) +- Ask a [question](https://github.com/k8s-at-home/organization/discussions) +- Join our [Discord](https://discord.gg/sTMX7Vh) community +{{- end -}} + +{{ template "chart.header" . }} + +{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} + +{{ template "chart.description" . }} + +{{ template "custom.notes" . }} + +{{ template "chart.sourcesSection" . }} + +{{ template "custom.requirements" . }} + +{{ template "custom.dependencies" . }} + +{{ template "custom.install" . }} + +{{ template "custom.usage" . }} + +{{ template "custom.configuration.header" . }} + +{{ template "custom.configuration.readValues" . }} + +{{ template "custom.custom.configuration" . }} + +{{ template "custom.valuesSection" . }} + +{{ template "custom.changelog" . }} + +{{ template "custom.support" . }} + +{{ template "helm-docs.versionFooter" . }} +{{ "" }} diff --git a/charts/cv/charts/helm-library-common/README_CHANGELOG.md.gotmpl b/charts/cv/charts/helm-library-common/README_CHANGELOG.md.gotmpl new file mode 100644 index 0000000..5bc6cb6 --- /dev/null +++ b/charts/cv/charts/helm-library-common/README_CHANGELOG.md.gotmpl @@ -0,0 +1,262 @@ +{{- define "custom.changelog.header" -}} +## Changelog +{{- end -}} + +{{- define "custom.changelog" -}} +{{ template "custom.changelog.header" . }} + +All notable changes to this library Helm chart will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +### [4.2.0] + +#### Added + +- Support for defining ipFamilyPolicy and ipFamilies in service resources + +### [4.1.0] + +#### Changed + +- Updated Wireguard add-on image tag to `v1.0.20210914`. + +#### Added + +- Support for specifying whether a pod should auto mount a service account token. +- Support for specifying configMaps directly in values.yaml. +- Support for specifying annotations/labels on the VPN add-on `NetworkPolicy`. +- Support for specifying custom podSelector labels on the VPN add-on `NetworkPolicy`. +- Added `secret` and `configMap` as persistence types. [[ref]](http://docs.k8s-at-home.com/our-helm-charts/common-library-storage/). + +### [4.0.1] + +#### Fixed + +- Fixed an issue where users weren't able to set custom ingress labels. + +### [4.0.0] + +#### Added + +- Support for specifying container termination message path and policy (#77). +- Support for specifying Pod termination grace period. +- Support for specifying PVC labels for `persistence` items. + +#### Changed + +- **BREAKING**: Renamed the `skipuninstall` key to `retain` for `persistence` items. +- **BREAKING**: `initContainers` now expects a dictionary instead of a list to make merging less error-prone. initContainers are ordered by their key. +- **BREAKING**: `additionalContainers` now expects a dictionary instead of a list to make merging less error-prone. + +### [3.3.0] + +#### Added + +- Support ability to specify the [mountPropagation](https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation) key under persistence items (https://github.com/k8s-at-home/library-charts/issues/74). + +#### Changed + +- Changed the docstring for `persistence` to better reference [our documentation](http://docs.k8s-at-home.com/our-helm-charts/common-library-storage/) regarding Storage options. + +#### Fixed + +- Fixed an issue where the default `repository` value for the Wireguard addon was incorrect (https://github.com/k8s-at-home/library-charts/issues/69). +- Fixed an issue where probes were not referencing the service `targetPort`. + +### [3.2.0] + +#### Added + +- Support for specifying [topologySpreadConstraints](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) for a pod. +- Support for specifying multiple `subPath` items under `persistence` keys. + +#### Removed + +- Removed persistence examples from the `values.yaml` file. These will be documented instead in [our documentation](http://docs.k8s-at-home.com/our-helm-charts/common-library/). + +### [3.1.1] + +#### Fixed + +- Fixed an issue where the default service would not be determined correctly for Ingress objects. +- Fixed an issue where the code-server addon ingress would reference the wrong service when multiple hosts were specified (https://github.com/k8s-at-home/library-charts/issues/64). + +### [3.1.0] + +#### Added + +- Support to disable the controller when no container is deployed. + +#### Fixed + +- Fixed an issue where the code-server addon ingress would reference the wrong service. + +### [3.0.2] + +#### Fixed + +- Fixed an issue where the `common.names.fullname` template would not properly render. + +### [3.0.1] + +#### Fixed + +- Fixed an issue where the `nameOverride` and `fullnameOverride` could throw an error. + +### [3.0.0] + +#### Added + +- It is now possible to flag an ingress / service / port as primary. This will then be used + by default in the chart notes, probes, etc. +- Individual ports can now be enabled / disabled. +- Allow setting Pod labels using the `podLabels` field. +- Allow setting `volumeName` for PVC's. +- Annotated the values.yaml to better describe what fields do. This is also reflected in the [README.md](README.md) file. +- Added a [netshoot](https://github.com/nicolaka/netshoot) add-on. This allows for injecting a network trouble-shooting swiss-army sidecar container. + +#### Changed + +- Probes are now automatically disabled (except for custom defined probes) when no service is enabled. +- Moved the primary ingress from `ingress` to `ingress.main`. +- Moved the primary service from `service` to `service.main`. +- Multiple ingress objects can now be specified under the `ingress` key. +- Multiple service objects can now be specified under the `service` key. +- `nameSuffix` has been renamed to `nameOverride`. +- `hostPathMounts` has been integrated with `persistence`. +- `additionalVolumes` has been integrated with `persistence`. +- Test framework has been rewritten from Ruby to Go. + +#### Fixed + +- Cleaned up YAML document separators (`---`). +- Fixed indenting of the `lifecycle` field. + +#### Removed + +- Removed support for `ingress.additionalIngresses`. +- Removed support for `services.additionalServices`. +- Removed support for TrueNAS SCALE features. These are out of scope for our project. + +### [2.5.0] + +#### Added + +- Added `Horizontal Pod Autoscaler` +- Can now use "HTTP" or "HTTPS" as port protocol (which use TCP under-the-hood) +- Setting the port protocol to "HTTPS" adds traefik annotation to use https towards the backend service +- Add option to automatically generate a configmap for use with the TrueNAS SCALE UI portal-button +- Added option to use TrueNAS SCALE default storageClass by using `SCALE-ZFS` storageClass +- It is now possible to set the `serviceName` and `servicePort` per Ingress path + +#### Changed + +- Port protocol gets used to determine install-notes URL (http or https) + +### [2.4.0] + +#### Added + +- `hostPathMounts` to mount hostPaths with a single values.yaml setting +- Automated ownership fixing job for `hostPathMounts` +- `envList` to use a list of environment variables in addition to the current dict or template + +#### Changed + +- Set `dnsPolicy` default based on `hostNetwork` setting + +#### Fixed + +- Fixed unit-tests not correctly testing no-env scenario's + +### [2.3.1] + +#### Fixed + +- Fixed the VPN addon secret name when providing inline VPN configuration. + +### [2.3.0] + +#### Added + +- Allow `configFileSecret` to be specified under the VPN add-on, to reference an existing secret. +- Allow `git.deployKey` to be specified under the codeserver add-on. Please refer to `values.yaml` for more details. + +#### Changed + +- Modified unit tests to no longer depend on `jq`. + +#### Fixed + +- `secretName` is now truly optional under Ingress TLS configuration. + +### [2.2.0] + +#### Added + +- Persistence `nameSuffix` can now be set to `-` to disable suffixing that PVC. +- Support for configuring `lifecycle` +- Support for configuring `pathTpl` in Ingress (#15). + +#### Fixed + +- Ingress `pathType` is now actually configurable. Fixes #16. +- PVC's are always forced to a newline. Fixes #17. + +### [2.1.0] + +#### Added + +- Added support for shipping logs to Loki using the new `promtail` add-on. + +#### Changed + +- Upgraded the default image in the `codeserver` add-on to `v3.9.2` + +### [2.0.1] + +#### Fixed + +- Volumes referencing persistentVolumeClaims actually reference the PVC again. +- Items under persistence now default their `mountPath` to the item name, as they should have been doing. + +### [2.0.0] + +#### Added + +- Added support for using Helm template language in `additionalContainers`. + +#### Changed + +- **Breaking:** `persistence.emptyDir` was changed to allow more configuration options, such as `medium` and `sizeLimit`. + +### [1.0.0] + +#### Changed + +- Moved common library chart to separate repository + +#### Fixed + +- The `command` and `args` values now properly support both string and list values. + +[4.0.0]: #400 +[3.3.0]: #330 +[3.2.0]: #320 +[3.1.1]: #311 +[3.1.0]: #310 +[3.0.2]: #302 +[3.0.1]: #301 +[3.0.0]: #300 +[2.5.0]: #250 +[2.4.0]: #240 +[2.3.1]: #231 +[2.3.0]: #230 +[2.2.0]: #220 +[2.1.0]: #210 +[2.0.1]: #201 +[2.0.0]: #200 +[1.0.0]: #100 +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/README_CONFIG.md.gotmpl b/charts/cv/charts/helm-library-common/README_CONFIG.md.gotmpl new file mode 100644 index 0000000..a550249 --- /dev/null +++ b/charts/cv/charts/helm-library-common/README_CONFIG.md.gotmpl @@ -0,0 +1,29 @@ +{{- define "custom.notes" -}} +Since a lot of the {{ template "custom.repository.organization" . }} charts follow a similar pattern, this library was built to reduce maintenance cost between the charts that use it and try achieve a goal of being DRY. +{{- end -}} + +{{- define "custom.custom.configuration.header" -}} +## Custom configuration +{{- end -}} + +{{- define "custom.custom.configuration" -}} +{{ template "custom.custom.configuration.header" . }} + +N/A +{{- end -}} + +{{- define "custom.usage" }} +## Using this library + +Include this chart as a dependency in your `Chart.yaml` e.g. + +```yaml +# Chart.yaml +dependencies: +- name: common + version: 3.0.0 + repository: {{ template "custom.helm.url" }} +``` + +For more information, take a look at the [Docs](http://docs.k8s-at-home.com/our-helm-charts/common-library/). +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/_all.tpl b/charts/cv/charts/helm-library-common/templates/_all.tpl new file mode 100644 index 0000000..e844bfb --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_all.tpl @@ -0,0 +1,58 @@ +{{/* +Main entrypoint for the common library chart. It will render all underlying templates based on the provided values. +*/}} +{{- define "common.all" -}} + {{- /* Merge the local chart values and the common chart defaults */ -}} + {{- include "common.values.setup" . }} + + {{- /* Enable code-server add-on if required */ -}} + {{- if .Values.addons.codeserver.enabled }} + {{- include "common.addon.codeserver" . }} + {{- end -}} + + {{- /* Enable VPN add-on if required */ -}} + {{- if .Values.addons.vpn.enabled }} + {{- include "common.addon.vpn" . }} + {{- end -}} + + {{- /* Enable promtail add-on if required */ -}} + {{- if .Values.addons.promtail.enabled }} + {{- include "common.addon.promtail" . }} + {{- end -}} + + {{- /* Enable netshoot add-on if required */ -}} + {{- if .Values.addons.netshoot.enabled }} + {{- include "common.addon.netshoot" . }} + {{- end -}} + + {{ include "common.configmap" . | nindent 0 }} + + {{- /* Build the templates */ -}} + {{- include "common.pvc" . }} + + {{- if .Values.serviceAccount.create -}} + {{- include "common.serviceAccount" . }} + {{- end -}} + + {{- if .Values.controller.enabled }} + {{- if eq .Values.controller.type "deployment" }} + {{- include "common.deployment" . | nindent 0 }} + {{ else if eq .Values.controller.type "daemonset" }} + {{- include "common.daemonset" . | nindent 0 }} + {{ else if eq .Values.controller.type "statefulset" }} + {{- include "common.statefulset" . | nindent 0 }} + {{ else }} + {{- fail (printf "Not a valid controller.type (%s)" .Values.controller.type) }} + {{- end -}} + {{- end -}} + + {{ include "common.classes.hpa" . | nindent 0 }} + + {{ include "common.service" . | nindent 0 }} + + {{ include "common.ingress" . | nindent 0 }} + + {{- if .Values.secret -}} + {{ include "common.secret" . | nindent 0 }} + {{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/_configmap.tpl b/charts/cv/charts/helm-library-common/templates/_configmap.tpl new file mode 100644 index 0000000..73ad958 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_configmap.tpl @@ -0,0 +1,19 @@ +{{/* +Renders the configMap objects required by the chart. +*/}} +{{- define "common.configmap" -}} + {{- /* Generate named configMaps as required */ -}} + {{- range $name, $configmap := .Values.configmap }} + {{- if $configmap.enabled -}} + {{- $configmapValues := $configmap -}} + + {{/* set the default nameOverride to the configMap name */}} + {{- if not $configmapValues.nameOverride -}} + {{- $_ := set $configmapValues "nameOverride" $name -}} + {{ end -}} + + {{- $_ := set $ "ObjectValues" (dict "configmap" $configmapValues) -}} + {{- include "common.classes.configmap" $ }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/_daemonset.tpl b/charts/cv/charts/helm-library-common/templates/_daemonset.tpl new file mode 100644 index 0000000..2dd9d53 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_daemonset.tpl @@ -0,0 +1,38 @@ +{{/* +This template serves as the blueprint for the DaemonSet objects that are created +within the common library. +*/}} +{{- define "common.daemonset" }} +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: {{ include "common.names.fullname" . }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with .Values.controller.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.controller.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} + selector: + matchLabels: + {{- include "common.labels.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "common.labels.selectorLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- include "common.controller.pod" . | nindent 6 }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/_deployment.tpl b/charts/cv/charts/helm-library-common/templates/_deployment.tpl new file mode 100644 index 0000000..87f05bc --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_deployment.tpl @@ -0,0 +1,56 @@ +{{/* +This template serves as the blueprint for the Deployment objects that are created +within the common library. +*/}} +{{- define "common.deployment" }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "common.names.fullname" . }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with .Values.controller.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.controller.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} + replicas: {{ .Values.controller.replicas }} + {{- $strategy := default "Recreate" .Values.controller.strategy }} + {{- if and (ne $strategy "Recreate") (ne $strategy "RollingUpdate") }} + {{- fail (printf "Not a valid strategy type for Deployment (%s)" $strategy) }} + {{- end }} + strategy: + type: {{ $strategy }} + {{- with .Values.controller.rollingUpdate }} + {{- if and (eq $strategy "RollingUpdate") (or .surge .unavailable) }} + rollingUpdate: + {{- with .unavailable }} + maxUnavailable: {{ . }} + {{- end }} + {{- with .surge }} + maxSurge: {{ . }} + {{- end }} + {{- end }} + {{- end }} + selector: + matchLabels: + {{- include "common.labels.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "common.labels.selectorLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- include "common.controller.pod" . | nindent 6 }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/_ingress.tpl b/charts/cv/charts/helm-library-common/templates/_ingress.tpl new file mode 100644 index 0000000..b14e170 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_ingress.tpl @@ -0,0 +1,39 @@ +{{/* Renders the Ingress objects required by the chart */}} +{{- define "common.ingress" -}} + {{- /* Generate named ingresses as required */ -}} + {{- range $name, $ingress := .Values.ingress }} + {{- if $ingress.enabled -}} + {{- $ingressValues := $ingress -}} + + {{/* set defaults */}} + {{- if and (not $ingressValues.nameOverride) (ne $name (include "common.ingress.primary" $)) -}} + {{- $_ := set $ingressValues "nameOverride" $name -}} + {{- end -}} + + {{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}} + {{- include "common.classes.ingress" $ }} + {{- end }} + {{- end }} +{{- end }} + +{{/* Return the name of the primary ingress object */}} +{{- define "common.ingress.primary" -}} + {{- $enabledIngresses := dict -}} + {{- range $name, $ingress := .Values.ingress -}} + {{- if $ingress.enabled -}} + {{- $_ := set $enabledIngresses $name . -}} + {{- end -}} + {{- end -}} + + {{- $result := "" -}} + {{- range $name, $ingress := $enabledIngresses -}} + {{- if and (hasKey $ingress "primary") $ingress.primary -}} + {{- $result = $name -}} + {{- end -}} + {{- end -}} + + {{- if not $result -}} + {{- $result = keys $enabledIngresses | first -}} + {{- end -}} + {{- $result -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/_notes.tpl b/charts/cv/charts/helm-library-common/templates/_notes.tpl new file mode 100644 index 0000000..f747ffd --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_notes.tpl @@ -0,0 +1,56 @@ +{{/* +Default NOTES.txt content. +*/}} +{{- define "common.notes.defaultNotes" -}} + +{{- $primaryIngress := get .Values.ingress (include "common.ingress.primary" .) -}} +{{- $primaryService := get .Values.service (include "common.service.primary" .) -}} +{{- $primaryPort := "" -}} +{{- if $primaryService -}} + {{- $primaryPort = get $primaryService.ports (include "common.classes.service.ports.primary" (dict "serviceName" (include "common.service.primary" .) "values" $primaryService)) -}} +{{- end -}} + +{{- $prefix := "http" -}} +{{- if $primaryPort }} + {{- if hasKey $primaryPort "protocol" }} + {{- if eq $primaryPort.protocol "HTTPS" }} + {{- $prefix = "https" }} + {{- end }} + {{- end }} +{{- end }} + +{{- if $primaryIngress }} +1. Access the application by visting one of these URL's: +{{ range $primaryIngress.hosts }} + {{- $protocol := "http" -}} + {{ if $primaryIngress.tls -}} + {{- $prefix = "https" -}} + {{ end -}} + {{- $host := .host -}} + {{ if .hostTpl -}} + {{- $host = tpl .hostTpl $ -}} + {{ end }} + {{- $path := (first .paths).path | default "/" -}} + {{ if (first .paths).pathTpl -}} + {{- $path = tpl (first .paths).pathTpl $ -}} + {{ end }} + - {{ $protocol }}://{{- $host }}{{- $path }} +{{- end }} +{{- else if and $primaryService $primaryPort }} +1. Get the application URL by running these commands: +{{- if contains "NodePort" $primaryService.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.names.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo {{ $prefix }}://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" $primaryService.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ include "common.names.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo {{ $prefix }}://$SERVICE_IP:{{ $primaryPort.port }} +{{- else if contains "ClusterIP" $primaryService.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "common.names.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit {{ $prefix }}://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:{{ $primaryPort.port }} +{{- end }} +{{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/_pvc.tpl b/charts/cv/charts/helm-library-common/templates/_pvc.tpl new file mode 100644 index 0000000..608b4de --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_pvc.tpl @@ -0,0 +1,16 @@ +{{/* +Renders the Persistent Volume Claim objects required by the chart. +*/}} +{{- define "common.pvc" -}} + {{- /* Generate pvc as required */ -}} + {{- range $index, $PVC := .Values.persistence }} + {{- if and $PVC.enabled (eq (default "pvc" $PVC.type) "pvc") (not $PVC.existingClaim) -}} + {{- $persistenceValues := $PVC -}} + {{- if not $persistenceValues.nameOverride -}} + {{- $_ := set $persistenceValues "nameOverride" $index -}} + {{- end -}} + {{- $_ := set $ "ObjectValues" (dict "persistence" $persistenceValues) -}} + {{- include "common.classes.pvc" $ | nindent 0 -}} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/_secret.tpl b/charts/cv/charts/helm-library-common/templates/_secret.tpl new file mode 100644 index 0000000..1a6df46 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_secret.tpl @@ -0,0 +1,17 @@ +{{/* +The Secret object to be created. +*/}} +{{- define "common.secret" }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "common.names.fullname" . }} + labels: + {{- include "common.labels" . | nindent 4 }} +type: Opaque +{{- with .Values.secret }} +stringData: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/_service.tpl b/charts/cv/charts/helm-library-common/templates/_service.tpl new file mode 100644 index 0000000..3581193 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_service.tpl @@ -0,0 +1,43 @@ +{{/* +Renders the Service objects required by the chart. +*/}} +{{- define "common.service" -}} + {{- /* Generate named services as required */ -}} + {{- range $name, $service := .Values.service }} + {{- if $service.enabled -}} + {{- $serviceValues := $service -}} + + {{/* set the default nameOverride to the service name */}} + {{- if and (not $serviceValues.nameOverride) (ne $name (include "common.service.primary" $)) -}} + {{- $_ := set $serviceValues "nameOverride" $name -}} + {{ end -}} + + {{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}} + {{- include "common.classes.service" $ }} + {{- end }} + {{- end }} +{{- end }} + +{{/* +Return the primary service object +*/}} +{{- define "common.service.primary" -}} + {{- $enabledServices := dict -}} + {{- range $name, $service := .Values.service -}} + {{- if $service.enabled -}} + {{- $_ := set $enabledServices $name . -}} + {{- end -}} + {{- end -}} + + {{- $result := "" -}} + {{- range $name, $service := $enabledServices -}} + {{- if and (hasKey $service "primary") $service.primary -}} + {{- $result = $name -}} + {{- end -}} + {{- end -}} + + {{- if not $result -}} + {{- $result = keys $enabledServices | first -}} + {{- end -}} + {{- $result -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/_serviceaccount.tpl b/charts/cv/charts/helm-library-common/templates/_serviceaccount.tpl new file mode 100644 index 0000000..0cca83c --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_serviceaccount.tpl @@ -0,0 +1,16 @@ +{{/* +The ServiceAccount object to be created. +*/}} +{{- define "common.serviceAccount" }} +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "common.names.serviceAccountName" . }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/_statefulset.tpl b/charts/cv/charts/helm-library-common/templates/_statefulset.tpl new file mode 100644 index 0000000..e99a7b0 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/_statefulset.tpl @@ -0,0 +1,64 @@ +{{/* +This template serves as the blueprint for the StatefulSet objects that are created +within the common library. +*/}} +{{- define "common.statefulset" }} +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "common.names.fullname" . }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with .Values.controller.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.controller.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} + replicas: {{ .Values.controller.replicas }} + {{- $strategy := default "RollingUpdate" .Values.controller.strategy }} + {{- if and (ne $strategy "OnDelete") (ne $strategy "RollingUpdate") }} + {{- fail (printf "Not a valid strategy type for StatefulSet (%s)" $strategy) }} + {{- end }} + updateStrategy: + type: {{ $strategy }} + {{- if and (eq $strategy "RollingUpdate") .Values.controller.rollingUpdate.partition }} + rollingUpdate: + partition: {{ .Values.controller.rollingUpdate.partition }} + {{- end }} + selector: + matchLabels: + {{- include "common.labels.selectorLabels" . | nindent 6 }} + serviceName: {{ include "common.names.fullname" . }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "common.labels.selectorLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- include "common.controller.pod" . | nindent 6 }} + volumeClaimTemplates: + {{- range $index, $vct := .Values.volumeClaimTemplates }} + - metadata: + name: {{ $vct.name }} + spec: + accessModes: + - {{ required (printf "accessMode is required for vCT %v" $vct.name) $vct.accessMode | quote }} + resources: + requests: + storage: {{ required (printf "size is required for PVC %v" $vct.name) $vct.size | quote }} + {{- if $vct.storageClass }} + storageClassName: {{ if (eq "-" $vct.storageClass) }}""{{- else }}{{ $vct.storageClass | quote }}{{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/addons/code-server/_codeserver.tpl b/charts/cv/charts/helm-library-common/templates/addons/code-server/_codeserver.tpl new file mode 100644 index 0000000..ef1ca67 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/code-server/_codeserver.tpl @@ -0,0 +1,50 @@ +{{/* +Template to render code-server addon +It will include / inject the required templates based on the given values. +*/}} +{{- define "common.addon.codeserver" -}} +{{- if .Values.addons.codeserver.enabled -}} + {{/* Append the code-server container to the additionalContainers */}} + {{- $container := include "common.addon.codeserver.container" . | fromYaml -}} + {{- if $container -}} + {{- $_ := set .Values.additionalContainers "addon-codeserver" $container -}} + {{- end -}} + + {{/* Include the deployKeySecret if not empty */}} + {{- $secret := include "common.addon.codeserver.deployKeySecret" . -}} + {{- if $secret -}} + {{- $secret | nindent 0 -}} + {{- end -}} + + {{/* Append the secret volume to the volumes */}} + {{- $volume := include "common.addon.codeserver.deployKeyVolumeSpec" . | fromYaml -}} + {{- if $volume -}} + {{- $_ := set .Values.persistence "deploykey" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}} + {{- end -}} + + {{/* Add the code-server service */}} + {{- if .Values.addons.codeserver.service.enabled -}} + {{- $serviceValues := .Values.addons.codeserver.service -}} + {{- $_ := set $serviceValues "nameOverride" "codeserver" -}} + {{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}} + {{- include "common.classes.service" $ -}} + {{- $_ := unset $ "ObjectValues" -}} + {{- end -}} + + {{/* Add the code-server ingress */}} + {{- if .Values.addons.codeserver.ingress.enabled -}} + {{- $ingressValues := .Values.addons.codeserver.ingress -}} + {{- $_ := set $ingressValues "nameOverride" "codeserver" -}} + + {{/* Determine the target service name & port */}} + {{- $svcName := printf "%v-codeserver" (include "common.names.fullname" .) -}} + {{- $svcPort := .Values.addons.codeserver.service.ports.codeserver.port -}} + {{- range $_, $host := $ingressValues.hosts -}} + {{- $_ := set (index $host.paths 0) "service" (dict "name" $svcName "port" $svcPort) -}} + {{- end -}} + {{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}} + {{- include "common.classes.ingress" $ -}} + {{- $_ := unset $ "ObjectValues" -}} + {{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/code-server/_container.tpl b/charts/cv/charts/helm-library-common/templates/addons/code-server/_container.tpl new file mode 100644 index 0000000..23af35e --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/code-server/_container.tpl @@ -0,0 +1,46 @@ +{{/* +The code-server sidecar container to be inserted. +*/}} +{{- define "common.addon.codeserver.container" -}} +{{- if lt (len .Values.addons.codeserver.volumeMounts) 1 }} +{{- fail "At least 1 volumeMount is required for codeserver container" }} +{{- end -}} +name: codeserver +image: "{{ .Values.addons.codeserver.image.repository }}:{{ .Values.addons.codeserver.image.tag }}" +imagePullPolicy: {{ .Values.addons.codeserver.pullPolicy }} +{{- with .Values.addons.codeserver.securityContext }} +securityContext: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- with .Values.addons.codeserver.env }} +env: +{{- range $k, $v := . }} + - name: {{ $k }} + value: {{ $v | quote }} +{{- end }} +{{- end }} +ports: +- name: codeserver + containerPort: {{ .Values.addons.codeserver.service.ports.codeserver.port }} + protocol: TCP +args: +{{- range .Values.addons.codeserver.args }} +- {{ . | quote }} +{{- end }} +- "--port" +- "{{ .Values.addons.codeserver.service.ports.codeserver.port }}" +- {{ .Values.addons.codeserver.workingDir | default (first .Values.addons.codeserver.volumeMounts).mountPath }} +volumeMounts: +{{- with .Values.addons.codeserver.volumeMounts }} + {{- toYaml . | nindent 2 }} +{{- end }} +{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 .Values.addons.codeserver.git.deployKeySecret }} + - name: deploykey + mountPath: /root/.ssh/id_rsa + subPath: id_rsa +{{- end }} +{{- with .Values.addons.codeserver.resources }} +resources: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/code-server/_secret.tpl b/charts/cv/charts/helm-library-common/templates/addons/code-server/_secret.tpl new file mode 100644 index 0000000..14c6232 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/code-server/_secret.tpl @@ -0,0 +1,22 @@ +{{/* +The OpenVPN credentials secrets to be included. +*/}} +{{- define "common.addon.codeserver.deployKeySecret" -}} +{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "common.names.fullname" . }}-deploykey + labels: + {{- include "common.labels" . | nindent 4 }} +type: Opaque +{{- if .Values.addons.codeserver.git.deployKey }} +stringData: + id_rsa: {{ .Values.addons.codeserver.git.deployKey | quote }} +{{- else }} +data: + id_rsa: {{ .Values.addons.codeserver.git.deployKeyBase64 | quote }} +{{- end }} +{{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/code-server/_volume.tpl b/charts/cv/charts/helm-library-common/templates/addons/code-server/_volume.tpl new file mode 100644 index 0000000..6e6d594 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/code-server/_volume.tpl @@ -0,0 +1,17 @@ +{{/* +The volume (referencing git deploykey) to be inserted into additionalVolumes. +*/}} +{{- define "common.addon.codeserver.deployKeyVolumeSpec" -}} +{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 .Values.addons.codeserver.git.deployKeySecret }} +secret: + {{- if .Values.addons.codeserver.git.deployKeySecret }} + secretName: {{ .Values.addons.codeserver.git.deployKeySecret }} + {{- else }} + secretName: {{ include "common.names.fullname" . }}-deploykey + {{- end }} + defaultMode: 256 + items: + - key: id_rsa + path: id_rsa +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/netshoot/_container.tpl b/charts/cv/charts/helm-library-common/templates/addons/netshoot/_container.tpl new file mode 100644 index 0000000..3e7a429 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/netshoot/_container.tpl @@ -0,0 +1,27 @@ +{{/* +The netshoot sidecar container to be inserted. +*/}} +{{- define "common.addon.netshoot.container" -}} +name: netshoot +image: "{{ .Values.addons.netshoot.image.repository }}:{{ .Values.addons.netshoot.image.tag }}" +imagePullPolicy: {{ .Values.addons.netshoot.pullPolicy }} +{{- with .Values.addons.netshoot.securityContext }} +securityContext: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- with .Values.addons.netshoot.env }} +env: +{{- range $k, $v := . }} + - name: {{ $k }} + value: {{ $v | quote }} +{{- end }} +{{- end }} +command: + - /bin/sh + - -c + - sleep infinity +{{- with .Values.addons.netshoot.resources }} +resources: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/netshoot/_netshoot.tpl b/charts/cv/charts/helm-library-common/templates/addons/netshoot/_netshoot.tpl new file mode 100644 index 0000000..9a1e9fa --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/netshoot/_netshoot.tpl @@ -0,0 +1,13 @@ +{{/* +Template to render netshoot addon +It will include / inject the required templates based on the given values. +*/}} +{{- define "common.addon.netshoot" -}} +{{- if .Values.addons.netshoot.enabled -}} + {{/* Append the netshoot container to the additionalContainers */}} + {{- $container := include "common.addon.netshoot.container" . | fromYaml -}} + {{- if $container -}} + {{- $_ := set .Values.additionalContainers "addon-netshoot" $container -}} + {{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/promtail/_configmap.tpl b/charts/cv/charts/helm-library-common/templates/addons/promtail/_configmap.tpl new file mode 100644 index 0000000..3b92757 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/promtail/_configmap.tpl @@ -0,0 +1,35 @@ +{{/* +The promtail config to be included. +*/}} +{{- define "common.addon.promtail.configmap" -}} +{{- if .Values.addons.promtail.enabled }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "common.names.fullname" . }}-promtail + labels: + {{- include "common.labels" . | nindent 4 }} +data: + 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 -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/promtail/_container.tpl b/charts/cv/charts/helm-library-common/templates/addons/promtail/_container.tpl new file mode 100644 index 0000000..f4936bc --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/promtail/_container.tpl @@ -0,0 +1,39 @@ +{{/* +The promtail sidecar container to be inserted. +*/}} +{{- define "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: promtail-config + 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/cv/charts/helm-library-common/templates/addons/promtail/_promtail.tpl b/charts/cv/charts/helm-library-common/templates/addons/promtail/_promtail.tpl new file mode 100644 index 0000000..c8ef10f --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/promtail/_promtail.tpl @@ -0,0 +1,25 @@ +{{/* +Template to render promtail addon +It will include / inject the required templates based on the given values. +*/}} +{{- define "common.addon.promtail" -}} +{{- if .Values.addons.promtail.enabled -}} + {{/* Append the promtail container to the additionalContainers */}} + {{- $container := include "common.addon.promtail.container" . | fromYaml -}} + {{- if $container -}} + {{- $_ := set .Values.additionalContainers "addon-promtail" $container -}} + {{- end -}} + + {{/* Include the configmap if not empty */}} + {{- $configmap := include "common.addon.promtail.configmap" . -}} + {{- if $configmap -}} + {{- $configmap | nindent 0 -}} + {{- end -}} + + {{/* Append the promtail config volume to the volumes */}} + {{- $volume := include "common.addon.promtail.volumeSpec" . | fromYaml -}} + {{- if $volume -}} + {{- $_ := set .Values.persistence "promtail-config" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}} + {{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/promtail/_volume.tpl b/charts/cv/charts/helm-library-common/templates/addons/promtail/_volume.tpl new file mode 100644 index 0000000..bce624b --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/promtail/_volume.tpl @@ -0,0 +1,7 @@ +{{/* +The volume (referencing config) to be inserted into additionalVolumes. +*/}} +{{- define "common.addon.promtail.volumeSpec" -}} +configMap: + name: {{ include "common.names.fullname" . }}-promtail +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/_configmap.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/_configmap.tpl new file mode 100644 index 0000000..f57a696 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/_configmap.tpl @@ -0,0 +1,23 @@ +{{/* +The VPN config and scripts to be included. +*/}} +{{- define "common.addon.vpn.configmap" -}} +{{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "common.names.fullname" . }}-vpn + labels: + {{- include "common.labels" . | nindent 4 }} +data: +{{- with .Values.addons.vpn.scripts.up }} + up.sh: |- + {{- . | nindent 4}} +{{- end }} +{{- with .Values.addons.vpn.scripts.down }} + down.sh: |- + {{- . | nindent 4}} +{{- end }} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/_networkpolicy.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/_networkpolicy.tpl new file mode 100644 index 0000000..52faf2e --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/_networkpolicy.tpl @@ -0,0 +1,33 @@ +{{/* +Blueprint for the NetworkPolicy object that can be included in the addon. +*/}} +{{- define "common.addon.vpn.networkpolicy" -}} +{{- if .Values.addons.vpn.networkPolicy.enabled }} +--- +kind: NetworkPolicy +apiVersion: networking.k8s.io/v1 +metadata: + name: {{ include "common.names.fullname" . }} + labels: + {{- with .Values.addons.vpn.networkPolicy.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + annotations: + {{- with .Values.addons.vpn.networkPolicy.annotations }} + {{ toYaml . | nindent 4 }} + {{- end }} +spec: + podSelector: + matchLabels: + {{- include "common.labels.selectorLabels" . | nindent 6 }} + {{- with .Values.addons.vpn.networkPolicy.podSelectorLabels }} + {{ toYaml . | nindent 6 }} + {{- end }} + policyTypes: + - Egress + egress: + {{- with .Values.addons.vpn.networkPolicy.egress }} + {{- . | toYaml | nindent 4 }} + {{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/_secret.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/_secret.tpl new file mode 100644 index 0000000..43e1c27 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/_secret.tpl @@ -0,0 +1,19 @@ +{{/* +The OpenVPN config secret to be included. +*/}} +{{- define "common.addon.vpn.secret" -}} +{{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "common.names.fullname" . }}-vpnconfig + labels: + {{- include "common.labels" $ | nindent 4 }} +stringData: + {{- with .Values.addons.vpn.configFile }} + vpnConfigfile: |- + {{- . | nindent 4}} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/_volume.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/_volume.tpl new file mode 100644 index 0000000..184e2a9 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/_volume.tpl @@ -0,0 +1,37 @@ +{{/* +The volume (referencing VPN scripts) to be inserted into additionalVolumes. +*/}} +{{- define "common.addon.vpn.scriptsVolumeSpec" -}} +{{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down -}} +configMap: + name: {{ include "common.names.fullname" . }}-vpn + items: + {{- if .Values.addons.vpn.scripts.up }} + - key: up.sh + path: up.sh + mode: 0777 + {{- end }} + {{- if .Values.addons.vpn.scripts.down }} + - key: down.sh + path: down.sh + mode: 0777 + {{- end }} +{{- end -}} +{{- end -}} + +{{/* +The volume (referencing VPN config) to be inserted into additionalVolumes. +*/}} +{{- define "common.addon.vpn.configVolumeSpec" -}} +{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret -}} +secret: + {{- if .Values.addons.vpn.configFileSecret }} + secretName: {{ .Values.addons.vpn.configFileSecret }} + {{- else }} + secretName: {{ include "common.names.fullname" . }}-vpnconfig + {{- end }} + items: + - key: vpnConfigfile + path: vpnConfigfile +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/_vpn.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/_vpn.tpl new file mode 100644 index 0000000..fadd0e5 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/_vpn.tpl @@ -0,0 +1,45 @@ +{{/* +Template to render VPN addon +It will include / inject the required templates based on the given values. +*/}} +{{- define "common.addon.vpn" -}} +{{- if .Values.addons.vpn.enabled -}} + {{- if eq "openvpn" .Values.addons.vpn.type -}} + {{- include "common.addon.openvpn" . }} + {{- end -}} + + {{- if eq "wireguard" .Values.addons.vpn.type -}} + {{- include "common.addon.wireguard" . }} + {{- end -}} + + {{/* Include the configmap if not empty */}} + {{- $configmap := include "common.addon.vpn.configmap" . -}} + {{- if $configmap -}} + {{- $configmap | nindent 0 -}} + {{- end -}} + + {{/* Include the secret if not empty */}} + {{- $secret := include "common.addon.vpn.secret" . -}} + {{- if $secret -}} + {{- $secret | nindent 0 -}} + {{- end -}} + + {{/* Append the vpn scripts volume to the volumes */}} + {{- $scriptVolume := include "common.addon.vpn.scriptsVolumeSpec" . | fromYaml -}} + {{- if $scriptVolume -}} + {{- $_ := set .Values.persistence "vpnscript" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $scriptVolume) -}} + {{- end -}} + + {{/* Append the vpn config volume to the volumes */}} + {{- $configVolume := include "common.addon.vpn.configVolumeSpec" . | fromYaml }} + {{ if $configVolume -}} + {{- $_ := set .Values.persistence "vpnconfig" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $configVolume) -}} + {{- end -}} + + {{/* Include the networkpolicy if not empty */}} + {{- $networkpolicy := include "common.addon.vpn.networkpolicy" . -}} + {{- if $networkpolicy -}} + {{- $networkpolicy | nindent 0 -}} + {{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_addon.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_addon.tpl new file mode 100644 index 0000000..1cfcdd5 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_addon.tpl @@ -0,0 +1,17 @@ +{{/* +Template to render OpenVPN addon. It will add the container to the list of additionalContainers +and add a credentials secret if speciffied. +*/}} +{{- define "common.addon.openvpn" -}} + {{/* Append the openVPN container to the additionalContainers */}} + {{- $container := include "common.addon.openvpn.container" . | fromYaml -}} + {{- if $container -}} + {{- $_ := set .Values.additionalContainers "addon-openvpn" $container -}} + {{- end -}} + + {{/* Include the secret if not empty */}} + {{- $secret := include "common.addon.openvpn.secret" . -}} + {{- if $secret -}} + {{- $secret | nindent 0 -}} + {{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_container.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_container.tpl new file mode 100644 index 0000000..c6d9412 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_container.tpl @@ -0,0 +1,61 @@ +{{/* +The OpenVPN sidecar container to be inserted. +*/}} +{{- define "common.addon.openvpn.container" -}} +name: openvpn +image: "{{ .Values.addons.vpn.openvpn.image.repository }}:{{ .Values.addons.vpn.openvpn.image.tag }}" +imagePullPolicy: {{ .Values.addons.vpn.openvpn.pullPolicy }} +{{- with .Values.addons.vpn.securityContext }} +securityContext: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- with .Values.addons.vpn.env }} +env: +{{- range $k, $v := . }} + - name: {{ $k }} + value: {{ $v | quote }} +{{- end }} +{{- end }} +{{- if or .Values.addons.vpn.openvpn.auth .Values.addons.vpn.openvpn.authSecret }} +envFrom: + - secretRef: + {{- if .Values.addons.vpn.openvpn.authSecret }} + name: {{ .Values.addons.vpn.openvpn.authSecret }} + {{- else }} + name: {{ include "common.names.fullname" . }}-openvpn + {{- end }} +{{- end }} +{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down .Values.addons.vpn.additionalVolumeMounts .Values.persistence.shared.enabled }} +volumeMounts: +{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret }} + - name: vpnconfig + mountPath: /vpn/vpn.conf + subPath: vpnConfigfile +{{- end }} +{{- if .Values.addons.vpn.scripts.up }} + - name: vpnscript + mountPath: /vpn/up.sh + subPath: up.sh +{{- end }} +{{- if .Values.addons.vpn.scripts.down }} + - name: vpnscript + mountPath: /vpn/down.sh + subPath: down.sh +{{- end }} +{{- if .Values.persistence.shared.enabled }} + - mountPath: {{ .Values.persistence.shared.mountPath }} + name: shared +{{- end }} +{{- with .Values.addons.vpn.additionalVolumeMounts }} + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end }} +{{- with .Values.addons.vpn.livenessProbe }} +livenessProbe: + {{- toYaml . | nindent 2 }} +{{- end -}} +{{- with .Values.addons.vpn.resources }} +resources: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_secret.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_secret.tpl new file mode 100644 index 0000000..f1b6225 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/openvpn/_secret.tpl @@ -0,0 +1,16 @@ +{{/* +The OpenVPN credentials secrets to be included. +*/}} +{{- define "common.addon.openvpn.secret" -}} +{{- with .Values.addons.vpn.openvpn.auth }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "common.names.fullname" $ }}-openvpn + labels: + {{- include "common.labels" $ | nindent 4 }} +data: + VPN_AUTH: {{ . | b64enc }} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/wireguard/_addon.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/wireguard/_addon.tpl new file mode 100644 index 0000000..6c7ea35 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/wireguard/_addon.tpl @@ -0,0 +1,11 @@ +{{/* +Template to render Wireguard addon. It will add the container to the list of additionalContainers. +*/}} +*/}} +{{- define "common.addon.wireguard" -}} + {{/* Append the Wireguard container to the additionalContainers */}} + {{- $container := fromYaml (include "common.addon.wireguard.container" .) -}} + {{- if $container -}} + {{- $_ := set .Values.additionalContainers "addon-wireguard" $container -}} + {{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/addons/vpn/wireguard/_container.tpl b/charts/cv/charts/helm-library-common/templates/addons/vpn/wireguard/_container.tpl new file mode 100644 index 0000000..b6e1494 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/addons/vpn/wireguard/_container.tpl @@ -0,0 +1,52 @@ +{{/* +The Wireguard sidecar container to be inserted. +*/}} +{{- define "common.addon.wireguard.container" -}} +name: wireguard +image: "{{ .Values.addons.vpn.wireguard.image.repository }}:{{ .Values.addons.vpn.wireguard.image.tag }}" +imagePullPolicy: {{ .Values.addons.vpn.wireguard.pullPolicy }} +{{- with .Values.addons.vpn.securityContext }} +securityContext: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- with .Values.addons.vpn.env }} +env: +{{- range $k, $v := . }} + - name: {{ $k }} + value: {{ $v | quote }} +{{- end }} +{{- end }} +{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down .Values.addons.vpn.additionalVolumeMounts .Values.persistence.shared.enabled }} +volumeMounts: +{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret }} + - name: vpnconfig + mountPath: /etc/wireguard/wg0.conf + subPath: vpnConfigfile +{{- end }} +{{- if .Values.addons.vpn.scripts.up }} + - name: vpnscript + mountPath: /config/up.sh + subPath: up.sh +{{- end }} +{{- if .Values.addons.vpn.scripts.down }} + - name: vpnscript + mountPath: /config/down.sh + subPath: down.sh +{{- end }} +{{- if .Values.persistence.shared.enabled }} + - mountPath: {{ .Values.persistence.shared.mountPath }} + name: shared +{{- end }} +{{- with .Values.addons.vpn.additionalVolumeMounts }} + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end }} +{{- with .Values.addons.vpn.livenessProbe }} +livenessProbe: + {{- toYaml . | nindent 2 }} +{{- end -}} +{{- with .Values.addons.vpn.resources }} +resources: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/classes/_HorizontalPodAutoscaler.tpl b/charts/cv/charts/helm-library-common/templates/classes/_HorizontalPodAutoscaler.tpl new file mode 100644 index 0000000..1c448ac --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/classes/_HorizontalPodAutoscaler.tpl @@ -0,0 +1,37 @@ +{{/* +This template serves as a blueprint for horizontal pod autoscaler objects that are created +using the common library. +*/}} +{{- define "common.classes.hpa" -}} + {{- if .Values.autoscaling.enabled -}} + {{- $hpaName := include "common.names.fullname" . -}} + {{- $targetName := include "common.names.fullname" . }} +--- +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ $hpaName }} + labels: + {{- include "common.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: {{ include "common.names.controllerType" . }} + name: {{ .Values.autoscaling.target | default $targetName }} + minReplicas: {{ .Values.autoscaling.minReplicas | default 1 }} + maxReplicas: {{ .Values.autoscaling.maxReplicas | default 3 }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} + {{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/classes/_configmap.tpl b/charts/cv/charts/helm-library-common/templates/classes/_configmap.tpl new file mode 100644 index 0000000..31d841d --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/classes/_configmap.tpl @@ -0,0 +1,37 @@ +{{/* +This template serves as a blueprint for all configMap objects that are created +within the common library. +*/}} +{{- define "common.classes.configmap" -}} + {{- $fullName := include "common.names.fullname" . -}} + {{- $configMapName := $fullName -}} + {{- $values := .Values.configmap -}} + + {{- if hasKey . "ObjectValues" -}} + {{- with .ObjectValues.configmap -}} + {{- $values = . -}} + {{- end -}} + {{ end -}} + + {{- if and (hasKey $values "nameOverride") $values.nameOverride -}} + {{- $configMapName = printf "%v-%v" $configMapName $values.nameOverride -}} + {{- end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ $configMapName }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with $values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with $values.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +data: +{{- with $values.data }} + {{- tpl (toYaml .) $ | nindent 2 }} +{{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/classes/_ingress.tpl b/charts/cv/charts/helm-library-common/templates/classes/_ingress.tpl new file mode 100644 index 0000000..badd8dd --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/classes/_ingress.tpl @@ -0,0 +1,85 @@ +{{/* +This template serves as a blueprint for all Ingress objects that are created +within the common library. +*/}} +{{- define "common.classes.ingress" -}} + {{- $fullName := include "common.names.fullname" . -}} + {{- $ingressName := $fullName -}} + {{- $values := .Values.ingress -}} + + {{- if hasKey . "ObjectValues" -}} + {{- with .ObjectValues.ingress -}} + {{- $values = . -}} + {{- end -}} + {{ end -}} + + {{- if and (hasKey $values "nameOverride") $values.nameOverride -}} + {{- $ingressName = printf "%v-%v" $ingressName $values.nameOverride -}} + {{- end -}} + + {{- $primaryService := get .Values.service (include "common.service.primary" .) -}} + {{- $defaultServiceName := $fullName -}} + {{- if and (hasKey $primaryService "nameOverride") $primaryService.nameOverride -}} + {{- $defaultServiceName = printf "%v-%v" $defaultServiceName $primaryService.nameOverride -}} + {{- end -}} + {{- $defaultServicePort := get $primaryService.ports (include "common.classes.service.ports.primary" (dict "values" $primaryService)) -}} + {{- $isStable := include "common.capabilities.ingress.isStable" . }} +--- +apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }} +kind: Ingress +metadata: + name: {{ $ingressName }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with $values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with $values.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and $isStable $values.ingressClassName }} + ingressClassName: {{ $values.ingressClassName }} + {{- end }} + {{- if $values.tls }} + tls: + {{- range $values.tls }} + - hosts: + {{- range .hosts }} + - {{ tpl . $ | quote }} + {{- end }} + {{- if .secretName }} + secretName: {{ tpl .secretName $ | quote}} + {{- end }} + {{- end }} + {{- end }} + rules: + {{- range $values.hosts }} + - host: {{ tpl .host $ | quote }} + http: + paths: + {{- range .paths }} + {{- $service := $defaultServiceName -}} + {{- $port := $defaultServicePort.port -}} + {{- if .service -}} + {{- $service = default $service .service.name -}} + {{- $port = default $port .service.port -}} + {{- end }} + - path: {{ tpl .path $ | quote }} + {{- if $isStable }} + pathType: {{ default "Prefix" .pathType }} + {{- end }} + backend: + {{- if $isStable }} + service: + name: {{ $service }} + port: + number: {{ $port }} + {{- else }} + serviceName: {{ $service }} + servicePort: {{ $port }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/classes/_pvc.tpl b/charts/cv/charts/helm-library-common/templates/classes/_pvc.tpl new file mode 100644 index 0000000..ffc512c --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/classes/_pvc.tpl @@ -0,0 +1,49 @@ +{{/* +This template serves as a blueprint for all PersistentVolumeClaim objects that are created +within the common library. +*/}} +{{- define "common.classes.pvc" -}} +{{- $values := .Values.persistence -}} +{{- if hasKey . "ObjectValues" -}} + {{- with .ObjectValues.persistence -}} + {{- $values = . -}} + {{- end -}} +{{ end -}} +{{- $pvcName := include "common.names.fullname" . -}} +{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} + {{- if not (eq $values.nameOverride "-") -}} + {{- $pvcName = printf "%v-%v" $pvcName $values.nameOverride -}} + {{ end -}} +{{ end }} +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ $pvcName }} + {{- if or $values.retain $values.annotations }} + annotations: + {{- if $values.retain }} + "helm.sh/resource-policy": keep + {{- end }} + {{- with $values.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with $values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + accessModes: + - {{ required (printf "accessMode is required for PVC %v" $pvcName) $values.accessMode | quote }} + resources: + requests: + storage: {{ required (printf "size is required for PVC %v" $pvcName) $values.size | quote }} + {{- if $values.storageClass }} + storageClassName: {{ if (eq "-" $values.storageClass) }}""{{- else }}{{ $values.storageClass | quote }}{{- end }} + {{- end }} + {{- if $values.volumeName }} + volumeName: {{ $values.volumeName | quote }} + {{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/classes/_service.tpl b/charts/cv/charts/helm-library-common/templates/classes/_service.tpl new file mode 100644 index 0000000..a1d2c32 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/classes/_service.tpl @@ -0,0 +1,100 @@ +{{/* +This template serves as a blueprint for all Service objects that are created +within the common library. +*/}} +{{- define "common.classes.service" -}} +{{- $values := .Values.service -}} +{{- if hasKey . "ObjectValues" -}} + {{- with .ObjectValues.service -}} + {{- $values = . -}} + {{- end -}} +{{ end -}} + +{{- $serviceName := include "common.names.fullname" . -}} +{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} + {{- $serviceName = printf "%v-%v" $serviceName $values.nameOverride -}} +{{ end -}} +{{- $svcType := $values.type | default "" -}} +{{- $primaryPort := get $values.ports (include "common.classes.service.ports.primary" (dict "values" $values)) }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ $serviceName }} + labels: + {{- include "common.labels" . | nindent 4 }} + {{- with $values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + annotations: + {{- if eq ( $primaryPort.protocol | default "" ) "HTTPS" }} + traefik.ingress.kubernetes.io/service.serversscheme: https + {{- end }} + {{- with $values.annotations }} + {{ toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if (or (eq $svcType "ClusterIP") (empty $svcType)) }} + type: ClusterIP + {{- if $values.clusterIP }} + clusterIP: {{ $values.clusterIP }} + {{end}} + {{- else if eq $svcType "LoadBalancer" }} + type: {{ $svcType }} + {{- if $values.loadBalancerIP }} + loadBalancerIP: {{ $values.loadBalancerIP }} + {{- end }} + {{- if $values.externalTrafficPolicy }} + externalTrafficPolicy: {{ $values.externalTrafficPolicy }} + {{- end }} + {{- if $values.loadBalancerSourceRanges }} + loadBalancerSourceRanges: + {{ toYaml $values.loadBalancerSourceRanges | nindent 4 }} + {{- end -}} + {{- else }} + type: {{ $svcType }} + {{- end }} + {{- if $values.sessionAffinity }} + sessionAffinity: {{ $values.sessionAffinity }} + {{- if $values.sessionAffinityConfig }} + sessionAffinityConfig: + {{ toYaml $values.sessionAffinityConfig | nindent 4 }} + {{- end -}} + {{- end }} + {{- with $values.externalIPs }} + externalIPs: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- if $values.publishNotReadyAddresses }} + publishNotReadyAddresses: {{ $values.publishNotReadyAddresses }} + {{- end }} + {{- if $values.ipFamilyPolicy }} + ipFamilyPolicy: {{ $values.ipFamilyPolicy }} + {{- end }} + {{- with $values.ipFamilies }} + ipFamilies: + {{ 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 }} + selector: + {{- include "common.labels.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/classes/_service_ports.tpl b/charts/cv/charts/helm-library-common/templates/classes/_service_ports.tpl new file mode 100644 index 0000000..32cae4c --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/classes/_service_ports.tpl @@ -0,0 +1,27 @@ +{{/* +Return the primary port for a given Service object. +*/}} +{{- define "common.classes.service.ports.primary" -}} + {{- $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 }} + + {{- $result := "" -}} + {{- range $name, $port := $enabledPorts -}} + {{- if and (hasKey $port "primary") $port.primary -}} + {{- $result = $name -}} + {{- end -}} + {{- end -}} + + {{- if not $result -}} + {{- $result = keys $enabledPorts | first -}} + {{- end -}} + {{- $result -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/chart/_capabilities.tpl b/charts/cv/charts/helm-library-common/templates/lib/chart/_capabilities.tpl new file mode 100644 index 0000000..96de3c1 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/chart/_capabilities.tpl @@ -0,0 +1,19 @@ +{{/* Allow KubeVersion to be overridden. */}} +{{- define "common.capabilities.ingress.kubeVersion" -}} + {{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}} +{{- end -}} + +{{/* Return the appropriate apiVersion for Ingress objects */}} +{{- define "common.capabilities.ingress.apiVersion" -}} + {{- print "networking.k8s.io/v1" -}} + {{- if semverCompare "<1.19" (include "common.capabilities.ingress.kubeVersion" .) -}} + {{- print "beta1" -}} + {{- end -}} +{{- end -}} + +{{/* Check Ingress stability */}} +{{- define "common.capabilities.ingress.isStable" -}} + {{- if eq (include "common.capabilities.ingress.apiVersion" .) "networking.k8s.io/v1" -}} + {{- true -}} + {{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/chart/_labels.tpl b/charts/cv/charts/helm-library-common/templates/lib/chart/_labels.tpl new file mode 100644 index 0000000..8a1e11a --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/chart/_labels.tpl @@ -0,0 +1,15 @@ +{{/* Common labels shared across objects */}} +{{- define "common.labels" -}} +helm.sh/chart: {{ include "common.names.chart" . }} +{{ include "common.labels.selectorLabels" . }} + {{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + {{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* Selector labels shared across objects */}} +{{- define "common.labels.selectorLabels" -}} +app.kubernetes.io/name: {{ include "common.names.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/chart/_names.tpl b/charts/cv/charts/helm-library-common/templates/lib/chart/_names.tpl new file mode 100644 index 0000000..a32d572 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/chart/_names.tpl @@ -0,0 +1,58 @@ +{{/* Expand the name of the chart */}} +{{- define "common.names.name" -}} + {{- $globalNameOverride := "" -}} + {{- if hasKey .Values "global" -}} + {{- $globalNameOverride = (default $globalNameOverride .Values.global.nameOverride) -}} + {{- end -}} + {{- default .Chart.Name (default .Values.nameOverride $globalNameOverride) | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "common.names.fullname" -}} + {{- $name := include "common.names.name" . -}} + {{- $globalFullNameOverride := "" -}} + {{- if hasKey .Values "global" -}} + {{- $globalFullNameOverride = (default $globalFullNameOverride .Values.global.fullnameOverride) -}} + {{- end -}} + {{- if or .Values.fullnameOverride $globalFullNameOverride -}} + {{- $name = default .Values.fullnameOverride $globalFullNameOverride -}} + {{- else -}} + {{- if contains $name .Release.Name -}} + {{- $name = .Release.Name -}} + {{- else -}} + {{- $name = printf "%s-%s" .Release.Name $name -}} + {{- end -}} + {{- end -}} + {{- trunc 63 $name | trimSuffix "-" -}} +{{- end -}} + +{{/* Create chart name and version as used by the chart label */}} +{{- define "common.names.chart" -}} + {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* Create the name of the ServiceAccount to use */}} +{{- define "common.names.serviceAccountName" -}} + {{- if .Values.serviceAccount.create -}} + {{- default (include "common.names.fullname" .) .Values.serviceAccount.name -}} + {{- else -}} + {{- default "default" .Values.serviceAccount.name -}} + {{- end -}} +{{- end -}} + +{{/* Return the properly cased version of the controller type */}} +{{- define "common.names.controllerType" -}} + {{- if eq .Values.controller.type "deployment" -}} + {{- print "Deployment" -}} + {{- else if eq .Values.controller.type "daemonset" -}} + {{- print "DaemonSet" -}} + {{- else if eq .Values.controller.type "statefulset" -}} + {{- print "StatefulSet" -}} + {{- else -}} + {{- fail (printf "Not a valid controller.type (%s)" .Values.controller.type) -}} + {{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/chart/_values.tpl b/charts/cv/charts/helm-library-common/templates/lib/chart/_values.tpl new file mode 100644 index 0000000..d3c8413 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/chart/_values.tpl @@ -0,0 +1,9 @@ +{{/* Merge the local chart values and the common chart defaults */}} +{{- define "common.values.setup" -}} + {{- if .Values.common -}} + {{- $defaultValues := deepCopy .Values.common -}} + {{- $userValues := deepCopy (omit .Values "common") -}} + {{- $mergedValues := mustMergeOverwrite $defaultValues $userValues -}} + {{- $_ := set . "Values" (deepCopy $mergedValues) -}} + {{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/controller/_container.tpl b/charts/cv/charts/helm-library-common/templates/lib/controller/_container.tpl new file mode 100644 index 0000000..300cdeb --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/controller/_container.tpl @@ -0,0 +1,84 @@ +{{- /* The main container included in the controller */ -}} +{{- define "common.controller.mainContainer" -}} +- name: {{ include "common.names.fullname" . }} + image: {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- with .Values.command }} + command: + {{- if kindIs "string" . }} + - {{ . }} + {{- else }} + {{ toYaml . | nindent 4 }} + {{- end }} + {{- end }} + {{- with .Values.args }} + args: + {{- if kindIs "string" . }} + - {{ . }} + {{- else }} + {{ toYaml . | nindent 4 }} + {{- end }} + {{- end }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.lifecycle }} + lifecycle: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.termination.messagePath }} + terminationMessagePath: {{ . }} + {{- end }} + {{- with .Values.termination.messagePolicy }} + terminationMessagePolicy: {{ . }} + {{- end }} + + {{- with .Values.env }} + env: + {{- range $k, $v := . }} + {{- $name := $k }} + {{- $value := $v }} + {{- if kindIs "int" $name }} + {{- $name = required "environment variables as a list of maps require a name field" $value.name }} + {{- end }} + - name: {{ quote $name }} + {{- if kindIs "map" $value -}} + {{- if hasKey $value "value" }} + {{- $value = $value.value -}} + {{- else if hasKey $value "valueFrom" }} + {{- toYaml $value | nindent 6 }} + {{- else }} + {{- dict "valueFrom" $value | toYaml | nindent 6 }} + {{- end }} + {{- end }} + {{- if not (kindIs "map" $value) }} + {{- if kindIs "string" $value }} + {{- $value = tpl $value $ }} + {{- end }} + value: {{ quote $value }} + {{- end }} + {{- end }} + {{- end }} + {{- if or .Values.envFrom .Values.secret }} + envFrom: + {{- with .Values.envFrom }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- if .Values.secret }} + - secretRef: + name: {{ include "common.names.fullname" . }} + {{- end }} + {{- end }} + ports: + {{- include "common.controller.ports" . | trim | nindent 4 }} + {{- with (include "common.controller.volumeMounts" . | trim) }} + volumeMounts: + {{- nindent 4 . }} + {{- end }} + {{- include "common.controller.probes" . | trim | nindent 2 }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/controller/_pod.tpl b/charts/cv/charts/helm-library-common/templates/lib/controller/_pod.tpl new file mode 100644 index 0000000..cc721bf --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/controller/_pod.tpl @@ -0,0 +1,90 @@ +{{- /* +The pod definition included in the controller. +*/ -}} +{{- define "common.controller.pod" -}} + {{- with .Values.imagePullSecrets }} +imagePullSecrets: + {{- toYaml . | nindent 2 }} + {{- end }} +serviceAccountName: {{ include "common.names.serviceAccountName" . }} +automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} + {{- with .Values.podSecurityContext }} +securityContext: + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.priorityClassName }} +priorityClassName: {{ . }} + {{- end }} + {{- with .Values.schedulerName }} +schedulerName: {{ . }} + {{- end }} + {{- with .Values.hostNetwork }} +hostNetwork: {{ . }} + {{- end }} + {{- with .Values.hostname }} +hostname: {{ . }} + {{- end }} + {{- if .Values.dnsPolicy }} +dnsPolicy: {{ .Values.dnsPolicy }} + {{- else if .Values.hostNetwork }} +dnsPolicy: ClusterFirstWithHostNet + {{- else }} +dnsPolicy: ClusterFirst + {{- end }} + {{- with .Values.dnsConfig }} +dnsConfig: + {{- toYaml . | nindent 2 }} + {{- end }} +enableServiceLinks: {{ .Values.enableServiceLinks }} + {{- with .Values.termination.gracePeriodSeconds }} +terminationGracePeriodSeconds: {{ . }} + {{- end }} + {{- if .Values.initContainers }} +initContainers: + {{- $initContainers := list }} + {{- range $index, $key := (keys .Values.initContainers | uniq | sortAlpha) }} + {{- $container := get $.Values.initContainers $key }} + {{- if not $container.name -}} + {{- $_ := set $container "name" $key }} + {{- end }} + {{- $initContainers = append $initContainers $container }} + {{- end }} + {{- tpl (toYaml $initContainers) $ | nindent 2 }} + {{- end }} +containers: + {{- include "common.controller.mainContainer" . | nindent 2 }} + {{- with .Values.additionalContainers }} + {{- $additionalContainers := list }} + {{- range $name, $container := . }} + {{- if not $container.name -}} + {{- $_ := set $container "name" $name }} + {{- end }} + {{- $additionalContainers = append $additionalContainers $container }} + {{- end }} + {{- tpl (toYaml $additionalContainers) $ | nindent 2 }} + {{- end }} + {{- with (include "common.controller.volumes" . | trim) }} +volumes: + {{- nindent 2 . }} + {{- end }} + {{- with .Values.hostAliases }} +hostAliases: + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.nodeSelector }} +nodeSelector: + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.affinity }} +affinity: + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.topologySpreadConstraints }} +topologySpreadConstraints: + {{- toYaml . | nindent 2 }} + {{- end }} + {{- with .Values.tolerations }} +tolerations: + {{- toYaml . | nindent 2 }} + {{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/controller/_ports.tpl b/charts/cv/charts/helm-library-common/templates/lib/controller/_ports.tpl new file mode 100644 index 0000000..5394690 --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/controller/_ports.tpl @@ -0,0 +1,36 @@ +{{/* +Ports included by the controller. +*/}} +{{- define "common.controller.ports" -}} + {{- $ports := list -}} + {{- range .Values.service -}} + {{- if .enabled -}} + {{- range $name, $port := .ports -}} + {{- $_ := set $port "name" $name -}} + {{- $ports = mustAppend $ports $port -}} + {{- end }} + {{- end }} + {{- end }} + +{{/* export/render the list of ports */}} +{{- if $ports -}} +{{- range $_ := $ports }} +{{- if .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) }} + {{- end }} + containerPort: {{ .targetPort | default .port }} + {{- if .protocol }} + {{- if or ( eq .protocol "HTTP" ) ( eq .protocol "HTTPS" ) ( eq .protocol "TCP" ) }} + protocol: TCP + {{- else }} + protocol: {{ .protocol }} + {{- end }} + {{- else }} + protocol: TCP + {{- end }} +{{- end}} +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/controller/_probes.tpl b/charts/cv/charts/helm-library-common/templates/lib/controller/_probes.tpl new file mode 100644 index 0000000..3b64a5e --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/controller/_probes.tpl @@ -0,0 +1,33 @@ +{{/* +Probes selection logic. +*/}} +{{- define "common.controller.probes" -}} +{{- $primaryService := get .Values.service (include "common.service.primary" .) -}} +{{- $primaryPort := "" -}} +{{- if $primaryService -}} + {{- $primaryPort = get $primaryService.ports (include "common.classes.service.ports.primary" (dict "serviceName" (include "common.service.primary" .) "values" $primaryService)) -}} +{{- end -}} + +{{- range $probeName, $probe := .Values.probes }} + {{- if $probe.enabled -}} + {{- "" | nindent 0 }} + {{- $probeName }}Probe: + {{- if $probe.custom -}} + {{- $probe.spec | toYaml | nindent 2 }} + {{- else }} + {{- if and $primaryService $primaryPort -}} + {{- "tcpSocket:" | nindent 2 }} + {{- if $primaryPort.targetPort }} + {{- printf "port: %v" $primaryPort.targetPort | nindent 4 }} + {{- else}} + {{- printf "port: %v" $primaryPort.port | nindent 4 }} + {{- end }} + {{- printf "initialDelaySeconds: %v" $probe.spec.initialDelaySeconds | nindent 2 }} + {{- printf "failureThreshold: %v" $probe.spec.failureThreshold | nindent 2 }} + {{- printf "timeoutSeconds: %v" $probe.spec.timeoutSeconds | nindent 2 }} + {{- printf "periodSeconds: %v" $probe.spec.periodSeconds | nindent 2 }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/templates/lib/controller/_volumemounts.tpl b/charts/cv/charts/helm-library-common/templates/lib/controller/_volumemounts.tpl new file mode 100644 index 0000000..8b05c9e --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/controller/_volumemounts.tpl @@ -0,0 +1,56 @@ +{{/* Volumes included by the controller */}} +{{- define "common.controller.volumeMounts" -}} + {{- range $persistenceIndex, $persistenceItem := .Values.persistence }} + {{- if $persistenceItem.enabled -}} + {{- if kindIs "slice" $persistenceItem.subPath -}} + {{- if $persistenceItem.mountPath -}} + {{- fail (printf "Cannot use persistence.mountPath with a subPath list (%s)" $persistenceIndex) }} + {{- end -}} + {{- range $subPathIndex, $subPathItem := $persistenceItem.subPath }} +- name: {{ $persistenceIndex }} + subPath: {{ required "subPaths as a list of maps require a path field" $subPathItem.path }} + mountPath: {{ required "subPaths as a list of maps require an explicit mountPath field" $subPathItem.mountPath }} + {{- with $subPathItem.readOnly }} + readOnly: {{ . }} + {{- end }} + {{- with $subPathItem.mountPropagation }} + mountPropagation: {{ . }} + {{- end }} + {{- end -}} + {{- else -}} + {{/* Set the default mountPath to / */}} + {{- $mountPath := (printf "/%v" $persistenceIndex) -}} + {{- if eq "hostPath" (default "pvc" $persistenceItem.type) -}} + {{- $mountPath = $persistenceItem.hostPath -}} + {{- end -}} + {{/* Use the specified mountPath if provided */}} + {{- with $persistenceItem.mountPath -}} + {{- $mountPath = . -}} + {{- end }} + {{- if ne $mountPath "-" }} +- name: {{ $persistenceIndex }} + mountPath: {{ $mountPath }} + {{- with $persistenceItem.subPath }} + subPath: {{ . }} + {{- end }} + {{- with $persistenceItem.readOnly }} + readOnly: {{ . }} + {{- end }} + {{- with $persistenceItem.mountPropagation }} + mountPropagation: {{ . }} + {{- end }} + {{- end }} + {{- end -}} + {{- end -}} + {{- end }} + + {{- if eq .Values.controller.type "statefulset" }} + {{- range $index, $vct := .Values.volumeClaimTemplates }} +- mountPath: {{ $vct.mountPath }} + name: {{ $vct.name }} + {{- if $vct.subPath }} + subPath: {{ $vct.subPath }} + {{- end }} + {{- end }} + {{- end }} +{{- end -}} diff --git a/charts/cv/charts/helm-library-common/templates/lib/controller/_volumes.tpl b/charts/cv/charts/helm-library-common/templates/lib/controller/_volumes.tpl new file mode 100644 index 0000000..5e86a7c --- /dev/null +++ b/charts/cv/charts/helm-library-common/templates/lib/controller/_volumes.tpl @@ -0,0 +1,64 @@ +{{/* +Volumes included by the controller. +*/}} +{{- define "common.controller.volumes" -}} +{{- range $index, $persistence := .Values.persistence }} +{{- if $persistence.enabled }} +- name: {{ $index }} + {{- if eq (default "pvc" $persistence.type) "pvc" }} + {{- $pvcName := (include "common.names.fullname" $) -}} + {{- if $persistence.existingClaim }} + {{- /* Always prefer an existingClaim if that is set */}} + {{- $pvcName = $persistence.existingClaim -}} + {{- else -}} + {{- /* Otherwise refer to the PVC name */}} + {{- if $persistence.nameOverride -}} + {{- if not (eq $persistence.nameOverride "-") -}} + {{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $persistence.nameOverride) -}} + {{- end -}} + {{- else -}} + {{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $index) -}} + {{- end -}} + {{- end }} + persistentVolumeClaim: + claimName: {{ $pvcName }} + {{- else if or (eq $persistence.type "configMap") (eq $persistence.type "secret") }} + {{- $objectName := (required (printf "name not set for persistence item %s" $index) $persistence.name) }} + {{- $objectName = tpl $objectName $ }} + {{- if eq $persistence.type "configMap" }} + configMap: + name: {{ $objectName }} + {{- else }} + secret: + secretName: {{ $objectName }} + {{- end }} + {{- with $persistence.defaultMode }} + defaultMode: {{ . }} + {{- end }} + {{- with $persistence.items }} + items: + {{- toYaml . | nindent 6 }} + {{- end }} + {{- else if eq $persistence.type "emptyDir" }} + {{- $emptyDir := dict -}} + {{- with $persistence.medium -}} + {{- $_ := set $emptyDir "medium" . -}} + {{- end -}} + {{- with $persistence.sizeLimit -}} + {{- $_ := set $emptyDir "sizeLimit" . -}} + {{- end }} + emptyDir: {{- $emptyDir | toYaml | nindent 4 }} + {{- else if eq $persistence.type "hostPath" }} + hostPath: + path: {{ required "hostPath not set" $persistence.hostPath }} + {{- with $persistence.hostPathType }} + type: {{ . }} + {{- end }} + {{- else if eq $persistence.type "custom" }} + {{- toYaml $persistence.volumeSpec | nindent 2 }} + {{- else }} + {{- fail (printf "Not a valid persistence.type (%s)" .Values.persistence.type) }} + {{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/cv/charts/helm-library-common/tests/addon_codeserver_test.go b/charts/cv/charts/helm-library-common/tests/addon_codeserver_test.go new file mode 100644 index 0000000..e6ac4c3 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/addon_codeserver_test.go @@ -0,0 +1,136 @@ +package common + +import ( + "testing" + + "github.com/Jeffail/gabs/v2" + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type AddonCodeserverTestSuite struct { + suite.Suite + Chart helmunit.HelmChart + baseValues string +} + +func (suite *AddonCodeserverTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() + suite.baseValues = ` + addons: + codeserver: + enabled: true + volumeMounts: + - name: "config" + mountPath: "/data/config" + ` +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestAddonCodeserver(t *testing.T) { + suite.Run(t, new(AddonCodeserverTestSuite)) +} + +func (suite *AddonCodeserverTestSuite) TestContainer() { + tests := map[string]struct { + values *string + expectedCodeserverContainer bool + }{ + "Default": {values: nil, expectedCodeserverContainer: false}, + "AddonEnabled": {values: &suite.baseValues, expectedCodeserverContainer: true}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, nil, tc.values) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + + var codeserverContainer *gabs.Container + for _, container := range containers { + containerName := container.Path("name").Data().(string) + if containerName == "codeserver" { + codeserverContainer = container + break + } + } + + if tc.expectedCodeserverContainer { + suite.Assertions.NotEmpty(codeserverContainer) + } else { + suite.Assertions.Empty(codeserverContainer) + } + }) + } +} + +func (suite *AddonCodeserverTestSuite) TestDeployKey() { + tests := map[string]struct { + values []string + expectSecret bool + expectedSecretName string + }{ + "Inline": {values: []string{"addons.codeserver.git.deployKey=test"}, expectSecret: true, expectedSecretName: "common-test-deploykey"}, + "InlineBase64": {values: []string{"addons.codeserver.git.deployKeyBase64=dGVzdEtleQ=="}, expectSecret: true, expectedSecretName: "common-test-deploykey"}, + "ExistingSecret": {values: []string{"addons.codeserver.git.deployKeySecret=test-secret"}, expectSecret: false, expectedSecretName: "test-secret"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, &suite.baseValues) + if err != nil { + suite.FailNow(err.Error()) + } + + secretManifest := suite.Chart.Manifests.Get("Secret", tc.expectedSecretName) + if tc.expectSecret { + suite.Assertions.NotEmpty(secretManifest) + } else { + suite.Assertions.Empty(secretManifest) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + var codeserverContainer *gabs.Container + for _, container := range containers { + containerName := container.Path("name").Data().(string) + if containerName == "codeserver" { + codeserverContainer = container + break + } + } + suite.Assertions.NotEmpty(codeserverContainer) + + volumeMounts := codeserverContainer.Path("volumeMounts").Children() + var gitDeploykeyVolumeMount *gabs.Container + for _, volumeMount := range volumeMounts { + volumeMountName := volumeMount.Path("name").Data().(string) + if volumeMountName == "deploykey" { + gitDeploykeyVolumeMount = volumeMount + break + } + } + suite.Assertions.NotEmpty(gitDeploykeyVolumeMount) + suite.Assertions.EqualValues("/root/.ssh/id_rsa", gitDeploykeyVolumeMount.Path("mountPath").Data()) + suite.Assertions.EqualValues("id_rsa", gitDeploykeyVolumeMount.Path("subPath").Data()) + + volumes := deploymentManifest.Path("spec.template.spec.volumes").Children() + var gitDeploykeyVolume *gabs.Container + for _, volume := range volumes { + volumeName := volume.Path("name").Data().(string) + if volumeName == "deploykey" { + gitDeploykeyVolume = volume + break + } + } + suite.Assertions.NotEmpty(gitDeploykeyVolume) + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/addon_netshoot_test.go b/charts/cv/charts/helm-library-common/tests/addon_netshoot_test.go new file mode 100644 index 0000000..3b82ea8 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/addon_netshoot_test.go @@ -0,0 +1,64 @@ +package common + +import ( + "testing" + + "github.com/Jeffail/gabs/v2" + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type AddonNetshootTestSuite struct { + suite.Suite + Chart helmunit.HelmChart + baseValues []string +} + +func (suite *AddonNetshootTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() + suite.baseValues = []string{"addons.netshoot.enabled=true"} +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestAddonNetshoot(t *testing.T) { + suite.Run(t, new(AddonNetshootTestSuite)) +} + +func (suite *AddonNetshootTestSuite) TestContainer() { + tests := map[string]struct { + values []string + expectedNetshootContainer bool + }{ + "Default": {values: nil, expectedNetshootContainer: false}, + "AddonEnabled": {values: suite.baseValues, expectedNetshootContainer: true}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + + var netshootContainer *gabs.Container + for _, container := range containers { + containerName := container.Path("name").Data().(string) + if containerName == "netshoot" { + netshootContainer = container + break + } + } + + if tc.expectedNetshootContainer { + suite.Assertions.NotEmpty(netshootContainer) + } else { + suite.Assertions.Empty(netshootContainer) + } + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/addon_vpn_test.go b/charts/cv/charts/helm-library-common/tests/addon_vpn_test.go new file mode 100644 index 0000000..864ced0 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/addon_vpn_test.go @@ -0,0 +1,129 @@ +package common + +import ( + "testing" + + "github.com/Jeffail/gabs/v2" + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type AddonVpnTestSuite struct { + suite.Suite + Chart helmunit.HelmChart + baseValues []string +} + +func (suite *AddonVpnTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() + suite.baseValues = []string{"addons.vpn.enabled=true"} +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestAddonVpn(t *testing.T) { + suite.Run(t, new(AddonVpnTestSuite)) +} + +func (suite *AddonVpnTestSuite) TestContainer() { + tests := map[string]struct { + values []string + expectedVpnContainer bool + }{ + "Default": {values: nil, expectedVpnContainer: false}, + "AddonEnabled": {values: suite.baseValues, expectedVpnContainer: true}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + + var vpnContainer *gabs.Container + for _, container := range containers { + containerName := container.Path("name").Data().(string) + if containerName == "openvpn" { + vpnContainer = container + break + } + } + + if tc.expectedVpnContainer { + suite.Assertions.NotEmpty(vpnContainer) + } else { + suite.Assertions.Empty(vpnContainer) + } + }) + } +} + +func (suite *AddonVpnTestSuite) TestConfiguration() { + tests := map[string]struct { + values []string + expectSecret bool + expectedSecretName string + }{ + "InlineConfig": {values: append(suite.baseValues, "addons.vpn.configFile=test"), expectSecret: true, expectedSecretName: "common-test-vpnconfig"}, + "ExistingSecret": {values: append(suite.baseValues, "addons.vpn.configFileSecret=test-secret"), expectSecret: false, expectedSecretName: "test-secret"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + secretManifest := suite.Chart.Manifests.Get("Secret", tc.expectedSecretName) + if tc.expectSecret { + suite.Assertions.NotEmpty(secretManifest) + } else { + suite.Assertions.Empty(secretManifest) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + var vpnContainer *gabs.Container + for _, container := range containers { + containerName := container.Path("name").Data().(string) + if containerName == "openvpn" { + vpnContainer = container + break + } + } + suite.Assertions.NotEmpty(vpnContainer) + + volumeMounts := vpnContainer.Path("volumeMounts").Children() + var vpnConfigVolumeMount *gabs.Container + for _, volumeMount := range volumeMounts { + volumeMountName := volumeMount.Path("name").Data().(string) + if volumeMountName == "vpnconfig" { + vpnConfigVolumeMount = volumeMount + break + } + } + suite.Assertions.NotEmpty(vpnConfigVolumeMount) + suite.Assertions.EqualValues("/vpn/vpn.conf", vpnConfigVolumeMount.Path("mountPath").Data()) + suite.Assertions.EqualValues("vpnConfigfile", vpnConfigVolumeMount.Path("subPath").Data()) + + volumes := deploymentManifest.Path("spec.template.spec.volumes").Children() + var vpnConfigVolume *gabs.Container + for _, volume := range volumes { + volumeName := volume.Path("name").Data().(string) + if volumeName == "vpnconfig" { + vpnConfigVolume = volume + break + } + } + suite.Assertions.NotEmpty(vpnConfigVolume) + + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/configmap_test.go b/charts/cv/charts/helm-library-common/tests/configmap_test.go new file mode 100644 index 0000000..5641ba4 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/configmap_test.go @@ -0,0 +1,98 @@ +package common + +import ( + // "fmt" + "testing" + + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type ConfigmapTestSuite struct { + suite.Suite + Chart helmunit.HelmChart +} + +func (suite *ConfigmapTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestConfigmap(t *testing.T) { + suite.Run(t, new(ConfigmapTestSuite)) +} + +func (suite *ConfigmapTestSuite) TestValues() { + tests := map[string]struct { + values []string + expectedConfigmap bool + }{ + "Default": { + values: nil, + expectedConfigmap: false, + }, + "Disabled": { + values: []string{"configmap.config.enabled=false"}, + expectedConfigmap: false, + }, + "Multiple": { + values: []string{ + "configmap.config.enabled=true", + "configmap.config.data.foo=bar", + "configmap.secondary.enabled=true", + }, + expectedConfigmap: true, + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + configmapManifest := suite.Chart.Manifests.Get("ConfigMap", "common-test-config") + if tc.expectedConfigmap { + suite.Assertions.NotEmpty(configmapManifest) + } else { + suite.Assertions.Empty(configmapManifest) + } + }) + } +} + +func (suite *ConfigmapTestSuite) TestConfigmapName() { + tests := map[string]struct { + values []string + expectedName string + }{ + "Default": { + values: []string{ + "configmap.config.enabled=true", + "configmap.config.data.foo=bar", + }, + expectedName: "common-test-config", + }, + "CustomName": { + values: []string{ + "configmap.config.enabled=true", + "configmap.config.data.foo=bar", + "configmap.config.nameOverride=http", + }, + expectedName: "common-test-http", + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + configmapManifest := suite.Chart.Manifests.Get("ConfigMap", tc.expectedName) + suite.Assertions.NotEmpty(configmapManifest) + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/container_test.go b/charts/cv/charts/helm-library-common/tests/container_test.go new file mode 100644 index 0000000..2e1ca11 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/container_test.go @@ -0,0 +1,304 @@ +package common + +import ( + "testing" + + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type ContainerTestSuite struct { + suite.Suite + Chart helmunit.HelmChart +} + +func (suite *ContainerTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestContainer(t *testing.T) { + suite.Run(t, new(ContainerTestSuite)) +} + +func (suite *ContainerTestSuite) TestCommand() { + tests := map[string]struct { + values []string + expectedCommand []string + }{ + "Default": {values: nil, expectedCommand: nil}, + "SingleString": {values: []string{"command=/bin/sh"}, expectedCommand: []string{"/bin/sh"}}, + "StringList": {values: []string{"command={/bin/sh,-c}"}, expectedCommand: []string{"/bin/sh", "-c"}}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + containerCommand := containers[0].Path("command") + + if tc.expectedCommand == nil { + suite.Assertions.Empty(containerCommand) + } else { + var actualDataList []string + actualData := containerCommand.Children() + for _, key := range actualData { + actualDataList = append(actualDataList, key.Data().(string)) + } + suite.Assertions.EqualValues(tc.expectedCommand, actualDataList) + } + }) + } +} + +func (suite *ContainerTestSuite) TestArgs() { + tests := map[string]struct { + values []string + expectedArgs []string + }{ + "Default": {values: nil, expectedArgs: nil}, + "SingleString": {values: []string{"args=sleep infinity"}, expectedArgs: []string{"sleep infinity"}}, + "StringList": {values: []string{"args={sleep,infinity}"}, expectedArgs: []string{"sleep", "infinity"}}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + containerArgs := containers[0].Path("args") + + if tc.expectedArgs == nil { + suite.Assertions.Empty(containerArgs) + } else { + var actualDataList []string + actualData := containerArgs.Children() + for _, key := range actualData { + actualDataList = append(actualDataList, key.Data().(string)) + } + suite.Assertions.EqualValues(tc.expectedArgs, actualDataList) + } + }) + } +} + +func (suite *ContainerTestSuite) TestEnv() { + tests := map[string]struct { + values []string + expectedEnv map[string]string + }{ + "Default": {values: nil, expectedEnv: nil}, + "KeyValueString": {values: []string{"env.string=value_of_env"}, expectedEnv: map[string]string{"string": "value_of_env"}}, + "KeyValueFloat": {values: []string{"env.float=4.2"}, expectedEnv: map[string]string{"float": "4.2"}}, + "KeyValueBool": {values: []string{"env.bool=false"}, expectedEnv: map[string]string{"bool": "false"}}, + "KeyValueInt": {values: []string{"env.int=42"}, expectedEnv: map[string]string{"int": "42"}}, + "List": {values: []string{"env[0].name=STATIC_ENV_FROM_LIST", "env[0].value=STATIC_ENV_VALUE_FROM_LIST"}, expectedEnv: map[string]string{"STATIC_ENV_FROM_LIST": "STATIC_ENV_VALUE_FROM_LIST"}}, + "ValueFrom": {values: []string{"env[0].name=STATIC_ENV_FROM_LIST", "env[0].valueFrom.fieldRef.fieldPath=spec.nodeName"}, expectedEnv: map[string]string{"STATIC_ENV_FROM_LIST": "spec.nodeName"}}, + "KeyValue+ExplicitValueFrom": {values: []string{"env.STATIC_ENV=value_of_env", "env.STATIC_ENV_FROM.valueFrom.fieldRef.fieldPath=spec.nodeName"}, expectedEnv: map[string]string{"STATIC_ENV": "value_of_env", "STATIC_ENV_FROM": "spec.nodeName"}}, + "ImplicitValueFrom": {values: []string{"env.NODE_NAME.fieldRef.fieldPath=spec.nodeName"}, expectedEnv: map[string]string{"NODE_NAME": "spec.nodeName"}}, + "Templated": {values: []string{`env.DYN_ENV=\{\{ .Release.Name \}\}-admin`}, expectedEnv: map[string]string{"DYN_ENV": "common-test-admin"}}, + "Mixed": { + values: []string{ + `env.DYN_ENV=\{\{ .Release.Name \}\}-admin`, + "env.STATIC_ENV=value_of_env", + "env.STATIC_EXPLICIT_ENV_FROM.valueFrom.fieldRef.fieldPath=spec.nodeName", + "env.STATIC_IMPLICIT_ENV_FROM.fieldRef.fieldPath=spec.nodeName", + }, + expectedEnv: map[string]string{ + "DYN_ENV": "common-test-admin", + "STATIC_ENV": "value_of_env", + "STATIC_EXPLICIT_ENV_FROM": "spec.nodeName", + "STATIC_IMPLICIT_ENV_FROM": "spec.nodeName", + }, + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + containerEnv := containers[0].Path("env") + + if tc.expectedEnv == nil { + suite.Assertions.Empty(containerEnv) + } else { + actualDataMap := make(map[string]string) + actualData := containerEnv.Children() + for _, value := range actualData { + envVar := value.ChildrenMap() + envName := envVar["name"].Data().(string) + var envValue string + if _, ok := envVar["valueFrom"]; ok { + envValue = value.Path("valueFrom.fieldRef.fieldPath").Data().(string) + } else { + envValue = value.Path("value").Data().(string) + } + actualDataMap[envName] = envValue + } + suite.Assertions.EqualValues(tc.expectedEnv, actualDataMap) + } + }) + } +} + +func (suite *ContainerTestSuite) TestEnvFrom() { + tests := map[string]struct { + values []string + expectSecret bool + expectedSecretName string + }{ + "Default": {values: nil, expectSecret: false, expectedSecretName: ""}, + "FromSecret": {values: []string{"secret.STATIC_SECRET=value_of_secret"}, expectSecret: true, expectedSecretName: "common-test"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + secretManifest := suite.Chart.Manifests.Get("Secret", tc.expectedSecretName) + if tc.expectSecret { + suite.Assertions.NotEmpty(secretManifest) + } else { + suite.Assertions.Empty(secretManifest) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + containerEnvFrom := containers[0].Path("envFrom").Children() + + if !tc.expectSecret { + suite.Assertions.Empty(containerEnvFrom) + } else { + suite.Assertions.EqualValues(tc.expectedSecretName, containerEnvFrom[0].Path("secretRef.name").Data().(string)) + } + }) + } +} + +func (suite *ContainerTestSuite) TestPorts() { + tests := map[string]struct { + values []string + expectedPortName string + expectedPort int + expectedProtocol string + }{ + "Default": {values: nil, expectedPortName: "http", expectedPort: 0, expectedProtocol: "TCP"}, + "CustomName": {values: []string{"service.main.ports.http.enabled=false", "service.main.ports.server.enabled=true", "service.main.ports.server.port=8080"}, expectedPortName: "server", expectedPort: 8080, expectedProtocol: "TCP"}, + "ProtocolHTTP": {values: []string{"service.main.ports.http.protocol=HTTP"}, expectedPortName: "http", expectedPort: 0, expectedProtocol: "TCP"}, + "ProtocolHTTPS": {values: []string{"service.main.ports.http.protocol=HTTP"}, expectedPortName: "http", expectedPort: 0, expectedProtocol: "TCP"}, + "ProtocolUDP": {values: []string{"service.main.ports.http.protocol=UDP"}, expectedPortName: "http", expectedPort: 0, expectedProtocol: "UDP"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + containerPorts := containers[0].Path("ports").Children() + suite.Assertions.NotEmpty(containerPorts[0]) + suite.Assertions.EqualValues(tc.expectedPortName, containerPorts[0].Path("name").Data()) + suite.Assertions.EqualValues(tc.expectedProtocol, containerPorts[0].Path("protocol").Data()) + + if tc.expectedPort == 0 { + suite.Assertions.Empty(containerPorts[0].Path("containerPort").Data()) + } else { + suite.Assertions.EqualValues(tc.expectedPort, containerPorts[0].Path("containerPort").Data()) + } + }) + } +} + +func (suite *ContainerTestSuite) TestPersistenceVolumeMounts() { + values := ` + persistence: + config: + enabled: true + cache: + enabled: true + type: emptyDir + claimWithCustomMountPath: + enabled: true + mountPath: /custom + accessMode: ReadWriteMany + size: 1G + claimWithSubPath: + enabled: true + existingClaim: myClaim + subPath: "mySubPath" + hostpath-data: + enabled: true + type: hostPath + mountPath: /data + hostPath: /tmp + hostpath-dev: + enabled: true + type: hostPath + hostPath: /dev + subPath: mySubPath + ` + tests := map[string]struct { + values *string + volumeToTest string + expectedMountPath string + expectedSubPath string + }{ + "MountWithoutMountPath": {values: &values, volumeToTest: "config", expectedMountPath: "/config"}, + "EmptyDir": {values: &values, volumeToTest: "cache", expectedMountPath: "/cache"}, + "MountWithCustomMountPath": {values: &values, volumeToTest: "claimWithCustomMountPath", expectedMountPath: "/custom"}, + "MountWithSubPath": {values: &values, volumeToTest: "claimWithSubPath", expectedMountPath: "/claimWithSubPath", expectedSubPath: "mySubPath"}, + "HostPathMount": {values: &values, volumeToTest: "hostpath-data", expectedMountPath: "/data"}, + "HostPathMountWithSubPath": {values: &values, volumeToTest: "hostpath-dev", expectedMountPath: "/dev", expectedSubPath: "mySubPath"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, nil, tc.values) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + containers := deploymentManifest.Path("spec.template.spec.containers").Children() + containerVolumeMounts := containers[0].Path("volumeMounts").Children() + suite.Assertions.NotEmpty(containerVolumeMounts) + + for _, volumeMount := range containerVolumeMounts { + volumeMountName := volumeMount.Path("name").Data().(string) + if volumeMountName == tc.volumeToTest { + suite.Assertions.EqualValues(tc.expectedMountPath, volumeMount.Path("mountPath").Data()) + + if tc.expectedSubPath == "" { + suite.Assertions.Empty(volumeMount.Path("subPath").Data()) + } else { + suite.Assertions.EqualValues(tc.expectedSubPath, volumeMount.Path("subPath").Data()) + } + break + } + } + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/controller_test.go b/charts/cv/charts/helm-library-common/tests/controller_test.go new file mode 100644 index 0000000..2963216 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/controller_test.go @@ -0,0 +1,59 @@ +package common + +import ( + "testing" + + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type ControllerTestSuite struct { + suite.Suite + Chart helmunit.HelmChart +} + +func (suite *ControllerTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestController(t *testing.T) { + suite.Run(t, new(ControllerTestSuite)) +} + +func (suite *ControllerTestSuite) TestTypes() { + tests := map[string]struct { + values []string + expectedRenderFailure bool + expectedController string + }{ + "Default": {values: nil, expectedRenderFailure: false, expectedController: "deployment"}, + "DaemonSet": {values: []string{"controller.type=daemonset"}, expectedRenderFailure: false, expectedController: "daemonset"}, + "Deployment": {values: []string{"controller.type=deployment"}, expectedRenderFailure: false, expectedController: "deployment"}, + "StatefulSet": {values: []string{"controller.type=statefulset"}, expectedRenderFailure: false, expectedController: "statefulset"}, + "Custom": {values: []string{"controller.type=custom"}, expectedRenderFailure: true, expectedController: ""}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if tc.expectedRenderFailure { + suite.Assertions.Error(err) + return + } + if err != nil { + suite.FailNow(err.Error()) + } + + manifest := suite.Chart.Manifests.Get(tc.expectedController, "common-test") + suite.Assertions.NotEmpty(manifest) + + types := map[string]interface{}{"deployment": nil, "statefulset": nil, "daemonset": nil} + delete(types, tc.expectedController) + for k := range types { + suite.Assertions.Empty(suite.Chart.Manifests.Get(k, "common-test")) + } + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/horizontal_pod_autoscaler_test.go b/charts/cv/charts/helm-library-common/tests/horizontal_pod_autoscaler_test.go new file mode 100644 index 0000000..7c28858 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/horizontal_pod_autoscaler_test.go @@ -0,0 +1,107 @@ +package common + +import ( + "testing" + + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type HorizontalPodAutoscalerTestSuite struct { + suite.Suite + Chart helmunit.HelmChart +} + +func (suite *HorizontalPodAutoscalerTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestHorizontalPodAutoscaler(t *testing.T) { + suite.Run(t, new(HorizontalPodAutoscalerTestSuite)) +} + +func (suite *HorizontalPodAutoscalerTestSuite) TestValues() { + baseValues := []string{"autoscaling.enabled=true"} + tests := map[string]struct { + values []string + expectedHorizontalPodAutoscaler bool + expectedTarget string + expectedMinReplicas int + expectedMaxReplicas int + }{ + "Default": { + values: nil, + expectedHorizontalPodAutoscaler: false, + }, + "Enabled": { + values: baseValues, + expectedHorizontalPodAutoscaler: true, expectedTarget: "common-test", expectedMinReplicas: 1, expectedMaxReplicas: 3, + }, + "CustomSettings": { + values: append(baseValues, "autoscaling.target=common-custom", "autoscaling.minReplicas=4", "autoscaling.maxReplicas=8"), + expectedHorizontalPodAutoscaler: true, expectedTarget: "common-custom", expectedMinReplicas: 4, expectedMaxReplicas: 8, + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + manifest := suite.Chart.Manifests.Get("HorizontalPodAutoscaler", "common-test") + if tc.expectedHorizontalPodAutoscaler { + suite.Assertions.NotEmpty(manifest) + suite.Assertions.EqualValues(tc.expectedTarget, manifest.Path("spec.scaleTargetRef.name").Data()) + suite.Assertions.EqualValues(tc.expectedMinReplicas, manifest.Path("spec.minReplicas").Data()) + suite.Assertions.EqualValues(tc.expectedMaxReplicas, manifest.Path("spec.maxReplicas").Data()) + } else { + suite.Assertions.Empty(manifest) + } + }) + } +} + +func (suite *HorizontalPodAutoscalerTestSuite) TestMetrics() { + baseValues := []string{"autoscaling.enabled=true"} + tests := map[string]struct { + values []string + expectedResources map[string]int + }{ + "targetCPUUtilizationPercentage": { + values: append(baseValues, "autoscaling.targetCPUUtilizationPercentage=60"), + expectedResources: map[string]int{"cpu": 60}, + }, + "targetMemoryUtilizationPercentage": { + values: append(baseValues, "autoscaling.targetMemoryUtilizationPercentage=70"), + expectedResources: map[string]int{"memory": 70}, + }, + "Combined": { + values: append(baseValues, "autoscaling.targetCPUUtilizationPercentage=60", "autoscaling.targetMemoryUtilizationPercentage=70"), + expectedResources: map[string]int{"cpu": 60, "memory": 70}, + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + manifest := suite.Chart.Manifests.Get("HorizontalPodAutoscaler", "common-test") + suite.Assertions.NotEmpty(manifest) + + manifestMetrics := manifest.Path("spec.metrics").Children() + + metricsMap := make(map[string]int) + for _, manifestMetric := range manifestMetrics { + metricsMap[manifestMetric.Path("resource.name").Data().(string)] = int(manifestMetric.Path("resource.targetAverageUtilization").Data().(float64)) + } + + suite.Assertions.EqualValues(tc.expectedResources, metricsMap) + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/ingress_test.go b/charts/cv/charts/helm-library-common/tests/ingress_test.go new file mode 100644 index 0000000..f92f502 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/ingress_test.go @@ -0,0 +1,222 @@ +package common + +import ( + "testing" + + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type IngressTestSuite struct { + suite.Suite + Chart helmunit.HelmChart +} + +func (suite *IngressTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestIngress(t *testing.T) { + suite.Run(t, new(IngressTestSuite)) +} + +func (suite *IngressTestSuite) TestValues() { + tests := map[string]struct { + values []string + expectedIngress bool + expectedHostName string + expectedPath string + }{ + "Default": { + values: nil, + expectedIngress: false, + }, + "Disabled": { + values: []string{"ingress.main.enabled=false"}, + expectedIngress: false, + }, + "CustomHostAndPath": { + values: []string{ + "ingress.main.enabled=true", + "ingress.main.hosts[0].host=chart-test.local", + "ingress.main.hosts[0].paths[0].path=/test", + }, + expectedIngress: true, + expectedHostName: "chart-test.local", + expectedPath: "/test", + }, + "Multiple": { + values: []string{ + "ingress.main.enabled=true", + "ingress.secondary.enabled=true", + }, + expectedIngress: true, + }, + "PathTemplate": { + values: []string{ + "ingress.main.enabled=true", + "ingress.main.hosts[0].host=chart-example.local", + `ingress.main.hosts[0].paths[0].path=\{\{ .Release.Name \}\}.path`, + }, + expectedIngress: true, + expectedPath: "common-test.path", + }, + "HostTemplate": { + values: []string{ + "ingress.main.enabled=true", + `ingress.main.hosts[0].host=\{\{ .Release.Name \}\}.hostname`, + "ingress.main.hosts[0].paths[0].path=/", + }, + expectedIngress: true, + expectedHostName: "common-test.hostname", + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + ingressManifest := suite.Chart.Manifests.Get("Ingress", "common-test") + if tc.expectedIngress { + suite.Assertions.NotEmpty(ingressManifest) + + ingressRules := ingressManifest.Path("spec.rules").Children() + if tc.expectedHostName != "" { + suite.Assertions.EqualValues(tc.expectedHostName, ingressRules[0].Path("host").Data()) + } + + if tc.expectedPath != "" { + paths := ingressRules[0].Path("http.paths").Children() + suite.Assertions.EqualValues(tc.expectedPath, paths[0].Path("path").Data()) + } + } else { + suite.Assertions.Empty(ingressManifest) + } + }) + } +} + +func (suite *IngressTestSuite) TestPathServices() { + tests := map[string]struct { + values []string + expectedServiceName string + expectedServicePort int + }{ + "Default": { + values: []string{"ingress.main.enabled=true"}, + expectedServiceName: "common-test", + }, + "CustomService": { + values: []string{ + "service.main.ports.http.targetPort=80", + "ingress.main.enabled=true", + "ingress.main.hosts[0].host=test.local", + "ingress.main.hosts[0].paths[0].path=/second/", + "ingress.main.hosts[0].paths[0].service.name=pathService", + "ingress.main.hosts[0].paths[0].service.port=1234", + }, + expectedServiceName: "pathService", + expectedServicePort: 1234, + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + ingressManifest := suite.Chart.Manifests.Get("Ingress", "common-test") + suite.Assertions.NotEmpty(ingressManifest) + + ingressRules := ingressManifest.Path("spec.rules").Children() + paths := ingressRules[0].Path("http.paths").Children() + primaryPath := paths[0] + + if tc.expectedServiceName == "" { + suite.Assertions.Empty(primaryPath.Path("backend.service.name").Data()) + } else { + suite.Assertions.EqualValues(tc.expectedServiceName, primaryPath.Path("backend.service.name").Data()) + } + + if tc.expectedServicePort == 0 { + suite.Assertions.Empty(primaryPath.Path("backend.service.port.number").Data()) + } else { + suite.Assertions.EqualValues(tc.expectedServicePort, primaryPath.Path("backend.service.port.number").Data()) + } + }) + } +} + +func (suite *IngressTestSuite) TestTLS() { + tests := map[string]struct { + values []string + expectedTLS bool + expectedHostName string + expectedSecretName string + }{ + "Default": { + values: nil, + expectedTLS: false, + }, + "Provided": { + values: []string{ + "ingress.main.enabled=true", + "ingress.main.tls[0].hosts[0]=hostname", + "ingress.main.tls[0].secretName=secret-name", + }, + expectedTLS: true, + expectedHostName: "hostname", + expectedSecretName: "secret-name", + }, + "NoSecret": { + values: []string{ + "ingress.main.enabled=true", + "ingress.main.tls[0].hosts[0]=hostname", + }, + expectedTLS: true, + expectedHostName: "hostname", + expectedSecretName: "", + }, + "SecretTemplate": { + values: []string{ + "ingress.main.enabled=true", + "ingress.main.tls[0].hosts[0]=hostname", + `ingress.main.tls[0].secretName=\{\{ .Release.Name \}\}-secret`, + }, + expectedTLS: true, + expectedHostName: "hostname", + expectedSecretName: "common-test-secret", + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + ingressManifest := suite.Chart.Manifests.Get("Ingress", "common-test") + + if tc.expectedTLS { + suite.Assertions.NotEmpty(ingressManifest.Path("spec.tls").Data()) + tlsSpec := ingressManifest.Path("spec.tls").Children() + tlsHostsSpec := tlsSpec[0].Path("hosts").Children() + suite.Assertions.EqualValues(tc.expectedHostName, tlsHostsSpec[0].Data()) + + if tc.expectedSecretName == "" { + suite.Assertions.Empty(tlsSpec[0].Path("secretName").Data()) + } else { + suite.Assertions.EqualValues(tc.expectedSecretName, tlsSpec[0].Path("secretName").Data()) + } + } else { + suite.Assertions.Empty(ingressManifest.Path("spec.tls").Data()) + } + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/persistentvolumeclaim_test.go b/charts/cv/charts/helm-library-common/tests/persistentvolumeclaim_test.go new file mode 100644 index 0000000..9cf1225 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/persistentvolumeclaim_test.go @@ -0,0 +1,166 @@ +package common + +import ( + "testing" + + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type PersistenceVolumeClaimTestSuite struct { + suite.Suite + Chart helmunit.HelmChart +} + +func (suite *PersistenceVolumeClaimTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestPersistenceVolumeClaim(t *testing.T) { + suite.Run(t, new(PersistenceVolumeClaimTestSuite)) +} + +func (suite *PersistenceVolumeClaimTestSuite) TestName() { + tests := map[string]struct { + values []string + expectedName string + }{ + "Default": {values: []string{"persistence.config.enabled=true"}, expectedName: "common-test-config"}, + "WithoutSuffix": {values: []string{"persistence.config.enabled=true", "persistence.config.nameOverride=-"}, expectedName: "common-test"}, + "WithNameOverride": {values: []string{"persistence.config.enabled=true", "persistence.config.nameOverride=custom"}, expectedName: "common-test-custom"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + pvcManifest := suite.Chart.Manifests.Get("PersistentVolumeClaim", tc.expectedName) + suite.Assertions.NotEmpty(pvcManifest) + }) + } +} + +func (suite *PersistenceVolumeClaimTestSuite) TestStorageClass() { + tests := map[string]struct { + values []string + expectedStorageClass string + }{ + "Default": {values: []string{"persistence.config.enabled=true"}, expectedStorageClass: "-"}, + "CustomClass": {values: []string{"persistence.config.enabled=true", "persistence.config.storageClass=custom"}, expectedStorageClass: "custom"}, + "Empty": {values: []string{"persistence.config.enabled=true", "persistence.config.storageClass=-"}, expectedStorageClass: ""}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + pvcManifest := suite.Chart.Manifests.Get("PersistentVolumeClaim", "common-test-config") + suite.Assertions.NotEmpty(pvcManifest) + + if tc.expectedStorageClass == "-" { + suite.Assertions.Empty(pvcManifest.Path("spec.storageClassName").Data()) + } else { + suite.Assertions.EqualValues(tc.expectedStorageClass, pvcManifest.Path("spec.storageClassName").Data()) + } + }) + } +} + +func (suite *PersistenceVolumeClaimTestSuite) TestMetaData() { + defaultChartAnnotations := make(map[string]interface{}) + defaultChartLabels := map[string]interface{}{ + "app.kubernetes.io/instance": "common-test", + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "common-test", + "helm.sh/chart": "common-test-0.1.0", + } + + tests := map[string]struct { + values []string + expectedAnnotations map[string]interface{} + expectedLabels map[string]interface{} + }{ + "Default": { + values: []string{ + "persistence.config.enabled=true", + }, + expectedAnnotations: nil, + expectedLabels: nil, + }, + "NoRetain": { + values: []string{ + "persistence.config.enabled=true", + "persistence.config.labels.test_label=test", + "persistence.config.annotations.test_annotation=test", + }, + expectedAnnotations: map[string]interface{}{ + "test_annotation": "test", + }, + expectedLabels: map[string]interface{}{ + "test_label": "test", + }, + }, + "Retain": { + values: []string{ + "persistence.config.enabled=true", + "persistence.config.retain=true", + "persistence.config.labels.test_label=test", + "persistence.config.annotations.test_annotation=test", + }, + expectedAnnotations: map[string]interface{}{ + "helm.sh/resource-policy": "keep", + "test_annotation": "test", + }, + expectedLabels: map[string]interface{}{ + "test_label": "test", + }, + }, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + pvcManifest := suite.Chart.Manifests.Get("PersistentVolumeClaim", "common-test-config") + suite.Assertions.NotEmpty(pvcManifest) + + pvcAnnotations := pvcManifest.Path("metadata.annotations").Data() + testAnnotations := make(map[string]interface{}) + for index, element := range defaultChartAnnotations { + testAnnotations[index] = element + } + for index, element := range tc.expectedAnnotations { + testAnnotations[index] = element + } + + if len(testAnnotations) == 0 { + suite.Assertions.Equal(nil, pvcAnnotations) + } else { + suite.Assertions.EqualValues(testAnnotations, pvcAnnotations) + } + + pvcLabels := pvcManifest.Path("metadata.labels").Data() + testLabels := make(map[string]interface{}) + for index, element := range defaultChartLabels { + testLabels[index] = element + } + for index, element := range tc.expectedLabels { + testLabels[index] = element + } + if len(testLabels) == 0 { + suite.Assertions.Equal(nil, pvcLabels) + } else { + suite.Assertions.EqualValues(testLabels, pvcLabels) + } + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/pod_test.go b/charts/cv/charts/helm-library-common/tests/pod_test.go new file mode 100644 index 0000000..31c2265 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/pod_test.go @@ -0,0 +1,386 @@ +package common + +import ( + "testing" + + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type PodTestSuite struct { + suite.Suite + Chart helmunit.HelmChart +} + +func (suite *PodTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestPod(t *testing.T) { + suite.Run(t, new(PodTestSuite)) +} + +func (suite *PodTestSuite) TestReplicas() { + tests := map[string]struct { + values []string + expectedValue interface{} + }{ + "Default": {values: nil, expectedValue: 1}, + "Specified": {values: []string{"controller.replicas=3"}, expectedValue: 3}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + suite.Assertions.EqualValues(tc.expectedValue, deploymentManifest.Path("spec.replicas").Data()) + }) + } +} + +func (suite *PodTestSuite) TestHostNetwork() { + tests := map[string]struct { + values []string + expectedValue interface{} + }{ + "Default": {values: nil, expectedValue: nil}, + "SpecifiedTrue": {values: []string{"hostNetwork=true"}, expectedValue: true}, + "SpecifiedFalse": {values: []string{"hostNetwork=false"}, expectedValue: nil}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + suite.Assertions.EqualValues(tc.expectedValue, deploymentManifest.Path("spec.template.spec.hostNetwork").Data()) + }) + } +} + +func (suite *PodTestSuite) TestDnsPolicy() { + tests := map[string]struct { + values []string + expectedValue interface{} + }{ + "Default": {values: nil, expectedValue: "ClusterFirst"}, + "HostnetworkFalse": {values: []string{"hostNetwork=false"}, expectedValue: "ClusterFirst"}, + "HostnetworkTrue": {values: []string{"hostNetwork=true"}, expectedValue: "ClusterFirstWithHostNet"}, + "ManualOverride": {values: []string{"dnsPolicy=None"}, expectedValue: "None"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + suite.Assertions.NotEmpty(deploymentManifest) + suite.Assertions.EqualValues(tc.expectedValue, deploymentManifest.Path("spec.template.spec.dnsPolicy").Data()) + }) + } +} + +func (suite *PodTestSuite) TestInitContainers() { + tests := map[string]struct { + values []string + expectedContainer interface{} + }{ + "StaticWithName": {values: []string{"initContainers.init1.name=template-test"}, expectedContainer: "template-test"}, + "StaticWithoutName": {values: []string{"initContainers.init1.image=template-test"}, expectedContainer: "init1"}, + "DynamicTemplate": {values: []string{`initContainers.init1.name=\{\{ .Release.Name \}\}-container`}, expectedContainer: "common-test-container"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + initcontainers := deploymentManifest.Path("spec.template.spec.initContainers") + suite.Assertions.Contains(initcontainers.Search("*", "name").Data(), tc.expectedContainer) + }) + } +} + +func (suite *PodTestSuite) TestAdditionalContainers() { + tests := map[string]struct { + values []string + expectedContainer interface{} + }{ + "StaticWithName": {values: []string{"additionalContainers.additional1.name=template-test"}, expectedContainer: "template-test"}, + "StaticWithoutName": {values: []string{"additionalContainers.additional1.image=template-test"}, expectedContainer: "additional1"}, + "DynamicTemplate": {values: []string{`additionalContainers.additional1.name=\{\{ .Release.Name \}\}-container`}, expectedContainer: "common-test-container"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + containers := deploymentManifest.Path("spec.template.spec.containers") + suite.Assertions.Contains(containers.Search("*", "name").Data(), tc.expectedContainer) + }) + } +} +func (suite *PodTestSuite) TestPersistenceItems() { + values := ` + persistence: + cache: + enabled: true + type: emptyDir + config: + enabled: true + data: + enabled: true + existingClaim: dataClaim + custom-mount: + enabled: true + type: custom + volumeSpec: + downwardAPI: + items: + - path: "labels" + fieldRef: + fieldPath: metadata.labels + ` + tests := map[string]struct { + values *string + expectedVolumes []string + }{ + "Default": {values: nil, expectedVolumes: nil}, + "MultipleItems": {values: &values, expectedVolumes: []string{"config", "cache", "data", "custom-mount"}}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, nil, tc.values) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + volumes := deploymentManifest.Path("spec.template.spec.volumes") + + if tc.expectedVolumes == nil { + suite.Assertions.EqualValues(nil, volumes.Data()) + } else { + suite.Assertions.NotEmpty(volumes) + searchVolumes := volumes.Search("*", "name").Data() + for _, expectedVolume := range tc.expectedVolumes { + suite.Assertions.Contains(searchVolumes, expectedVolume) + } + } + }) + } +} + +func (suite *PodTestSuite) TestPersistenceClaimNames() { + values := ` + persistence: + config: + enabled: true + existingClaim: + enabled: true + existingClaim: myClaim + claimWithoutSuffix: + enabled: true + nameOverride: "-" + accessMode: ReadWriteMany + size: 1G + claimWithNameOverride: + enabled: true + nameOverride: suffix + accessMode: ReadWriteMany + size: 1G + ` + tests := map[string]struct { + values *string + volumeToTest string + expectedClaimName string + }{ + "DefaultClaimName": {values: &values, volumeToTest: "config", expectedClaimName: "common-test-config"}, + "ClaimNameWithoutSuffix": {values: &values, volumeToTest: "claimWithoutSuffix", expectedClaimName: "common-test"}, + "ClaimNameWithNameOverride": {values: &values, volumeToTest: "claimWithNameOverride", expectedClaimName: "common-test-suffix"}, + "ExistingClaim": {values: &values, volumeToTest: "existingClaim", expectedClaimName: "myClaim"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, nil, tc.values) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + volumes := deploymentManifest.Path("spec.template.spec.volumes").Children() + + for _, volume := range volumes { + volumeName := volume.Path("name").Data().(string) + if volumeName == tc.volumeToTest { + suite.Assertions.EqualValues(tc.expectedClaimName, volume.Path("persistentVolumeClaim.claimName").Data()) + break + } + } + }) + } +} + +func (suite *PodTestSuite) TestPersistenceEmptyDir() { + baseValues := ` + persistence: + config: + enabled: true + type: emptyDir + ` + tests := map[string]struct { + values []string + expectedMedium string + expectedSizeLimit string + }{ + "Enabled": {values: nil, expectedMedium: "", expectedSizeLimit: ""}, + "WithMedium": {values: []string{"persistence.config.medium=memory"}, expectedMedium: "memory", expectedSizeLimit: ""}, + "WithSizeLimit": {values: []string{"persistence.config.medium=memory", "persistence.config.sizeLimit=1Gi"}, expectedMedium: "memory", expectedSizeLimit: "1Gi"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, &baseValues) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + volumes := deploymentManifest.Path("spec.template.spec.volumes").Children() + volume := volumes[0] + suite.Assertions.NotEmpty(volume.Data()) + + if tc.expectedMedium == "" { + suite.Assertions.Nil(volume.Path("emptyDir.medium")) + } else { + suite.Assertions.EqualValues(tc.expectedMedium, volume.Path("emptyDir.medium").Data()) + } + + if tc.expectedSizeLimit == "" { + suite.Assertions.Nil(volume.Path("emptyDir.sizeLimit")) + } else { + suite.Assertions.EqualValues(tc.expectedSizeLimit, volume.Path("emptyDir.sizeLimit").Data()) + } + + }) + } +} + +func (suite *PodTestSuite) TestHostPathVolumes() { + values := ` + persistence: + hostpathmounts-data: + enabled: true + type: hostPath + hostPath: "/tmp1" + mountPath: "/data" + hostpathmounts-with-type: + enabled: true + type: hostPath + hostPath: "/tmp2" + hostPathType: "Directory" + mountPath: "/data2" + ` + tests := map[string]struct { + values *string + expectedVolumes []string + }{ + "Default": {values: nil, expectedVolumes: nil}, + "MultipleItems": {values: &values, expectedVolumes: []string{"hostpathmounts-data", "hostpathmounts-with-type"}}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, nil, tc.values) + if err != nil { + suite.FailNow(err.Error()) + } + + deploymentManifest := suite.Chart.Manifests.Get("Deployment", "common-test") + volumes := deploymentManifest.Path("spec.template.spec.volumes") + + if tc.expectedVolumes == nil { + suite.Assertions.EqualValues(nil, volumes.Data()) + } else { + suite.Assertions.NotEmpty(volumes) + searchVolumes := volumes.Search("*", "name").Data() + for _, expectedVolume := range tc.expectedVolumes { + suite.Assertions.Contains(searchVolumes, expectedVolume) + } + } + }) + } +} + +func (suite *PodTestSuite) TestVolumeClaimTemplates() { + values := ` + volumeClaimTemplates: + - name: 'storage' + accessMode: 'ReadWriteOnce' + size: '10Gi' + storageClass: 'storage' + ` + tests := map[string]struct { + values []string + volumeClaimToTest string + expectedAccessMode string + expectedSize string + expectedStorageClassName string + }{ + "StatefulSet": {values: []string{"controller.type=statefulset"}, volumeClaimToTest: "storage", expectedAccessMode: "ReadWriteOnce", expectedSize: "10Gi", expectedStorageClassName: "storage"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, &values) + if err != nil { + suite.FailNow(err.Error()) + } + + controllerManifest := suite.Chart.Manifests.Get("StatefulSet", "common-test") + suite.Assertions.NotEmpty(controllerManifest) + + volumeClaimTemplates := controllerManifest.Path("spec.volumeClaimTemplates").Children() + suite.Assertions.NotEmpty(volumeClaimTemplates) + + for _, volumeClaimTemplate := range volumeClaimTemplates { + volumeClaimName := volumeClaimTemplate.Path("metadata.name").Data() + if volumeClaimName == tc.volumeClaimToTest { + if tc.expectedAccessMode == "" { + suite.Assertions.Empty(controllerManifest) + } else { + accessModes := volumeClaimTemplate.Path("spec.accessModes").Children() + suite.Assertions.EqualValues(tc.expectedAccessMode, accessModes[0].Data()) + } + + if tc.expectedSize == "" { + suite.Assertions.Empty(controllerManifest) + } else { + suite.Assertions.EqualValues(tc.expectedSize, volumeClaimTemplate.Path("spec.resources.requests.storage").Data()) + } + + if tc.expectedStorageClassName == "" { + suite.Assertions.Empty(controllerManifest) + } else { + suite.Assertions.EqualValues(tc.expectedStorageClassName, volumeClaimTemplate.Path("spec.storageClassName").Data()) + } + break + } + } + }) + } +} diff --git a/charts/cv/charts/helm-library-common/tests/service_test.go b/charts/cv/charts/helm-library-common/tests/service_test.go new file mode 100644 index 0000000..06d1e34 --- /dev/null +++ b/charts/cv/charts/helm-library-common/tests/service_test.go @@ -0,0 +1,138 @@ +package common + +import ( + "fmt" + "testing" + + "github.com/k8s-at-home/library-charts/test/helmunit" + "github.com/stretchr/testify/suite" +) + +type ServiceTestSuite struct { + suite.Suite + Chart helmunit.HelmChart +} + +func (suite *ServiceTestSuite) SetupSuite() { + suite.Chart = helmunit.New("common-test", "../../../../helper-charts/common-test") + suite.Chart.UpdateDependencies() +} + +// We need this function to kick off the test suite, otherwise +// "go test" won't know about our tests +func TestService(t *testing.T) { + suite.Run(t, new(ServiceTestSuite)) +} + +func (suite *ServiceTestSuite) TestServiceName() { + tests := map[string]struct { + values []string + expectedName string + }{ + "Default": {values: nil, expectedName: "common-test"}, + "CustomName": {values: []string{"service.main.nameOverride=http"}, expectedName: "common-test-http"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + serviceManifest := suite.Chart.Manifests.Get("Service", tc.expectedName) + suite.Assertions.NotEmpty(serviceManifest) + }) + } +} + +func (suite *ServiceTestSuite) TestPortNames() { + tests := map[string]struct { + values []string + expectedRenderFailure bool + expectedName string + expectedTargetPort interface{} + }{ + "Default": {values: nil, expectedRenderFailure: false, expectedName: "http", expectedTargetPort: "http"}, + "CustomName": {values: []string{"service.main.ports.http.enabled=false", "service.main.ports.server.enabled=true", "service.main.ports.server.port=8080"}, expectedRenderFailure: false, expectedName: "server", expectedTargetPort: "server"}, + "CustomTargetPort": {values: []string{"service.main.ports.http.targetPort=80"}, expectedRenderFailure: false, expectedName: "http", expectedTargetPort: 80}, + "NamedTargetPort": {values: []string{"service.main.ports.http.targetPort=name"}, expectedRenderFailure: true, expectedName: "", expectedTargetPort: nil}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if tc.expectedRenderFailure { + suite.Assertions.Error(err) + return + } + if err != nil { + suite.FailNow(err.Error()) + } + + serviceManifest := suite.Chart.Manifests.Get("Service", "common-test") + suite.Assertions.NotEmpty(serviceManifest) + servicePorts := serviceManifest.Path("spec.ports").Children() + suite.Assertions.EqualValues(tc.expectedName, servicePorts[0].Path("name").Data()) + suite.Assertions.EqualValues(tc.expectedTargetPort, servicePorts[0].Path("targetPort").Data()) + }) + } +} + +func (suite *ServiceTestSuite) TestPortProtocol() { + tests := map[string]struct { + values []string + expectedProtocol string + }{ + "Default": {values: nil, expectedProtocol: "TCP"}, + "ExplicitTCP": {values: []string{"service.main.ports.http.protocol=TCP"}, expectedProtocol: "TCP"}, + "ExplicitHTTP": {values: []string{"service.main.ports.http.protocol=HTTP"}, expectedProtocol: "TCP"}, + "ExplicitHTTPS": {values: []string{"service.main.ports.http.protocol=HTTPS"}, expectedProtocol: "TCP"}, + "ExplicitUDP": {values: []string{"service.main.ports.http.protocol=UDP"}, expectedProtocol: "UDP"}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + serviceManifest := suite.Chart.Manifests.Get("Service", "common-test") + suite.Assertions.NotEmpty(serviceManifest) + servicePorts := serviceManifest.Path("spec.ports").Children() + suite.Assertions.EqualValues(tc.expectedProtocol, servicePorts[0].Path("protocol").Data()) + }) + } +} + +func (suite *ServiceTestSuite) TestAnnotations() { + tests := map[string]struct { + values []string + expectedAnnotations map[string]string + }{ + "Default": {values: nil, expectedAnnotations: nil}, + "ExplicitTCP": {values: []string{"service.main.ports.http.protocol=TCP"}, expectedAnnotations: nil}, + "ExplicitHTTP": {values: []string{"service.main.ports.http.protocol=HTTP"}, expectedAnnotations: nil}, + "ExplicitHTTPS": {values: []string{"service.main.ports.http.protocol=HTTPS"}, expectedAnnotations: map[string]string{"traefik.ingress.kubernetes.io/service.serversscheme": "https"}}, + "ExplicitUDP": {values: []string{"service.main.ports.http.protocol=UDP"}, expectedAnnotations: nil}, + } + for name, tc := range tests { + suite.Suite.Run(name, func() { + err := suite.Chart.Render(nil, tc.values, nil) + if err != nil { + suite.FailNow(err.Error()) + } + + serviceManifest := suite.Chart.Manifests.Get("Service", "common-test") + suite.Assertions.NotEmpty(serviceManifest) + serviceAnnotations := serviceManifest.Path("metadata.annotations").Children() + if tc.expectedAnnotations == nil { + suite.Assertions.Empty(serviceAnnotations) + } else { + for annotation, value := range tc.expectedAnnotations { + serviceAnnotation := serviceManifest.Path("metadata.annotations").Search(annotation) + suite.Assertions.NotEmpty(serviceAnnotation, fmt.Sprintf("Annotation %s not found", annotation)) + suite.Assertions.EqualValues(value, serviceAnnotation.Data(), fmt.Sprintf("Invalid value for annotation %s", annotation)) + } + } + }) + } +} diff --git a/charts/cv/charts/helm-library-common/values.yaml b/charts/cv/charts/helm-library-common/values.yaml new file mode 100644 index 0000000..b32847f --- /dev/null +++ b/charts/cv/charts/helm-library-common/values.yaml @@ -0,0 +1,707 @@ +global: + # -- Set an override for the prefix of the fullname + nameOverride: + # -- Set the entire name definition + fullnameOverride: + +controller: + # -- enable the controller. + enabled: true + # -- Set the controller type. + # Valid options are deployment, daemonset or statefulset + type: deployment + # -- Set annotations on the deployment/statefulset/daemonset + annotations: {} + # -- Set labels on the deployment/statefulset/daemonset + 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. + strategy: + rollingUpdate: + # -- Set deployment RollingUpdate max unavailable + unavailable: + # -- Set deployment RollingUpdate max surge + surge: + # -- Set statefulset RollingUpdate partition + partition: + # -- ReplicaSet revision history limit + revisionHistoryLimit: 3 + +image: + # -- image repository + repository: + # -- image tag + tag: + # -- image pull policy + pullPolicy: + +# -- Override the command(s) for the default container +command: [] +# -- Override the args for the default container +args: [] + +# -- Set annotations on the pod +podAnnotations: {} + +# -- Set labels on the pod +podLabels: {} + +# -- Add a Horizontal Pod Autoscaler +# @default -- +autoscaling: + enabled: false + target: # deploymentname + minReplicas: # 1 + maxReplicas: # 100 + targetCPUUtilizationPercentage: # 80 + targetMemoryUtilizationPercentage: # 80 + +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: "" + +# -- Specifies whether a service account token should be automatically mounted. +automountServiceAccountToken: true + +# -- Use this to populate a secret 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. +secret: {} + # PASSWORD: my-password + +# -- Configure configMaps for the chart here. +# Additional configMaps can be added by adding a dictionary key similar to the 'config' object. +# @default -- See below +configmap: + config: + # -- Enables or disables the configMap + enabled: false + # -- Labels to add to the configMap + labels: {} + # -- Annotations to add to the configMap + annotations: {} + # -- configMap data content. Helm template enabled. + data: {} + # foo: bar + +# -- Main environment variables. Template enabled. +# Syntax options: +# A) TZ: UTC +# B) PASSWD: '{{ .Release.Name }}' +# C) PASSWD: +# envFrom: +# ... +# D) - name: TZ +# value: UTC +# E) - name: TZ +# value: '{{ .Release.Name }}' +env: + +# -- Custom priority class for different treatment by the scheduler +priorityClassName: # system-node-critical + +# -- Allows specifying a custom scheduler name +schedulerName: # awkward-dangerous-scheduler + +# -- Allows specifying explicit hostname setting +hostname: + +# -- When using hostNetwork make sure you set dnsPolicy to `ClusterFirstWithHostNet` +hostNetwork: false + +# -- Defaults to "ClusterFirst" if hostNetwork is false and "ClusterFirstWithHostNet" if hostNetwork is true. +dnsPolicy: # ClusterFirst + +# -- Optional DNS settings, configuring the ndots option may resolve nslookup issues on some Kubernetes setups. +dnsConfig: {} +# options: +# - name: ndots +# value: "1" + +# -- Enable/disable the generation of environment variables for services. +# [[ref]](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service) +enableServiceLinks: true + +# -- Configure the Security Context for the Pod +podSecurityContext: {} + +# -- Configure the Security Context for the main container +securityContext: {} + +# -- Configure the lifecycle for the main container +lifecycle: {} + +# -- Specify any initContainers here as dictionary items. Each initContainer should have its own key. +# The dictionary item key will determine the order. Helm templates can be used. +initContainers: {} + +# -- Specify any additional containers here as dictionary items. Each additional container should have its own key. +# Helm templates can be used. +additionalContainers: {} + +# -- Probe configuration +# -- [[ref]](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) +# @default -- See below +probes: + # -- Liveness probe configuration + # @default -- See below + liveness: + # -- Enable the liveness probe + enabled: true + # -- Set this to `true` if you wish to specify your own livenessProbe + custom: false + # -- The spec field contains the values for the default livenessProbe. + # If you selected `custom: true`, this field holds the definition of the livenessProbe. + # @default -- See below + spec: + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + # -- Redainess probe configuration + # @default -- See below + readiness: + # -- Enable the readiness probe + enabled: true + # -- Set this to `true` if you wish to specify your own readinessProbe + custom: false + # -- The spec field contains the values for the default readinessProbe. + # If you selected `custom: true`, this field holds the definition of the readinessProbe. + # @default -- See below + spec: + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + # -- Startup probe configuration + # @default -- See below + startup: + # -- Enable the startup probe + enabled: true + # -- Set this to `true` if you wish to specify your own startupProbe + custom: false + # -- The spec field contains the values for the default startupProbe. + # If you selected `custom: true`, this field holds the definition of the startupProbe. + # @default -- See below + spec: + initialDelaySeconds: 0 + timeoutSeconds: 1 + ## This means it has a maximum of 5*30=150 seconds to start up before it fails + periodSeconds: 5 + failureThreshold: 30 + +termination: + # -- 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)] + messagePath: + + # -- 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)] + messagePolicy: + + # -- Duration in seconds the pod needs to terminate gracefully + # -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)] + gracePeriodSeconds: + +# -- Configure the services for the chart here. +# Additional services can be added by adding a dictionary key similar to the 'main' service. +# @default -- See below +service: + main: + # -- Enables or disables the service + enabled: true + + # -- Make this the primary service (used in probes, notes, etc...). + # If there is more than 1 service, make sure that only 1 service is marked as primary. + primary: true + + # -- Override the name suffix that is used for this service + nameOverride: + + # -- Set the service type + type: ClusterIP + + # -- Provide additional annotations which may be required. + annotations: {} + + # -- Provide additional labels which may be required. + labels: {} + + # -- Configure the Service port information here. + # Additional ports can be added by adding a dictionary key similar to the 'http' service. + # @default -- See below + ports: + http: + # -- Enables or disables the port + enabled: true + + # -- Make this the primary port (used in probes, notes, etc...) + # If there is more than 1 service, make sure that only 1 port is marked as primary. + primary: true + + # -- The port number + port: + + # -- Port protocol. + # Support values are `HTTP`, `HTTPS`, `TCP` and `UDP`. + # HTTPS and HTTPS spawn a TCP service and get used for internal URL and name generation + protocol: HTTP + + # -- Specify a service targetPort if you wish to differ the service port from the application port. + # If `targetPort` is specified, this port number is used in the container definition instead of + # the `port` value. Therefore named ports are not supported for this field. + targetPort: + + # -- Specify the nodePort value for the LoadBalancer and NodePort service types. + # [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) + nodePort: + +# -- Configure the ingresses for the chart here. +# Additional ingresses can be added by adding a dictionary key similar to the 'main' ingress. +# @default -- See below +ingress: + main: + # -- Enables or disables the ingress + enabled: false + + # -- Make this the primary ingress (used in probes, notes, etc...). + # If there is more than 1 ingress, make sure that only 1 ingress is marked as primary. + primary: true + + # -- Override the name suffix that is used for this ingress. + nameOverride: + + # -- Provide additional annotations which may be required. + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + + # -- Provide additional labels which may be required. + labels: {} + + # -- Set the ingressClass that is used for this ingress. + # Requires Kubernetes >=1.19 + ingressClassName: # "nginx" + + ## Configure the hosts for the ingress + hosts: + - # -- Host address. Helm template can be passed. + host: chart-example.local + ## Configure the paths for the host + paths: + - # -- Path. Helm template can be passed. + path: / + # -- Ignored if not kubeVersion >= 1.14-0 + pathType: Prefix + service: + # -- Overrides the service name reference for this path + name: + # -- Overrides the service port reference for this path + port: + + # -- Configure TLS for the ingress. Both secretName and hosts can process a Helm template. + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +# -- Configure persistence for the chart here. +# Additional items can be added by adding a dictionary key similar to the 'config' key. +# [[ref]](http://docs.k8s-at-home.com/our-helm-charts/common-library-storage) +# @default -- See below +persistence: + # -- Default persistence for configuration files. + # @default -- See below + config: + # -- Enables or disables the persistence item + enabled: false + + # -- Sets the persistence type + # Valid options are pvc, emptyDir, hostPath, secret, configMap or custom + type: pvc + + # -- Where to mount the volume in the main container. + # Defaults to `/`, + # setting to '-' creates the volume but disables the volumeMount. + mountPath: # /config + # -- Specify if the volume should be mounted read-only. + readOnly: false + # -- Override the name suffix that is used for this volume. + nameOverride: + + # -- Storage Class for the config volume. + # If set to `-`, dynamic provisioning is disabled. + # If set to something else, the given storageClass is used. + # If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. + storageClass: # "-" + + # -- If you want to reuse an existing claim, the name of the existing PVC can be passed here. + existingClaim: # your-claim + + # -- Used in conjunction with `existingClaim`. Specifies a sub-path inside the referenced volume instead of its root + subPath: # some-subpath + + # -- AccessMode for the persistent volume. + # Make sure to select an access mode that is supported by your storage provider! + # [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) + accessMode: ReadWriteOnce + + # -- The amount of storage that is requested for the persistent volume. + size: 1Gi + + # -- Set to true to retain the PVC upon `helm uninstall` + retain: false + + # -- Create an emptyDir volume to share between all containers + # [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) + # @default -- See below + shared: + enabled: false + type: emptyDir + mountPath: /shared + + # -- Set the medium to "Memory" to mount a tmpfs (RAM-backed filesystem) instead + # of the storage medium that backs the node. + medium: # Memory + + # -- If the `SizeMemoryBackedVolumes` feature gate is enabled, you can + # specify a size for memory backed volumes. + sizeLimit: # 1Gi + +# -- Used in conjunction with `controller.type: statefulset` to create individual disks for each instance. +volumeClaimTemplates: [] +# - name: data +# mountPath: /data +# accessMode: "ReadWriteOnce" +# size: 1Gi +# - name: backup +# mountPath: /backup +# subPath: theSubPath +# accessMode: "ReadWriteOnce" +# size: 2Gi +# storageClass: cheap-storage-class + +# -- Node selection constraint +# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) +nodeSelector: {} + +# -- Defines affinity constraint rules. +# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) +affinity: {} + +# -- Defines topologySpreadConstraint rules. +# [[ref]](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) +topologySpreadConstraints: [] +# - maxSkew: +# topologyKey: +# whenUnsatisfiable: +# labelSelector: + +# -- Specify taint tolerations +# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) +tolerations: [] + +# -- Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. +# [[ref]](https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/) +hostAliases: [] +# - ip: "192.168.1.100" +# hostnames: +# - "example.com" +# - "www.example.com" + +# -- Set the resource requests / limits for the main container. +resources: {} + ## We usually recommend not to specify default resources and to leave this as a conscious + ## choice for the user. This also increases chances charts run on environments with little + ## resources, such as Minikube. If you do want to specify resources, uncomment the following + ## lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# -- The common chart supports several add-ons. These can be configured under this key. +# @default -- See below +addons: + + # -- The common chart supports adding a VPN add-on. It can be configured under this key. + # For more info, check out [our docs](http://docs.k8s-at-home.com/our-helm-charts/common-library-add-ons/#wireguard-vpn) + # @default -- See values.yaml + vpn: + # -- Enable running a VPN in the pod to route traffic through a VPN + enabled: false + + # -- Specify the VPN type. Valid options are openvpn or wireguard + type: openvpn + + # -- OpenVPN specific configuration + # @default -- See below + openvpn: + image: + # -- Specify the openvpn client image + repository: dperson/openvpn-client + # -- Specify the openvpn client image tag + tag: latest + # -- Specify the openvpn client image pull policy + pullPolicy: IfNotPresent + + # -- Credentials to connect to the VPN Service (used with -a) + auth: # "user;password" + # -- Optionally specify an existing secret that contains the credentials. + # Credentials should be stored under the `VPN_AUTH` key + authSecret: # my-vpn-secret + + # -- WireGuard specific configuration + # @default -- See below + wireguard: + image: + # -- Specify the WireGuard image + repository: ghcr.io/k8s-at-home/wireguard + # -- Specify the WireGuard image tag + tag: v1.0.20210914 + # -- Specify the WireGuard image pull policy + pullPolicy: IfNotPresent + + # -- Set the VPN container securityContext + # @default -- See values.yaml + securityContext: + capabilities: + add: + - NET_ADMIN + - SYS_MODULE + + # -- All variables specified here will be added to the vpn sidecar container + # See the documentation of the VPN image for all config values + env: {} + # TZ: UTC + + # -- Provide a customized vpn configuration file to be used by the VPN. + configFile: # |- + # Some Example Config + # remote greatvpnhost.com 8888 + # auth-user-pass + # Cipher AES + + # -- Reference an existing secret that contains the VPN configuration file + # The chart expects it to be present under the `vpnConfigfile` key. + configFileSecret: + + # -- Provide custom up/down scripts that can be used by the vpn configuration. + # @default -- See values.yaml + scripts: + up: # |- + # #!/bin/bash + # echo "connected" > /shared/vpnstatus + down: # |- + # #!/bin/bash + # echo "disconnected" > /shared/vpnstatus + + additionalVolumeMounts: [] + + # -- Optionally specify a livenessProbe, e.g. to check if the connection is still + # being protected by the VPN + livenessProbe: {} + # exec: + # command: + # - sh + # - -c + # - if [ $(curl -s https://ipinfo.io/country) == 'US' ]; then exit 0; else exit $?; fi + # initialDelaySeconds: 30 + # periodSeconds: 60 + # failureThreshold: 1 + + networkPolicy: + # -- If set to true, will deploy a network policy that blocks all outbound + # traffic except traffic specified as allowed + enabled: false + + # -- Provide additional annotations which may be required. + annotations: {} + + # -- Provide additional labels which may be required. + labels: {} + + # -- Provide additional podSelector labels which may be required. + podSelectorLabels: {} + + # -- The egress configuration for your network policy, All outbound traffic + # from the pod will be blocked unless specified here. + # [[ref]](https://kubernetes.io/docs/concepts/services-networking/network-policies/) + # [[recipes]](https://github.com/ahmetb/kubernetes-network-policy-recipes) + egress: + # - to: + # - ipBlock: + # cidr: 0.0.0.0/0 + # ports: + # - port: 53 + # protocol: UDP + # - port: 53 + # protocol: TCP + + # -- The common library supports adding a code-server add-on to access files. It can be configured under this key. + # For more info, check out [our docs](http://docs.k8s-at-home.com/our-helm-charts/common-library-add-ons/#code-server) + # @default -- See values.yaml + codeserver: + # -- Enable running a code-server container in the pod + enabled: false + + image: + # -- Specify the code-server image + repository: codercom/code-server + # -- Specify the code-server image tag + tag: 3.9.2 + # -- Specify the code-server image pull policy + pullPolicy: IfNotPresent + + # -- Set any environment variables for code-server here + env: {} + # TZ: UTC + + # -- Set codeserver command line arguments. + # Consider setting --user-data-dir to a persistent location to preserve code-server setting changes + args: + - --auth + - none + # - --user-data-dir + # - "/config/.vscode" + + # -- Specify a list of volumes that get mounted in the code-server container. + # At least 1 volumeMount is required! + volumeMounts: [] + # - name: config + # mountPath: /data/config + + # -- Specify the working dir that will be opened when code-server starts + # If not given, the app will default to the mountpah of the first specified volumeMount + workingDir: "" + + # -- Optionally allow access a Git repository by passing in a private SSH key + # @default -- See below + git: + # -- Raw SSH private key + deployKey: "" + # -- Base64-encoded SSH private key. When both variables are set, the raw SSH key takes precedence. + deployKeyBase64: "" + # -- Existing secret containing SSH private key + # The chart expects it to be present under the `id_rsa` key. + deployKeySecret: "" + + service: + # -- Enable a service for the code-server add-on. + enabled: true + type: ClusterIP + # Specify the default port information + ports: + codeserver: + port: 12321 + enabled: true + protocol: TCP + targetPort: codeserver + ## Specify the nodePort value for the LoadBalancer and NodePort service types. + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport + ## + # nodePort: + annotations: {} + labels: {} + # -- Specify the ip policy. Options: SingleStack, PreferDualStack, RequireDualStack + ipFamilyPolicy: SingleStack + # -- The ip families that should be used. Options: IPv4, IPv6 + ipFamilies: + - IPv4 + + ingress: + # -- Enable an ingress for the code-server add-on. + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + labels: {} + hosts: + - host: code.chart-example.local + paths: + - path: / + # Ignored if not kubeVersion >= 1.14-0 + pathType: Prefix + tls: [] + # - secretName: chart-example-tls + # hosts: + # - code.chart-example.local + + 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: grafana/promtail + # -- Specify the promtail image tag + tag: 2.2.0 + # -- 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: + # -- Enable running a netshoot container in the pod + enabled: false + + image: + # -- Specify the netshoot image + repository: nicolaka/netshoot + # -- Specify the netshoot image tag + tag: latest + # -- Specify the netshoot image pull policy + pullPolicy: Always + + # -- Set any environment variables for netshoot here + env: {} + + securityContext: + capabilities: + add: + - NET_ADMIN diff --git a/charts/cv/templates/NOTES.txt b/charts/cv/templates/NOTES.txt new file mode 100644 index 0000000..90f7b65 --- /dev/null +++ b/charts/cv/templates/NOTES.txt @@ -0,0 +1 @@ +{{- include "common.notes.defaultNotes" . -}} diff --git a/charts/cv/templates/common.yaml b/charts/cv/templates/common.yaml new file mode 100644 index 0000000..64e027a --- /dev/null +++ b/charts/cv/templates/common.yaml @@ -0,0 +1,5 @@ +{{/* Make sure all variables are set properly */}} +{{- include "common.values.setup" . }} + +{{/* Render the templates */}} +{{ include "common.all" . }} diff --git a/charts/cv/values.yaml b/charts/cv/values.yaml new file mode 100644 index 0000000..030f1be --- /dev/null +++ b/charts/cv/values.yaml @@ -0,0 +1,40 @@ +# +# IMPORTANT NOTE +# +# This chart inherits from our common library chart. You can check the default values/options here: +# https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml +# + +image: + # -- image repository + repository: docker.io/jcabillot/cv + # -- image tag + tag: "" + # -- image pull policy + pullPolicy: Always + +# -- environment variables. +# @default -- See below +env: + # -- Set the container timezone + TZ: UTC + +# -- Configures service settings for the chart. +# @default -- See values.yaml +service: + main: + ports: + http: + port: 80 + +ingress: + # -- Enable and configure ingress settings for the chart under this key. + # @default -- See values.yaml + main: + enabled: false + +# -- Configures the probes for the main Pod. +# @default -- See values.yaml +probes: + liveness: + enabled: false