feat(common)!: Release version 1.0.0 (#68)

- Removed: **BREAKING**: Removed support for HorizontalPodAutoscaler
- Added: Support services have extraSelectorLabels (#58)
- Added: support for `httpGet` probes
- Added: support for setting labels / annotations on volumeClaimTemplates
- Changed: **BREAKING**: Restructure of template components. All Helm templates have been renamed / namespaced. E.g. `common.values.setup` has now become `bjw-s.common.loader.init`.
- Changed: **BREAKING**: Raised minimum supported k8s version to 1.22
- Changed: **BREAKING**: Renamed `configmap` key to `configMaps`
- Changed: **BREAKING**: Moved `serviceMonitor` from `service` to its own key
- Changed: **BREAKING**: Renamed `secret` key to `secrets`, which now works similar to `configMaps`
- Changed: Updated code-server image to v4.8.2
- Changed: Updated gluetun image to v3.32.0
- Fixed: Fix NOTES always showing ingress protocol as http (#62)

Signed-off-by: Gavin Mogan <git@gavinmogan.com>
Co-authored-by: Gavin Mogan <github@gavinmogan.com>
Co-authored-by: Gabe Cook <gabe565@gmail.com>
This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2022-11-03 11:41:35 +01:00 committed by GitHub
parent 98ee81df4e
commit ae4233c77f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
94 changed files with 1126 additions and 976 deletions

View file

@ -1,4 +1,4 @@
mkdocs==1.4.1 mkdocs==1.4.2
mkdocs-macros-plugin ==0.7.0 mkdocs-macros-plugin ==0.7.0
mkdocs-material ==8.5.7 mkdocs-material ==8.5.7
mkdocs-minify-plugin==0.6.1 mkdocs-minify-plugin==0.6.1

View file

@ -10,28 +10,39 @@ Thank you for contributing! I will try to test and integrate the change as soon
Also don't be worried if the request is closed or not integrated. Sometimes our priorities might not match the priorities of the pull request. Don't fret, the open source community thrives on forks and GitHub makes it easy to keep your changes in a forked repo. Also don't be worried if the request is closed or not integrated. Sometimes our priorities might not match the priorities of the pull request. Don't fret, the open source community thrives on forks and GitHub makes it easy to keep your changes in a forked repo.
--> -->
**Description of the change** ### Description of the change
<!--
Describe the scope of your change - i.e. what the change does.
Remove any sections that are not applicable.
-->
<!-- Describe the scope of your change - i.e. what the change does. --> #### Removed
<!-- Any features that have been removed -->
**Benefits** #### Fixed
<!-- Any functionality that has been fixed -->
#### Added
<!-- Any new features that have been added -->
#### Changed
<!-- Any features that have been changed from how they were working before -->
### Benefits
<!-- What benefits will be realized by the code change? --> <!-- What benefits will be realized by the code change? -->
**Possible drawbacks** ### Possible drawbacks
<!-- Describe any known limitations with your change --> <!-- Describe any known limitations with your change -->
**Applicable issues** ### Applicable issues
<!-- Enter any applicable Issues here (You can reference an issue using #) --> <!-- Enter any applicable Issues here (You can reference an issue using #) -->
- fixes # - fixes #
**Additional information** ## Additional information
<!-- If there's anything else that's important and relevant to your pull request, mention that information here.--> <!-- If there's anything else that's important and relevant to your pull request, mention that information here.-->
**Checklist** <!-- [Place an '[X]' (no spaces) in all applicable fields. Please remove unrelated fields.] --> ## Checklist
<!-- [Place an '[X]' (no spaces) in all applicable fields. Please remove unrelated fields.] -->
- [ ] Title of the PR conforms to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. - [ ] Title of the PR conforms to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.
- [ ] Scope of the of the PR title contains the chart name. - [ ] Scope of the of the PR title contains the chart name.
- [ ] Chart version in `Chart.yaml` has been bumped according to [Semantic Versioning](https://semver.org/). - [ ] Chart version in `Chart.yaml` has been bumped according to [Semantic Versioning](https://semver.org/).

View file

@ -29,7 +29,7 @@ jobs:
strategy: strategy:
matrix: matrix:
chart: ${{ fromJSON(inputs.chartsToTest) }} chart: ${{ fromJSON(inputs.chartsToTest) }}
k8s_version: ["v1.22.12", "v1.24.3"] k8s_version: ["v1.22.15", "v1.23.13", "v1.24.7", "v1.25.3"]
fail-fast: false fail-fast: false
steps: steps:
- name: Checkout - name: Checkout

View file

@ -1,9 +1,10 @@
---
apiVersion: v2 apiVersion: v2
name: common name: common
description: Function library for Helm charts description: Function library for Helm charts
type: library type: library
version: 0.2.2 version: 1.0.0
kubeVersion: ">=1.16.0-0" kubeVersion: ">=1.22.0-0"
keywords: keywords:
- common - common
- library - library
@ -13,7 +14,27 @@ maintainers:
email: me@bjw-s.dev email: me@bjw-s.dev
annotations: annotations:
artifacthub.io/changes: |- artifacthub.io/changes: |-
- kind: fixed - kind: removed
description: Fix deprecation warning on unsupported vpn types. description: "**BREAKING**: Removed support for HorizontalPodAutoscaler"
- kind: added
description: Added support for `httpGet` probes
- kind: added
description: Added support for setting labels / annotations on volumeClaimTemplates
- kind: added
description: Support services have extraSelectorLabels
- kind: changed - kind: changed
description: Updated code-server image to v4.7.1 description: "**BREAKING**: Restructure of template components. All Helm template names have changed!"
- kind: changed
description: "**BREAKING**: Raised minimum supported k8s version to 1.22"
- kind: changed
description: "**BREAKING**: Renamed `configmap` key to `configMaps`"
- kind: changed
description: "**BREAKING**: Moved `serviceMonitor` from `service` to its own key"
- kind: changed
description: "**BREAKING**: Renamed `secret` key to `secrets`, which now works similar to `configMaps`"
- kind: changed
description: Updated code-server image to v4.8.2
- kind: changed
description: Updated gluetun image to v3.32.0
- kind: fixed
description: Fix NOTES always showing ingress protocol as http

View file

@ -1,6 +1,6 @@
# common # common
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square)
Function library for Helm charts Function library for Helm charts
@ -8,7 +8,7 @@ Since a lot of the bjw-s charts follow a similar pattern, this library was built
## Requirements ## Requirements
Kubernetes: `>=1.16.0-0` Kubernetes: `>=1.22.0-0`
## Dependencies ## Dependencies
@ -29,7 +29,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml # Chart.yaml
dependencies: dependencies:
- name: common - name: common
version: 0.2.0 version: 1.0.0
repository: https://bjw-s.github.io/helm-charts/ repository: https://bjw-s.github.io/helm-charts/
``` ```
@ -61,9 +61,9 @@ N/A
| addons.codeserver.git.deployKeySecret | string | `""` | Existing secret containing SSH private key The chart expects it to be present under the `id_rsa` key. | | addons.codeserver.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.pullPolicy | string | `"IfNotPresent"` | Specify the code-server image pull policy |
| addons.codeserver.image.repository | string | `"ghcr.io/coder/code-server"` | Specify the code-server image | | addons.codeserver.image.repository | string | `"ghcr.io/coder/code-server"` | Specify the code-server image |
| addons.codeserver.image.tag | string | `"4.7.0"` | Specify the code-server image tag | | addons.codeserver.image.tag | string | `"4.8.2"` | Specify the code-server image tag |
| addons.codeserver.ingress.enabled | bool | `false` | Enable an ingress for the code-server add-on. | | addons.codeserver.ingress.enabled | bool | `false` | Enable an ingress for the code-server add-on. |
| addons.codeserver.ingress.ingressClassName | string | `nil` | Set the ingressClass that is used for this ingress. Requires Kubernetes >=1.19 | | addons.codeserver.ingress.ingressClassName | string | `nil` | Set the ingressClass that is used for this ingress. |
| addons.codeserver.service.enabled | bool | `true` | Enable a service for the code-server add-on. | | addons.codeserver.service.enabled | bool | `true` | Enable a service for the code-server add-on. |
| 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.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.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 |
@ -92,7 +92,7 @@ N/A
| addons.vpn.gluetun | object | See below | Gluetun specific configuration -- Make sure to read the [documentation](https://github.com/qdm12/gluetun/wiki) to see how to configure this addon! | | addons.vpn.gluetun | object | See below | Gluetun specific configuration -- Make sure to read the [documentation](https://github.com/qdm12/gluetun/wiki) to see how to configure this addon! |
| addons.vpn.gluetun.image.pullPolicy | string | `"IfNotPresent"` | Specify the Gluetun image pull policy | | addons.vpn.gluetun.image.pullPolicy | string | `"IfNotPresent"` | Specify the Gluetun image pull policy |
| addons.vpn.gluetun.image.repository | string | `"docker.io/qmcgaw/gluetun"` | Specify the Gluetun image | | addons.vpn.gluetun.image.repository | string | `"docker.io/qmcgaw/gluetun"` | Specify the Gluetun image |
| addons.vpn.gluetun.image.tag | string | `"v3.31.1"` | Specify the Gluetun image tag | | addons.vpn.gluetun.image.tag | string | `"v3.32.0"` | Specify the Gluetun image tag |
| addons.vpn.livenessProbe | object | `{}` | Optionally specify a livenessProbe, e.g. to check if the connection is still being protected by the VPN | | 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.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.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) |
@ -105,13 +105,12 @@ N/A
| affinity | object | `{}` | Defines affinity constraint rules. [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) | | 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 | | args | list | `[]` | Override the args for the default container |
| automountServiceAccountToken | bool | `true` | Specifies whether a service account token should be automatically mounted. | | automountServiceAccountToken | bool | `true` | Specifies whether a service account token should be automatically mounted. |
| autoscaling | object | <disabled> | Add a Horizontal Pod Autoscaler |
| command | list | `[]` | Override the command(s) for the default container | | 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. | | configMaps | 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 | | configMaps.config.annotations | object | `{}` | Annotations to add to the configMap |
| configmap.config.data | object | `{}` | configMap data content. Helm template enabled. | | configMaps.config.data | object | `{}` | configMap data content. Helm template enabled. |
| configmap.config.enabled | bool | `false` | Enables or disables the configMap | | configMaps.config.enabled | bool | `false` | Enables or disables the configMap |
| configmap.config.labels | object | `{}` | Labels to add to the configMap | | configMaps.config.labels | object | `{}` | Labels to add to the configMap |
| controller.annotations | object | `{}` | Set annotations on the deployment/statefulset/daemonset | | controller.annotations | object | `{}` | Set annotations on the deployment/statefulset/daemonset |
| controller.enabled | bool | `true` | enable the controller. | | controller.enabled | bool | `true` | enable the controller. |
| controller.labels | object | `{}` | Set labels on the deployment/statefulset/daemonset | | controller.labels | object | `{}` | Set labels on the deployment/statefulset/daemonset |
@ -144,10 +143,9 @@ N/A
| ingress.main.enabled | bool | `false` | Enables or disables the ingress | | 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].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].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.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.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.ingressClassName | string | `nil` | Set the ingressClass that is used for this ingress. |
| ingress.main.labels | object | `{}` | Provide additional labels which may be required. | | 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.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.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. |
@ -180,18 +178,25 @@ N/A
| probes.liveness.custom | bool | `false` | Set this to `true` if you wish to specify your own livenessProbe | | 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.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.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.liveness.type | string | "TCP" | sets the probe type when not using a custom probe |
| probes.readiness | object | See below | Redainess probe configuration | | 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.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.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.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.readiness.type | string | "TCP" | sets the probe type when not using a custom probe |
| probes.startup | object | See below | Startup probe configuration | | 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.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.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. | | probes.startup.spec | object | See below | The spec field contains the values for the default startupProbe. If you selected `custom: true`, this field holds the definition of the startupProbe. |
| probes.startup.type | string | "TCP" | sets the probe type when not using a custom probe |
| resources | object | `{}` | Set the resource requests / limits for the main container. | | resources | object | `{}` | Set the resource requests / limits for the main container. |
| runtimeClassName | string | `nil` | Allow specifying a runtimeClassName other than the default one (ie: nvidia) | | runtimeClassName | string | `nil` | Allow specifying a runtimeClassName other than the default one (ie: nvidia) |
| schedulerName | string | `nil` | Allows specifying a custom scheduler name | | 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. | | secrets | object | See below | Use this to populate secrets with the values you specify. Be aware that these values are not encrypted by default, and could therefore visible to anybody with access to the values.yaml file. Additional Secrets can be added by adding a dictionary key similar to the 'secret' object. |
| secrets.secret.annotations | object | `{}` | Annotations to add to the Secret |
| secrets.secret.enabled | bool | `false` | Enables or disables the Secret |
| secrets.secret.labels | object | `{}` | Labels to add to the Secret |
| secrets.secret.stringData | object | `{}` | Secret stringData content. Helm template enabled. |
| securityContext | object | `{}` | Configure the Security Context for the main container | | 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 | 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.annotations | object | `{}` | Provide additional annotations which may be required. |
@ -200,12 +205,10 @@ N/A
| service.main.ipFamilies | list | `[]` | The ip families that should be used. Options: IPv4, IPv6 | | service.main.ipFamilies | list | `[]` | The ip families that should be used. Options: IPv4, IPv6 |
| service.main.ipFamilyPolicy | string | `nil` | Specify the ip policy. Options: SingleStack, PreferDualStack, RequireDualStack | | service.main.ipFamilyPolicy | string | `nil` | Specify the ip policy. Options: SingleStack, PreferDualStack, RequireDualStack |
| service.main.labels | object | `{}` | Provide additional labels which may be required. | | service.main.labels | object | `{}` | Provide additional labels which may be required. |
| service.main.monitor | object | See below | Configure a serviceMonitor for this Service. |
| service.main.monitor.enabled | bool | `false` | Enables or disables the serviceMonitor. |
| service.main.monitor.endpoints | list | See values.yaml | Configures the endpoints for the serviceMonitor. |
| service.main.nameOverride | string | `nil` | Override the name suffix that is used for this service | | 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 | 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.enabled | bool | `true` | Enables or disables the port |
| service.main.ports.http.extraSelectorLabels | object | `{}` | Allow adding additional match labels |
| 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.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.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.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. |
@ -216,6 +219,14 @@ N/A
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | | serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `false` | Specifies whether a service account should be created | | 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 | | 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 |
| serviceMonitor | object | See below | Configure the ServiceMonitors for the chart here. Additional ServiceMonitors can be added by adding a dictionary key similar to the 'main' ServiceMonitors. |
| serviceMonitor.main.annotations | object | `{}` | Provide additional annotations which may be required. |
| serviceMonitor.main.enabled | bool | `false` | Enables or disables the serviceMonitor. |
| serviceMonitor.main.endpoints | list | See values.yaml | Configures the endpoints for the serviceMonitor. |
| serviceMonitor.main.labels | object | `{}` | Provide additional labels which may be required. |
| serviceMonitor.main.nameOverride | string | `nil` | Override the name suffix that is used for this serviceMonitor. |
| serviceMonitor.main.selector | object | `{}` | Configures a custom selector for the serviceMonitor, this takes precedence over specifying a service name. Helm templates can be used. |
| serviceMonitor.main.serviceName | string | `"main"` | Configures the target Service for the serviceMonitor. Helm templates can be used. |
| termination.gracePeriodSeconds | string | `nil` | Duration in seconds the pod needs to terminate gracefully -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)] | | termination.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.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)] | | 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)] |

View file

@ -1,58 +0,0 @@
{{/*
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 -}}

View file

@ -1,35 +0,0 @@
{{/*
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" . }}
{{- with (merge (.Values.controller.labels | default dict) (include "common.labels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }}
{{- end }}
{{- with (merge (.Values.controller.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
spec:
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "common.labels.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with include ("common.podAnnotations") . }}
annotations:
{{- . | 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 }}

View file

@ -1,39 +0,0 @@
{{/* 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 -}}

View file

@ -1,17 +0,0 @@
{{/*
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 }}
annotations: {{- include "common.annotations" $ | nindent 4 }}
type: Opaque
{{- with .Values.secret }}
stringData:
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}

View file

@ -1,57 +0,0 @@
{{/*
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 -}}
{{/* Include the Service class */}}
{{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}}
{{- include "common.classes.service" $ | nindent 0 -}}
{{/* Include a serviceMonitor if required */}}
{{- if ($service.monitor).enabled | default false -}}
{{- $_ := set $ "ObjectValues" (dict "serviceMonitor" $serviceValues.monitor) -}}
{{- $_ := set $.ObjectValues.serviceMonitor "nameOverride" $serviceValues.nameOverride -}}
{{- $serviceName := include "common.names.fullname" $ -}}
{{- if and (hasKey $serviceValues "nameOverride") $serviceValues.nameOverride -}}
{{- $serviceName = printf "%v-%v" $serviceName $serviceValues.nameOverride -}}
{{ end -}}
{{- $_ := set $.ObjectValues.serviceMonitor "serviceName" $serviceName -}}
{{- include "common.classes.serviceMonitor" $ | nindent 0 -}}
{{- end -}}
{{- 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 -}}

View file

@ -1,14 +0,0 @@
{{/*
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 (merge (.Values.serviceAccount.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View file

@ -1,62 +0,0 @@
{{/*
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" . }}
{{- with (merge (.Values.controller.labels | default dict) (include "common.labels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }}
{{- end }}
{{- with (merge (.Values.controller.annotations | default dict) (include "common.annotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
spec:
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
replicas: {{ .Values.controller.replicas }}
podManagementPolicy: {{ default "OrderedReady" .Values.controller.podManagementPolicy }}
{{- $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 include ("common.podAnnotations") . }}
annotations:
{{- . | 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 }}

View file

@ -0,0 +1,40 @@
{{/*
Template to render code-server addon
It will include / inject the required templates based on the given values.
*/}}
{{- define "bjw-s.common.addon.codeserver" -}}
{{- if .Values.addons.codeserver.enabled -}}
{{/* Append the code-server container to the additionalContainers */}}
{{- $container := include "bjw-s.common.addon.codeserver.container" . | fromYaml -}}
{{- if $container -}}
{{- $_ := set .Values.additionalContainers "addon-codeserver" $container -}}
{{- end -}}
{{/* Include the deployKeySecret if not empty */}}
{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 -}}
{{- $deployKeySecret := include "bjw-s.common.addon.codeserver.deployKeySecret" . -}}
{{- if $deployKeySecret -}}
{{- $_ := set .Values.secrets "addon-codeserver-deploykey" (dict "enabled" "true" "stringData" ($deployKeySecret | fromYaml)) -}}
{{- end -}}
{{- end -}}
{{/* Append the secret volume to the volumes */}}
{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 .Values.addons.codeserver.git.deployKeySecret }}
{{- $volume := include "bjw-s.common.addon.codeserver.deployKeyVolumeSpec" . | fromYaml -}}
{{- if $volume -}}
{{- $_ := set .Values.persistence "deploykey" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}}
{{- end -}}
{{- end -}}
{{/* Add the code-server service */}}
{{- $_ := set .Values.service "addon-codeserver" .Values.addons.codeserver.service -}}
{{/* Add the code-server ingress */}}
{{- $svcName := printf "%v-addon-codeserver" (include "bjw-s.common.lib.chart.names.fullname" .) -}}
{{- $svcPort := .Values.addons.codeserver.service.ports.codeserver.port -}}
{{- range $_, $host := .Values.addons.codeserver.ingress.hosts -}}
{{- $_ := set (index $host.paths 0) "service" (dict "name" $svcName "port" $svcPort) -}}
{{- end -}}
{{- $_ := set .Values.ingress "addon-codeserver" .Values.addons.codeserver.ingress -}}
{{- end -}}
{{- end -}}

View file

@ -1,50 +0,0 @@
{{/*
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 -}}

View file

@ -1,7 +1,7 @@
{{/* {{/*
The code-server sidecar container to be inserted. The code-server sidecar container to be inserted.
*/}} */}}
{{- define "common.addon.codeserver.container" -}} {{- define "bjw-s.common.addon.codeserver.container" -}}
{{- if lt (len .Values.addons.codeserver.volumeMounts) 1 }} {{- if lt (len .Values.addons.codeserver.volumeMounts) 1 }}
{{- fail "At least 1 volumeMount is required for codeserver container" }} {{- fail "At least 1 volumeMount is required for codeserver container" }}
{{- end -}} {{- end -}}

View file

@ -1,22 +1,10 @@
{{/* {{/*
The OpenVPN credentials secrets to be included. The deployKey secret to be included.
*/}} */}}
{{- define "common.addon.codeserver.deployKeySecret" -}} {{- define "bjw-s.common.addon.codeserver.deployKeySecret" -}}
{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 }} {{- $deployKeyValue := .Values.addons.codeserver.git.deployKey -}}
--- {{- if .Values.addons.codeserver.git.deployKeyBase64 -}}
apiVersion: v1 {{- $deployKeyValue = .Values.addons.codeserver.git.deployKeyBase64 | b64dec -}}
kind: Secret {{- end -}}
metadata: id_rsa: {{ $deployKeyValue | quote }}
name: {{ template "common.names.fullname" . }}-deploykey
labels: {{- include "common.labels" $ | nindent 4 }}
annotations: {{- include "common.annotations" $ | 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 -}} {{- end -}}

View file

@ -1,17 +1,15 @@
{{/* {{/*
The volume (referencing git deploykey) to be inserted into additionalVolumes. The volume (referencing git deploykey) to be inserted into additionalVolumes.
*/}} */}}
{{- define "common.addon.codeserver.deployKeyVolumeSpec" -}} {{- define "bjw-s.common.addon.codeserver.deployKeyVolumeSpec" -}}
{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 .Values.addons.codeserver.git.deployKeySecret }}
secret: secret:
{{- if .Values.addons.codeserver.git.deployKeySecret }} {{- if .Values.addons.codeserver.git.deployKeySecret }}
secretName: {{ .Values.addons.codeserver.git.deployKeySecret }} secretName: {{ .Values.addons.codeserver.git.deployKeySecret }}
{{- else }} {{- else }}
secretName: {{ include "common.names.fullname" . }}-deploykey secretName: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-codeserver-deploykey
{{- end }} {{- end }}
defaultMode: {{ "0400" | toDecimal }} defaultMode: {{ "0400" | toDecimal }}
items: items:
- key: id_rsa - key: id_rsa
path: id_rsa path: id_rsa
{{- end -}} {{- end -}}
{{- end -}}

View file

@ -2,10 +2,10 @@
Template to render netshoot addon Template to render netshoot addon
It will include / inject the required templates based on the given values. It will include / inject the required templates based on the given values.
*/}} */}}
{{- define "common.addon.netshoot" -}} {{- define "bjw-s.common.addon.netshoot" -}}
{{- if .Values.addons.netshoot.enabled -}} {{- if .Values.addons.netshoot.enabled -}}
{{/* Append the netshoot container to the additionalContainers */}} {{/* Append the netshoot container to the additionalContainers */}}
{{- $container := include "common.addon.netshoot.container" . | fromYaml -}} {{- $container := include "bjw-s.common.addon.netshoot.container" . | fromYaml -}}
{{- if $container -}} {{- if $container -}}
{{- $_ := set .Values.additionalContainers "addon-netshoot" $container -}} {{- $_ := set .Values.additionalContainers "addon-netshoot" $container -}}
{{- end -}} {{- end -}}

View file

@ -1,7 +1,7 @@
{{/* {{/*
The netshoot sidecar container to be inserted. The netshoot sidecar container to be inserted.
*/}} */}}
{{- define "common.addon.netshoot.container" -}} {{- define "bjw-s.common.addon.netshoot.container" -}}
name: netshoot name: netshoot
image: "{{ .Values.addons.netshoot.image.repository }}:{{ .Values.addons.netshoot.image.tag }}" image: "{{ .Values.addons.netshoot.image.repository }}:{{ .Values.addons.netshoot.image.tag }}"
imagePullPolicy: {{ .Values.addons.netshoot.pullPolicy }} imagePullPolicy: {{ .Values.addons.netshoot.pullPolicy }}

View file

@ -0,0 +1,25 @@
{{/*
Template to render promtail addon
It will include / inject the required templates based on the given values.
*/}}
{{- define "bjw-s.common.addon.promtail" -}}
{{- if .Values.addons.promtail.enabled -}}
{{/* Append the promtail container to the additionalContainers */}}
{{- $container := include "bjw-s.common.addon.promtail.container" . | fromYaml -}}
{{- if $container -}}
{{- $_ := set .Values.additionalContainers "addon-promtail" $container -}}
{{- end -}}
{{/* Append the promtail configMap to the configmaps dict */}}
{{- $configmap := include "bjw-s.common.addon.promtail.configmap" . -}}
{{- if $configmap -}}
{{- $_ := set .Values.configMaps "addon-promtail" (dict "enabled" "true" "data" ($configmap | fromYaml)) -}}
{{- end -}}
{{/* Append the promtail config volume to the volumes */}}
{{- $volume := include "bjw-s.common.addon.promtail.volumeSpec" . | fromYaml -}}
{{- if $volume -}}
{{- $_ := set .Values.persistence "addon-promtail" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $volume) -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -1,16 +1,7 @@
{{/* {{/*
The promtail config to be included. The promtail config to be included.
*/}} */}}
{{- define "common.addon.promtail.configmap" -}} {{- define "bjw-s.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 }}
annotations: {{- include "common.annotations" $ | nindent 4 }}
data:
promtail.yaml: | promtail.yaml: |
server: server:
http_listen_port: 9080 http_listen_port: 9080
@ -32,4 +23,3 @@ data:
__path__: "{{ .path }}" __path__: "{{ .path }}"
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- end -}}

View file

@ -1,7 +1,7 @@
{{/* {{/*
The promtail sidecar container to be inserted. The promtail sidecar container to be inserted.
*/}} */}}
{{- define "common.addon.promtail.container" -}} {{- define "bjw-s.common.addon.promtail.container" -}}
{{- if lt (len .Values.addons.promtail.volumeMounts) 1 }} {{- if lt (len .Values.addons.promtail.volumeMounts) 1 }}
{{- fail "At least 1 volumeMount is required for the promtail container" }} {{- fail "At least 1 volumeMount is required for the promtail container" }}
{{- end -}} {{- end -}}
@ -25,7 +25,7 @@ args:
{{- end }} {{- end }}
- "-config.file=/etc/promtail/promtail.yaml" - "-config.file=/etc/promtail/promtail.yaml"
volumeMounts: volumeMounts:
- name: promtail-config - name: addon-promtail
mountPath: /etc/promtail/promtail.yaml mountPath: /etc/promtail/promtail.yaml
subPath: promtail.yaml subPath: promtail.yaml
readOnly: true readOnly: true

View file

@ -1,25 +0,0 @@
{{/*
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 -}}

View file

@ -1,7 +1,7 @@
{{/* {{/*
The volume (referencing config) to be inserted into additionalVolumes. The volume (referencing config) to be inserted into additionalVolumes.
*/}} */}}
{{- define "common.addon.promtail.volumeSpec" -}} {{- define "bjw-s.common.addon.promtail.volumeSpec" -}}
configMap: configMap:
name: {{ include "common.names.fullname" . }}-promtail name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-promtail
{{- end -}} {{- end -}}

View file

@ -2,46 +2,42 @@
Template to render VPN addon Template to render VPN addon
It will include / inject the required templates based on the given values. It will include / inject the required templates based on the given values.
*/}} */}}
{{- define "common.addon.vpn" -}} {{- define "bjw-s.common.addon.vpn" -}}
{{- if .Values.addons.vpn.enabled -}} {{- if .Values.addons.vpn.enabled -}}
{{- if eq "openvpn" .Values.addons.vpn.type -}}
{{- fail "The 'openvpn' VPN type is no longer supported. Please migrate to the 'gluetun' type." }}
{{- end -}}
{{- if eq "wireguard" .Values.addons.vpn.type -}}
{{- fail "The 'wireguard' VPN type is no longer supported. Please migrate to the 'gluetun' type." }}
{{- end -}}
{{- if eq "gluetun" .Values.addons.vpn.type -}} {{- if eq "gluetun" .Values.addons.vpn.type -}}
{{- include "common.addon.gluetun" . }} {{- include "bjw-s.common.addon.gluetun" . }}
{{- end -}} {{- end -}}
{{/* Include the configmap if not empty */}} {{/* Include the configmap if not empty */}}
{{- $configmap := include "common.addon.vpn.configmap" . -}} {{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down }}
{{- $configmap := include "bjw-s.common.addon.vpn.configmap" . -}}
{{- if $configmap -}} {{- if $configmap -}}
{{- $configmap | nindent 0 -}} {{- $_ := set .Values.configMaps "addon-vpn" (dict "enabled" "true" "data" ($configmap | fromYaml)) -}}
{{- end -}}
{{- end -}} {{- end -}}
{{/* Include the secret if not empty */}} {{/* Include the secret if not empty */}}
{{- $secret := include "common.addon.vpn.secret" . -}} {{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) }}
{{- $secret := include "bjw-s.common.addon.vpn.secret" . -}}
{{- if $secret -}} {{- if $secret -}}
{{- $secret | nindent 0 -}} {{- $_ := set .Values.secrets "addon-vpn-config" (dict "enabled" "true" "stringData" ($secret | fromYaml)) -}}
{{- end -}}
{{- end -}} {{- end -}}
{{/* Append the vpn scripts volume to the volumes */}} {{/* Append the vpn scripts volume to the volumes */}}
{{- $scriptVolume := include "common.addon.vpn.scriptsVolumeSpec" . | fromYaml -}} {{- $scriptVolume := include "bjw-s.common.addon.vpn.scriptsVolumeSpec" . | fromYaml -}}
{{- if $scriptVolume -}} {{- if $scriptVolume -}}
{{- $_ := set .Values.persistence "vpnscript" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $scriptVolume) -}} {{- $_ := set .Values.persistence "vpnscript" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $scriptVolume) -}}
{{- end -}} {{- end -}}
{{/* Append the vpn config volume to the volumes */}} {{/* Append the vpn config volume to the volumes */}}
{{- $configVolume := include "common.addon.vpn.configVolumeSpec" . | fromYaml }} {{- $configVolume := include "bjw-s.common.addon.vpn.configVolumeSpec" . | fromYaml }}
{{ if $configVolume -}} {{ if $configVolume -}}
{{- $_ := set .Values.persistence "vpnconfig" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $configVolume) -}} {{- $_ := set .Values.persistence "vpnconfig" (dict "enabled" "true" "mountPath" "-" "type" "custom" "volumeSpec" $configVolume) -}}
{{- end -}} {{- end -}}
{{/* Include the networkpolicy if not empty */}} {{/* Include the networkpolicy if not empty */}}
{{- $networkpolicy := include "common.addon.vpn.networkpolicy" . -}} {{- $networkpolicy := include "bjw-s.common.addon.vpn.networkpolicy" . -}}
{{- if $networkpolicy -}} {{- if $networkpolicy -}}
{{- $networkpolicy | nindent 0 -}} {{- $networkpolicy | nindent 0 -}}
{{- end -}} {{- end -}}

View file

@ -1,23 +1,14 @@
{{/* {{/*
The VPN config and scripts to be included. The VPN config and scripts to be included.
*/}} */}}
{{- define "common.addon.vpn.configmap" -}} {{- define "bjw-s.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 }}
annotations: {{- include "common.annotations" $ | nindent 4 }}
data:
{{- with .Values.addons.vpn.scripts.up }} {{- with .Values.addons.vpn.scripts.up }}
up.sh: |- up.sh: |-
{{- . | nindent 4}} {{- . | nindent 2}}
{{- end }} {{- end }}
{{- with .Values.addons.vpn.scripts.down }} {{- with .Values.addons.vpn.scripts.down }}
down.sh: |- down.sh: |-
{{- . | nindent 4}} {{- . | nindent 2}}
{{- end }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,22 +1,22 @@
{{/* {{/*
Blueprint for the NetworkPolicy object that can be included in the addon. Blueprint for the NetworkPolicy object that can be included in the addon.
*/}} */}}
{{- define "common.addon.vpn.networkpolicy" -}} {{- define "bjw-s.common.addon.vpn.networkpolicy" -}}
{{- if .Values.addons.vpn.networkPolicy.enabled }} {{- if .Values.addons.vpn.networkPolicy.enabled }}
--- ---
kind: NetworkPolicy kind: NetworkPolicy
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
metadata: metadata:
name: {{ include "common.names.fullname" . }} name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
{{- with (merge (.Values.addons.vpn.networkPolicy.labels | default dict) (include "common.labels" $ | fromYaml)) }} {{- with (merge (.Values.addons.vpn.networkPolicy.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }} labels: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with (merge (.Values.addons.vpn.networkPolicy.annotations | default dict) (include "common.annotations" $ | fromYaml)) }} {{- with (merge (.Values.addons.vpn.networkPolicy.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }} annotations: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
podSelector: podSelector:
{{- with (merge .Values.addons.vpn.networkPolicy.podSelectorLabels (include "common.labels.selectorLabels" . | fromYaml)) }} {{- with (merge .Values.addons.vpn.networkPolicy.podSelectorLabels (include "bjw-s.common.lib.metadata.selectorLabels" . | fromYaml)) }}
matchLabels: {{- toYaml . | nindent 6 }} matchLabels: {{- toYaml . | nindent 6 }}
{{- end }} {{- end }}
policyTypes: policyTypes:

View file

@ -1,19 +1,9 @@
{{/* {{/*
The OpenVPN config secret to be included. The OpenVPN config secret to be included.
*/}} */}}
{{- define "common.addon.vpn.secret" -}} {{- define "bjw-s.common.addon.vpn.secret" -}}
{{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) }} {{- 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 }}
annotations: {{- include "common.annotations" $ | nindent 4 }}
stringData:
{{- with .Values.addons.vpn.configFile }}
vpnConfigfile: |- vpnConfigfile: |-
{{- . | nindent 4}} {{- .Values.addons.vpn.configFile | nindent 2 }}
{{- end }}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,10 +1,10 @@
{{/* {{/*
The volume (referencing VPN scripts) to be inserted into additionalVolumes. The volume (referencing VPN scripts) to be inserted into additionalVolumes.
*/}} */}}
{{- define "common.addon.vpn.scriptsVolumeSpec" -}} {{- define "bjw-s.common.addon.vpn.scriptsVolumeSpec" -}}
{{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down -}} {{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down -}}
configMap: configMap:
name: {{ include "common.names.fullname" . }}-vpn name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-vpn
items: items:
{{- if .Values.addons.vpn.scripts.up }} {{- if .Values.addons.vpn.scripts.up }}
- key: up.sh - key: up.sh
@ -22,13 +22,13 @@ configMap:
{{/* {{/*
The volume (referencing VPN config) to be inserted into additionalVolumes. The volume (referencing VPN config) to be inserted into additionalVolumes.
*/}} */}}
{{- define "common.addon.vpn.configVolumeSpec" -}} {{- define "bjw-s.common.addon.vpn.configVolumeSpec" -}}
{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret -}} {{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret -}}
secret: secret:
{{- if .Values.addons.vpn.configFileSecret }} {{- if .Values.addons.vpn.configFileSecret }}
secretName: {{ .Values.addons.vpn.configFileSecret }} secretName: {{ .Values.addons.vpn.configFileSecret }}
{{- else }} {{- else }}
secretName: {{ include "common.names.fullname" . }}-vpnconfig secretName: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-vpn-config
{{- end }} {{- end }}
items: items:
- key: vpnConfigfile - key: vpnConfigfile

View file

@ -2,9 +2,9 @@
Template to render gluetun addon. It will add the container to the list of additionalContainers. Template to render gluetun addon. It will add the container to the list of additionalContainers.
*/}} */}}
*/}} */}}
{{- define "common.addon.gluetun" -}} {{- define "bjw-s.common.addon.gluetun" -}}
{{/* Append the gluetun container to the additionalContainers */}} {{/* Append the gluetun container to the additionalContainers */}}
{{- $container := fromYaml (include "common.addon.gluetun.container" .) -}} {{- $container := fromYaml (include "bjw-s.common.addon.gluetun.container" .) -}}
{{- if $container -}} {{- if $container -}}
{{- $_ := set .Values.additionalContainers "addon-gluetun" $container -}} {{- $_ := set .Values.additionalContainers "addon-gluetun" $container -}}
{{- end -}} {{- end -}}

View file

@ -1,7 +1,7 @@
{{/* {{/*
The gluetun sidecar container to be inserted. The gluetun sidecar container to be inserted.
*/}} */}}
{{- define "common.addon.gluetun.container" -}} {{- define "bjw-s.common.addon.gluetun.container" -}}
name: gluetun name: gluetun
image: "{{ .Values.addons.vpn.gluetun.image.repository }}:{{ .Values.addons.vpn.gluetun.image.tag }}" image: "{{ .Values.addons.vpn.gluetun.image.repository }}:{{ .Values.addons.vpn.gluetun.image.tag }}"
imagePullPolicy: {{ .Values.addons.vpn.gluetun.pullPolicy }} imagePullPolicy: {{ .Values.addons.vpn.gluetun.pullPolicy }}

View file

@ -1,37 +0,0 @@
{{/*
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 }}
annotations: {{- include "common.annotations" $ | 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 -}}

View file

@ -2,8 +2,8 @@
This template serves as a blueprint for all configMap objects that are created This template serves as a blueprint for all configMap objects that are created
within the common library. within the common library.
*/}} */}}
{{- define "common.classes.configmap" -}} {{- define "bjw-s.common.class.configmap" -}}
{{- $fullName := include "common.names.fullname" . -}} {{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}}
{{- $configMapName := $fullName -}} {{- $configMapName := $fullName -}}
{{- $values := .Values.configmap -}} {{- $values := .Values.configmap -}}
@ -21,14 +21,14 @@ apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: {{ $configMapName }} name: {{ $configMapName }}
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }} {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }} labels: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }} {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }} annotations: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
data: data:
{{- with $values.data }} {{- with $values.data }}
{{- tpl (toYaml .) $ | nindent 2 }} {{- tpl (toYaml .) $ | nindent 2 }}
{{- end }} {{- end }}
{{- end }} {{- end -}}

View file

@ -0,0 +1,35 @@
{{/*
This template serves as the blueprint for the DaemonSet objects that are created
within the common library.
*/}}
{{- define "bjw-s.common.class.daemonset" -}}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
{{- with include "bjw-s.common.lib.controller.metadata.labels" . }}
labels: {{- . | nindent 4 }}
{{- end }}
{{- with include "bjw-s.common.lib.controller.metadata.annotations" . }}
annotations: {{- . | nindent 4 }}
{{- end }}
spec:
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
selector:
matchLabels:
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }}
annotations:
{{- . | nindent 8 }}
{{- end }}
labels:
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- include "bjw-s.common.lib.controller.pod" . | nindent 6 }}
{{- end }}

View file

@ -1,26 +1,26 @@
{{/* {{/*
This template serves as the blueprint for the Deployment objects that are created This template serves as a blueprint for Deployment objects that are created
within the common library. using the common library.
*/}} */}}
{{- define "common.deployment" }} {{- define "bjw-s.common.class.deployment" -}}
{{- $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 -}}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: {{ include "common.names.fullname" . }} name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
{{- with (merge (.Values.controller.labels | default dict) (include "common.labels" $ | fromYaml)) }} {{- with include "bjw-s.common.lib.controller.metadata.labels" . }}
labels: {{- toYaml . | nindent 4 }} labels: {{- . | nindent 4 }}
{{- end }} {{- end }}
{{- with (merge (.Values.controller.annotations | default dict) (include "common.annotations" $ | fromYaml)) }} {{- with include "bjw-s.common.lib.controller.metadata.annotations" . }}
annotations: {{- toYaml . | nindent 4 }} annotations: {{- . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
replicas: {{ .Values.controller.replicas }} 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: strategy:
type: {{ $strategy }} type: {{ $strategy }}
{{- with .Values.controller.rollingUpdate }} {{- with .Values.controller.rollingUpdate }}
@ -36,18 +36,18 @@ spec:
{{- end }} {{- end }}
selector: selector:
matchLabels: matchLabels:
{{- include "common.labels.selectorLabels" . | nindent 6 }} {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }}
template: template:
metadata: metadata:
{{- with include ("common.podAnnotations") . }} {{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }}
annotations: annotations:
{{- . | nindent 8 }} {{- . | nindent 8 }}
{{- end }} {{- end }}
labels: labels:
{{- include "common.labels.selectorLabels" . | nindent 8 }} {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }} {{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
spec: spec:
{{- include "common.controller.pod" . | nindent 6 }} {{- include "bjw-s.common.lib.controller.pod" . | nindent 6 }}
{{- end }} {{- end -}}

View file

@ -2,8 +2,8 @@
This template serves as a blueprint for all Ingress objects that are created This template serves as a blueprint for all Ingress objects that are created
within the common library. within the common library.
*/}} */}}
{{- define "common.classes.ingress" -}} {{- define "bjw-s.common.class.ingress" -}}
{{- $fullName := include "common.names.fullname" . -}} {{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}}
{{- $ingressName := $fullName -}} {{- $ingressName := $fullName -}}
{{- $values := .Values.ingress -}} {{- $values := .Values.ingress -}}
@ -17,26 +17,25 @@ within the common library.
{{- $ingressName = printf "%v-%v" $ingressName $values.nameOverride -}} {{- $ingressName = printf "%v-%v" $ingressName $values.nameOverride -}}
{{- end -}} {{- end -}}
{{- $primaryService := get .Values.service (include "common.service.primary" .) -}} {{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}}
{{- $defaultServiceName := $fullName -}} {{- $defaultServiceName := $fullName -}}
{{- if and (hasKey $primaryService "nameOverride") $primaryService.nameOverride -}} {{- if and (hasKey $primaryService "nameOverride") $primaryService.nameOverride -}}
{{- $defaultServiceName = printf "%v-%v" $defaultServiceName $primaryService.nameOverride -}} {{- $defaultServiceName = printf "%v-%v" $defaultServiceName $primaryService.nameOverride -}}
{{- end -}} {{- end -}}
{{- $defaultServicePort := get $primaryService.ports (include "common.classes.service.ports.primary" (dict "values" $primaryService)) -}} {{- $defaultServicePort := get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $primaryService)) -}}
{{- $isStable := include "common.capabilities.ingress.isStable" . }}
--- ---
apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }} apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
name: {{ $ingressName }} name: {{ $ingressName }}
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }} {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }} labels: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }} {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }} annotations: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
{{- if and $isStable $values.ingressClassName }} {{- if $values.ingressClassName }}
ingressClassName: {{ $values.ingressClassName }} ingressClassName: {{ $values.ingressClassName }}
{{- end }} {{- end }}
{{- if $values.tls }} {{- if $values.tls }}
@ -64,19 +63,12 @@ spec:
{{- $port = default $port .service.port -}} {{- $port = default $port .service.port -}}
{{- end }} {{- end }}
- path: {{ tpl .path $ | quote }} - path: {{ tpl .path $ | quote }}
{{- if $isStable }}
pathType: {{ default "Prefix" .pathType }} pathType: {{ default "Prefix" .pathType }}
{{- end }}
backend: backend:
{{- if $isStable }}
service: service:
name: {{ $service }} name: {{ $service }}
port: port:
number: {{ $port }} number: {{ $port }}
{{- else }}
serviceName: {{ $service }}
servicePort: {{ $port }}
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}

View file

@ -2,14 +2,14 @@
This template serves as a blueprint for all PersistentVolumeClaim objects that are created This template serves as a blueprint for all PersistentVolumeClaim objects that are created
within the common library. within the common library.
*/}} */}}
{{- define "common.classes.pvc" -}} {{- define "bjw-s.common.class.pvc" -}}
{{- $values := .Values.persistence -}} {{- $values := .Values.persistence -}}
{{- if hasKey . "ObjectValues" -}} {{- if hasKey . "ObjectValues" -}}
{{- with .ObjectValues.persistence -}} {{- with .ObjectValues.persistence -}}
{{- $values = . -}} {{- $values = . -}}
{{- end -}} {{- end -}}
{{ end -}} {{ end -}}
{{- $pvcName := include "common.names.fullname" . -}} {{- $pvcName := include "bjw-s.common.lib.chart.names.fullname" . -}}
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} {{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
{{- if not (eq $values.nameOverride "-") -}} {{- if not (eq $values.nameOverride "-") -}}
{{- $pvcName = printf "%v-%v" $pvcName $values.nameOverride -}} {{- $pvcName = printf "%v-%v" $pvcName $values.nameOverride -}}
@ -20,14 +20,14 @@ kind: PersistentVolumeClaim
apiVersion: v1 apiVersion: v1
metadata: metadata:
name: {{ $pvcName }} name: {{ $pvcName }}
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }} {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }} labels: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
annotations: annotations:
{{- if $values.retain }} {{- if $values.retain }}
"helm.sh/resource-policy": keep "helm.sh/resource-policy": keep
{{- end }} {{- end }}
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }} {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:

View file

@ -0,0 +1,34 @@
{{/*
This template serves as a blueprint for all Secret objects that are created
within the common library.
*/}}
{{- define "bjw-s.common.class.secret" -}}
{{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}}
{{- $secretName := $fullName -}}
{{- $values := .Values.configmap -}}
{{- if hasKey . "ObjectValues" -}}
{{- with .ObjectValues.secret -}}
{{- $values = . -}}
{{- end -}}
{{ end -}}
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
{{- $secretName = printf "%v-%v" $secretName $values.nameOverride -}}
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ $secretName }}
{{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }}
{{- end }}
{{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
stringData:
{{- with $values.stringData }}
{{- tpl (toYaml .) $ | nindent 2 }}
{{- end }}
{{- end -}}

View file

@ -2,7 +2,7 @@
This template serves as a blueprint for all Service objects that are created This template serves as a blueprint for all Service objects that are created
within the common library. within the common library.
*/}} */}}
{{- define "common.classes.service" -}} {{- define "bjw-s.common.class.service" -}}
{{- $values := .Values.service -}} {{- $values := .Values.service -}}
{{- if hasKey . "ObjectValues" -}} {{- if hasKey . "ObjectValues" -}}
{{- with .ObjectValues.service -}} {{- with .ObjectValues.service -}}
@ -10,12 +10,12 @@ within the common library.
{{- end -}} {{- end -}}
{{ end -}} {{ end -}}
{{- $serviceName := include "common.names.fullname" . -}} {{- $serviceName := include "bjw-s.common.lib.chart.names.fullname" . -}}
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} {{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
{{- $serviceName = printf "%v-%v" $serviceName $values.nameOverride -}} {{- $serviceName = printf "%v-%v" $serviceName $values.nameOverride -}}
{{ end -}} {{ end -}}
{{- $svcType := $values.type | default "" -}} {{- $svcType := $values.type | default "" -}}
{{- $primaryPort := get $values.ports (include "common.classes.service.ports.primary" (dict "values" $values)) }} {{- $primaryPort := get $values.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $values)) }}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
@ -23,14 +23,14 @@ metadata:
name: {{ $serviceName }} name: {{ $serviceName }}
labels: labels:
app.kubernetes.io/service: {{ $serviceName }} app.kubernetes.io/service: {{ $serviceName }}
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }} {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
annotations: annotations:
{{- if eq ( $primaryPort.protocol | default "" ) "HTTPS" }} {{- if eq ( $primaryPort.protocol | default "" ) "HTTPS" }}
traefik.ingress.kubernetes.io/service.serversscheme: https traefik.ingress.kubernetes.io/service.serversscheme: https
{{- end }} {{- end }}
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }} {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
{{ toYaml . | nindent 4 }} {{ toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
@ -95,6 +95,7 @@ spec:
{{ end }} {{ end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
selector: {{- with (merge ($values.extraSelectorLabels | default dict) (include "bjw-s.common.lib.metadata.selectorLabels" . | fromYaml)) }}
{{- include "common.labels.selectorLabels" . | nindent 4 }} selector: {{- toYaml . | nindent 4 }}
{{- end }}
{{- end }} {{- end }}

View file

@ -0,0 +1,15 @@
{{/*
This template serves as a blueprint for ServiceAccount objects that are created
using the common library.
*/}}
{{- define "bjw-s.common.class.serviceAccount" -}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "bjw-s.common.lib.chart.names.serviceAccountName" . }}
labels: {{- include "bjw-s.common.lib.metadata.allLabels" $ | nindent 4 }}
{{- with (merge (.Values.serviceAccount.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}

View file

@ -1,4 +1,4 @@
{{- define "common.classes.serviceMonitor" -}} {{- define "bjw-s.common.class.serviceMonitor" -}}
{{- $values := dict -}} {{- $values := dict -}}
{{- if hasKey . "ObjectValues" -}} {{- if hasKey . "ObjectValues" -}}
{{- with .ObjectValues.serviceMonitor -}} {{- with .ObjectValues.serviceMonitor -}}
@ -6,7 +6,7 @@
{{- end -}} {{- end -}}
{{ end -}} {{ end -}}
{{- $serviceMonitorName := include "common.names.fullname" . -}} {{- $serviceMonitorName := include "bjw-s.common.lib.chart.names.fullname" . -}}
{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} {{- if and (hasKey $values "nameOverride") $values.nameOverride -}}
{{- $serviceMonitorName = printf "%v-%v" $serviceMonitorName $values.nameOverride -}} {{- $serviceMonitorName = printf "%v-%v" $serviceMonitorName $values.nameOverride -}}
{{ end -}} {{ end -}}
@ -15,16 +15,20 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor kind: ServiceMonitor
metadata: metadata:
name: {{ $serviceMonitorName }} name: {{ $serviceMonitorName }}
{{- with (merge ($values.labels | default dict) (include "common.labels" $ | fromYaml)) }} {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }}
labels: {{- toYaml . | nindent 4 }} labels: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
{{- with (merge ($values.annotations | default dict) (include "common.annotations" $ | fromYaml)) }} {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }}
annotations: {{- toYaml . | nindent 4 }} annotations: {{- toYaml . | nindent 4 }}
{{- end }} {{- end }}
spec: spec:
selector: selector:
{{- if $values.selector -}}
{{- tpl ($values.selector | toYaml) $ | nindent 4}}
{{- else }}
matchLabels: matchLabels:
app.kubernetes.io/service: {{ $values.serviceName }} app.kubernetes.io/service: {{ tpl $values.serviceName $ }}
{{- include "common.labels.selectorLabels" . | nindent 6 }} {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }}
{{- end }}
endpoints: {{- toYaml (required (printf "endpoints are required for serviceMonitor %v" $serviceMonitorName) $values.endpoints) | nindent 4 }} endpoints: {{- toYaml (required (printf "endpoints are required for serviceMonitor %v" $serviceMonitorName) $values.endpoints) | nindent 4 }}
{{- end }} {{- end }}

View file

@ -0,0 +1,68 @@
{{/*
This template serves as the blueprint for the StatefulSet objects that are created
within the common library.
*/}}
{{- define "bjw-s.common.class.statefulset" -}}
{{- $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 -}}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
{{- with include "bjw-s.common.lib.controller.metadata.labels" . }}
labels: {{- . | nindent 4 }}
{{- end }}
{{- with include "bjw-s.common.lib.controller.metadata.annotations" . }}
annotations: {{- . | nindent 4 }}
{{- end }}
spec:
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
replicas: {{ .Values.controller.replicas }}
podManagementPolicy: {{ default "OrderedReady" .Values.controller.podManagementPolicy }}
updateStrategy:
type: {{ $strategy }}
{{- if and (eq $strategy "RollingUpdate") .Values.controller.rollingUpdate.partition }}
rollingUpdate:
partition: {{ .Values.controller.rollingUpdate.partition }}
{{- end }}
selector:
matchLabels:
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }}
serviceName: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
template:
metadata:
{{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }}
annotations:
{{- . | nindent 8 }}
{{- end }}
labels:
{{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- include "bjw-s.common.lib.controller.pod" . | nindent 6 }}
volumeClaimTemplates:
{{- range $index, $volumeClaimTemplate := .Values.volumeClaimTemplates }}
- metadata:
name: {{ $volumeClaimTemplate.name }}
{{- with ($volumeClaimTemplate.labels | default dict) }}
labels: {{- toYaml . | nindent 10 }}
{{- end }}
{{- with ($volumeClaimTemplate.annotations | default dict) }}
annotations: {{- toYaml . | nindent 10 }}
{{- end }}
spec:
accessModes:
- {{ required (printf "accessMode is required for volumeClaimTemplate %v" $volumeClaimTemplate.name) $volumeClaimTemplate.accessMode | quote }}
resources:
requests:
storage: {{ required (printf "size is required for PVC %v" $volumeClaimTemplate.name) $volumeClaimTemplate.size | quote }}
{{- if $volumeClaimTemplate.storageClass }}
storageClassName: {{ if (eq "-" $volumeClaimTemplate.storageClass) }}""{{- else }}{{ $volumeClaimTemplate.storageClass | quote }}{{- end }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -1,19 +0,0 @@
{{/* 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 -}}

View file

@ -1,22 +0,0 @@
{{/* 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 }}
{{- with .Values.global.labels }}
{{- range $k, $v := . }}
{{- $name := $k }}
{{- $value := tpl $v $ }}
{{ $name }}: {{ quote $value }}
{{- end }}
{{- end }}
{{- 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 -}}

View file

@ -1,5 +1,5 @@
{{/* Expand the name of the chart */}} {{/* Expand the name of the chart */}}
{{- define "common.names.name" -}} {{- define "bjw-s.common.lib.chart.names.name" -}}
{{- $globalNameOverride := "" -}} {{- $globalNameOverride := "" -}}
{{- if hasKey .Values "global" -}} {{- if hasKey .Values "global" -}}
{{- $globalNameOverride = (default $globalNameOverride .Values.global.nameOverride) -}} {{- $globalNameOverride = (default $globalNameOverride .Values.global.nameOverride) -}}
@ -12,8 +12,8 @@ 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). 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. If release name contains chart name it will be used as a full name.
*/}} */}}
{{- define "common.names.fullname" -}} {{- define "bjw-s.common.lib.chart.names.fullname" -}}
{{- $name := include "common.names.name" . -}} {{- $name := include "bjw-s.common.lib.chart.names.name" . -}}
{{- $globalFullNameOverride := "" -}} {{- $globalFullNameOverride := "" -}}
{{- if hasKey .Values "global" -}} {{- if hasKey .Values "global" -}}
{{- $globalFullNameOverride = (default $globalFullNameOverride .Values.global.fullnameOverride) -}} {{- $globalFullNameOverride = (default $globalFullNameOverride .Values.global.fullnameOverride) -}}
@ -31,28 +31,15 @@ If release name contains chart name it will be used as a full name.
{{- end -}} {{- end -}}
{{/* Create chart name and version as used by the chart label */}} {{/* Create chart name and version as used by the chart label */}}
{{- define "common.names.chart" -}} {{- define "bjw-s.common.lib.chart.names.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}} {{- end -}}
{{/* Create the name of the ServiceAccount to use */}} {{/* Create the name of the ServiceAccount to use */}}
{{- define "common.names.serviceAccountName" -}} {{- define "bjw-s.common.lib.chart.names.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}} {{- if .Values.serviceAccount.create -}}
{{- default (include "common.names.fullname" .) .Values.serviceAccount.name -}} {{- default (include "bjw-s.common.lib.chart.names.fullname" .) .Values.serviceAccount.name -}}
{{- else -}} {{- else -}}
{{- default "default" .Values.serviceAccount.name -}} {{- default "default" .Values.serviceAccount.name -}}
{{- end -}} {{- end -}}
{{- 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 -}}

View file

@ -1,13 +1,13 @@
{{/* {{/*
Default NOTES.txt content. Default NOTES.txt content.
*/}} */}}
{{- define "common.notes.defaultNotes" -}} {{- define "bjw-s.common.lib.chart.notes" -}}
{{- $primaryIngress := get .Values.ingress (include "common.ingress.primary" .) -}} {{- $primaryIngress := get .Values.ingress (include "bjw-s.common.lib.ingress.primary" .) -}}
{{- $primaryService := get .Values.service (include "common.service.primary" .) -}} {{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}}
{{- $primaryPort := "" -}} {{- $primaryPort := "" -}}
{{- if $primaryService -}} {{- if $primaryService -}}
{{- $primaryPort = get $primaryService.ports (include "common.classes.service.ports.primary" (dict "serviceName" (include "common.service.primary" .) "values" $primaryService)) -}} {{- $primaryPort = get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "serviceName" (include "bjw-s.common.lib.service.primary" .) "values" $primaryService)) -}}
{{- end -}} {{- end -}}
{{- $prefix := "http" -}} {{- $prefix := "http" -}}
@ -22,7 +22,7 @@ Default NOTES.txt content.
{{- if $primaryIngress }} {{- if $primaryIngress }}
1. Access the application by visiting one of these URL's: 1. Access the application by visiting one of these URL's:
{{ range $primaryIngress.hosts }} {{ range $primaryIngress.hosts }}
{{- $protocol := "http" -}} {{- $prefix = "http" -}}
{{ if $primaryIngress.tls -}} {{ if $primaryIngress.tls -}}
{{- $prefix = "https" -}} {{- $prefix = "https" -}}
{{ end -}} {{ end -}}
@ -34,21 +34,21 @@ Default NOTES.txt content.
{{ if (first .paths).pathTpl -}} {{ if (first .paths).pathTpl -}}
{{- $path = tpl (first .paths).pathTpl $ -}} {{- $path = tpl (first .paths).pathTpl $ -}}
{{ end }} {{ end }}
- {{ $protocol }}://{{- $host }}{{- $path }} - {{ $prefix }}://{{- $host }}{{- $path }}
{{- end }} {{- end }}
{{- else if and $primaryService $primaryPort }} {{- else if and $primaryService $primaryPort }}
1. Get the application URL by running these commands: 1. Get the application URL by running these commands:
{{- if contains "NodePort" $primaryService.type }} {{- 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_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bjw-s.common.lib.chart.names.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo {{ $prefix }}://$NODE_IP:$NODE_PORT echo {{ $prefix }}://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" $primaryService.type }} {{- else if contains "LoadBalancer" $primaryService.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available. 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" . }}' You can watch the status of by running 'kubectl get svc -w {{ include "bjw-s.common.lib.chart.names.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bjw-s.common.lib.chart.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo {{ $prefix }}://$SERVICE_IP:{{ $primaryPort.port }} echo {{ $prefix }}://$SERVICE_IP:{{ $primaryPort.port }}
{{- else if contains "ClusterIP" $primaryService.type }} {{- 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}") export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bjw-s.common.lib.chart.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" echo "Visit {{ $prefix }}://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:{{ $primaryPort.port }} kubectl port-forward $POD_NAME 8080:{{ $primaryPort.port }}
{{- end }} {{- end }}

View file

@ -1,10 +1,10 @@
{{/* {{/*
Environment variables used by containers. Environment variables used by containers.
*/}} */}}
{{- define "common.controller.env_vars" -}} {{- define "bjw-s.common.lib.container.envVars" -}}
{{- $values := .Values.env -}} {{- $values := .Values.env -}}
{{- if hasKey . "ObjectValues" -}} {{- if hasKey . "ObjectValues" -}}
{{- with .ObjectValues.env -}} {{- with .ObjectValues.envVars -}}
{{- $values = . -}} {{- $values = . -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

View file

@ -1,7 +1,7 @@
{{/* {{/*
Ports included by the controller. Ports included by the controller.
*/}} */}}
{{- define "common.controller.ports" -}} {{- define "bjw-s.common.lib.container.ports" -}}
{{- $ports := list -}} {{- $ports := list -}}
{{- range .Values.service -}} {{- range .Values.service -}}
{{- if .enabled -}} {{- if .enabled -}}

View file

@ -0,0 +1,47 @@
{{/*
Probes selection logic.
*/}}
{{- define "bjw-s.common.lib.container.probes" -}}
{{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}}
{{- $primaryPort := "" -}}
{{- if $primaryService -}}
{{- $primaryPort = get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "serviceName" (include "bjw-s.common.lib.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 -}}
{{- $probeType := "" -}}
{{- if eq $probe.type "AUTO" -}}
{{- $probeType = $primaryPort.protocol -}}
{{- else -}}
{{- $probeType = $probe.type | default "TCP" -}}
{{- end }}
{{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}}
httpGet:
path: {{ $probe.path }}
scheme: {{ $probeType }}
{{- else }}
tcpSocket:
{{- end }}
{{- if $probe.port }}
port: {{ ( tpl ( $probe.port | toString ) $ ) }}
{{- else if $primaryPort.targetPort }}
port: {{ $primaryPort.targetPort }}
{{- else }}
port: {{ $primaryPort.port }}
{{- end }}
initialDelaySeconds: {{ $probe.spec.initialDelaySeconds }}
failureThreshold: {{ $probe.spec.failureThreshold }}
timeoutSeconds: {{ $probe.spec.timeoutSeconds }}
periodSeconds: {{ $probe.spec.periodSeconds }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View file

@ -1,5 +1,5 @@
{{/* Volumes included by the controller */}} {{/* Volumes included by the controller */}}
{{- define "common.controller.volumeMounts" -}} {{- define "bjw-s.common.lib.container.volumeMounts" -}}
{{- range $persistenceIndex, $persistenceItem := .Values.persistence }} {{- range $persistenceIndex, $persistenceItem := .Values.persistence }}
{{- if $persistenceItem.enabled -}} {{- if $persistenceItem.enabled -}}
{{- if kindIs "slice" $persistenceItem.subPath -}} {{- if kindIs "slice" $persistenceItem.subPath -}}

View file

@ -1,6 +1,6 @@
{{- /* The main container included in the controller */ -}} {{- /* The main container included in the controller */ -}}
{{- define "common.controller.mainContainer" -}} {{- define "bjw-s.common.lib.controller.mainContainer" -}}
- name: {{ include "common.names.fullname" . }} - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
image: {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }} image: {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.command }} {{- with .Values.command }}
@ -36,7 +36,7 @@
{{- with .Values.env }} {{- with .Values.env }}
env: env:
{{- get (fromYaml (include "common.controller.env_vars" $)) "env" | toYaml | nindent 4 -}} {{- get (fromYaml (include "bjw-s.common.lib.container.envVars" $)) "env" | toYaml | nindent 4 -}}
{{- end }} {{- end }}
{{- if or .Values.envFrom .Values.secret }} {{- if or .Values.envFrom .Values.secret }}
envFrom: envFrom:
@ -45,16 +45,16 @@
{{- end }} {{- end }}
{{- if .Values.secret }} {{- if .Values.secret }}
- secretRef: - secretRef:
name: {{ include "common.names.fullname" . }} name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}
{{- end }} {{- end }}
{{- end }} {{- end }}
ports: ports:
{{- include "common.controller.ports" . | trim | nindent 4 }} {{- include "bjw-s.common.lib.container.ports" . | trim | nindent 4 }}
{{- with (include "common.controller.volumeMounts" . | trim) }} {{- with (include "bjw-s.common.lib.container.volumeMounts" . | trim) }}
volumeMounts: volumeMounts:
{{- nindent 4 . }} {{- nindent 4 . }}
{{- end }} {{- end }}
{{- include "common.controller.probes" . | trim | nindent 2 }} {{- include "bjw-s.common.lib.container.probes" . | trim | nindent 2 }}
{{- with .Values.resources }} {{- with .Values.resources }}
resources: resources:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}

View file

@ -0,0 +1,25 @@
{{- define "bjw-s.common.lib.controller.metadata.labels" -}}
{{-
$labels := (
merge
(.Values.controller.labels | default dict)
(include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)
)
-}}
{{- with $labels -}}
{{- toYaml . -}}
{{- end -}}
{{- end -}}
{{- define "bjw-s.common.lib.controller.metadata.annotations" -}}
{{-
$annotations := (
merge
(.Values.controller.annotations | default dict)
(include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)
)
-}}
{{- with $annotations -}}
{{- toYaml . -}}
{{- end -}}
{{- end -}}

View file

@ -1,12 +1,12 @@
{{- /* {{- /*
The pod definition included in the controller. The pod definition included in the controller.
*/ -}} */ -}}
{{- define "common.controller.pod" -}} {{- define "bjw-s.common.lib.controller.pod" -}}
{{- with .Values.imagePullSecrets }} {{- with .Values.imagePullSecrets }}
imagePullSecrets: imagePullSecrets:
{{- toYaml . | nindent 2 }} {{- toYaml . | nindent 2 }}
{{- end }} {{- end }}
serviceAccountName: {{ include "common.names.serviceAccountName" . }} serviceAccountName: {{ include "bjw-s.common.lib.chart.names.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
{{- with .Values.podSecurityContext }} {{- with .Values.podSecurityContext }}
securityContext: securityContext:
@ -51,9 +51,9 @@ initContainers:
{{- $_ := set $container "name" $key }} {{- $_ := set $container "name" $key }}
{{- end }} {{- end }}
{{- if $container.env -}} {{- if $container.env -}}
{{- $_ := set $ "ObjectValues" (dict "env" $container.env) -}} {{- $_ := set $ "ObjectValues" (dict "envVars" $container.env) -}}
{{- $newEnv := fromYaml (include "common.controller.env_vars" $) -}} {{- $newEnv := fromYaml (include "bjw-s.common.lib.container.envVars" $) -}}
{{- $_ := unset $.ObjectValues "env" -}} {{- $_ := unset $.ObjectValues "envVars" -}}
{{- $_ := set $container "env" $newEnv.env }} {{- $_ := set $container "env" $newEnv.env }}
{{- end }} {{- end }}
{{- $initContainers = append $initContainers $container }} {{- $initContainers = append $initContainers $container }}
@ -61,7 +61,7 @@ initContainers:
{{- tpl (toYaml $initContainers) $ | nindent 2 }} {{- tpl (toYaml $initContainers) $ | nindent 2 }}
{{- end }} {{- end }}
containers: containers:
{{- include "common.controller.mainContainer" . | nindent 2 }} {{- include "bjw-s.common.lib.controller.mainContainer" . | nindent 2 }}
{{- with .Values.additionalContainers }} {{- with .Values.additionalContainers }}
{{- $additionalContainers := list }} {{- $additionalContainers := list }}
{{- range $name, $container := . }} {{- range $name, $container := . }}
@ -69,16 +69,16 @@ containers:
{{- $_ := set $container "name" $name }} {{- $_ := set $container "name" $name }}
{{- end }} {{- end }}
{{- if $container.env -}} {{- if $container.env -}}
{{- $_ := set $ "ObjectValues" (dict "env" $container.env) -}} {{- $_ := set $ "ObjectValues" (dict "envVars" $container.env) -}}
{{- $newEnv := fromYaml (include "common.controller.env_vars" $) -}} {{- $newEnv := fromYaml (include "bjw-s.common.lib.container.envVars" $) -}}
{{- $_ := set $container "env" $newEnv.env }} {{- $_ := set $container "env" $newEnv.env }}
{{- $_ := unset $.ObjectValues "env" -}} {{- $_ := unset $.ObjectValues "envVars" -}}
{{- end }} {{- end }}
{{- $additionalContainers = append $additionalContainers $container }} {{- $additionalContainers = append $additionalContainers $container }}
{{- end }} {{- end }}
{{- tpl (toYaml $additionalContainers) $ | nindent 2 }} {{- tpl (toYaml $additionalContainers) $ | nindent 2 }}
{{- end }} {{- end }}
{{- with (include "common.controller.volumes" . | trim) }} {{- with (include "bjw-s.common.lib.controller.volumes" . | trim) }}
volumes: volumes:
{{- nindent 2 . }} {{- nindent 2 . }}
{{- end }} {{- end }}

View file

@ -1,33 +0,0 @@
{{/*
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 }}

View file

@ -1,12 +1,12 @@
{{/* {{/*
Volumes included by the controller. Volumes included by the controller.
*/}} */}}
{{- define "common.controller.volumes" -}} {{- define "bjw-s.common.lib.controller.volumes" -}}
{{- range $index, $persistence := .Values.persistence }} {{- range $index, $persistence := .Values.persistence }}
{{- if $persistence.enabled }} {{- if $persistence.enabled }}
- name: {{ $index }} - name: {{ $index }}
{{- if eq (default "pvc" $persistence.type) "pvc" }} {{- if eq (default "pvc" $persistence.type) "pvc" }}
{{- $pvcName := (include "common.names.fullname" $) -}} {{- $pvcName := (include "bjw-s.common.lib.chart.names.fullname" $) -}}
{{- if $persistence.existingClaim }} {{- if $persistence.existingClaim }}
{{- /* Always prefer an existingClaim if that is set */}} {{- /* Always prefer an existingClaim if that is set */}}
{{- $pvcName = $persistence.existingClaim -}} {{- $pvcName = $persistence.existingClaim -}}
@ -14,10 +14,10 @@ Volumes included by the controller.
{{- /* Otherwise refer to the PVC name */}} {{- /* Otherwise refer to the PVC name */}}
{{- if $persistence.nameOverride -}} {{- if $persistence.nameOverride -}}
{{- if not (eq $persistence.nameOverride "-") -}} {{- if not (eq $persistence.nameOverride "-") -}}
{{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $persistence.nameOverride) -}} {{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $) $persistence.nameOverride) -}}
{{- end -}} {{- end -}}
{{- else -}} {{- else -}}
{{- $pvcName = (printf "%s-%s" (include "common.names.fullname" $) $index) -}} {{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $) $index) -}}
{{- end -}} {{- end -}}
{{- end }} {{- end }}
persistentVolumeClaim: persistentVolumeClaim:

View file

@ -0,0 +1,21 @@
{{/* Return the name of the primary ingress object */}}
{{- define "bjw-s.common.lib.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 -}}

View file

@ -0,0 +1,10 @@
{{/* Common labels shared across objects */}}
{{- define "bjw-s.common.lib.metadata.allLabels" -}}
helm.sh/chart: {{ include "bjw-s.common.lib.chart.names.chart" . }}
{{ include "bjw-s.common.lib.metadata.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{ include "bjw-s.common.lib.metadata.globalLabels" . }}
{{- end -}}

View file

@ -0,0 +1,10 @@
{{/* Common annotations shared across objects */}}
{{- define "bjw-s.common.lib.metadata.globalAnnotations" -}}
{{- with .Values.global.annotations }}
{{- range $k, $v := . }}
{{- $name := $k }}
{{- $value := tpl $v $ }}
{{ $name }}: {{ quote $value }}
{{- end }}
{{- end }}
{{- end -}}

View file

@ -0,0 +1,9 @@
{{- define "bjw-s.common.lib.metadata.globalLabels" -}}
{{- with .Values.global.labels }}
{{- range $k, $v := . }}
{{- $name := $k }}
{{- $value := tpl $v $ }}
{{ $name }}: {{ quote $value }}
{{- end }}
{{- end }}
{{- end -}}

View file

@ -1,22 +1,11 @@
{{/* Common annotations shared across objects */}}
{{- define "common.annotations" -}}
{{- with .Values.global.annotations }}
{{- range $k, $v := . }}
{{- $name := $k }}
{{- $value := tpl $v $ }}
{{ $name }}: {{ quote $value }}
{{- end }}
{{- end }}
{{- end -}}
{{/* Determine the Pod annotations used in the controller */}} {{/* Determine the Pod annotations used in the controller */}}
{{- define "common.podAnnotations" -}} {{- define "bjw-s.common.lib.metadata.podAnnotations" -}}
{{- if .Values.podAnnotations -}} {{- if .Values.podAnnotations -}}
{{- tpl (toYaml .Values.podAnnotations) . | nindent 0 -}} {{- tpl (toYaml .Values.podAnnotations) . | nindent 0 -}}
{{- end -}} {{- end -}}
{{- $configMapsFound := dict -}} {{- $configMapsFound := dict -}}
{{- range $name, $configmap := .Values.configmap -}} {{- range $name, $configmap := .Values.configMaps -}}
{{- if $configmap.enabled -}} {{- if $configmap.enabled -}}
{{- $_ := set $configMapsFound $name (toYaml $configmap.data | sha256sum) -}} {{- $_ := set $configMapsFound $name (toYaml $configmap.data | sha256sum) -}}
{{- end -}} {{- end -}}

View file

@ -0,0 +1,5 @@
{{/* Selector labels shared across objects */}}
{{- define "bjw-s.common.lib.metadata.selectorLabels" -}}
app.kubernetes.io/name: {{ include "bjw-s.common.lib.chart.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

View file

@ -0,0 +1,23 @@
{{/*
Return the primary service object
*/}}
{{- define "bjw-s.common.lib.service.primary" -}}
{{- $enabledServices := dict -}}
{{- range $name, $service := .Values.service -}}
{{- if $service.enabled -}}
{{- $_ := set $enabledServices $name . -}}
{{- end -}}
{{- end -}}
{{- $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 -}}

View file

@ -1,7 +1,7 @@
{{/* {{/*
Return the primary port for a given Service object. Return the primary port for a given Service object.
*/}} */}}
{{- define "common.classes.service.ports.primary" -}} {{- define "bjw-s.common.lib.service.primaryPort" -}}
{{- $enabledPorts := dict -}} {{- $enabledPorts := dict -}}
{{- range $name, $port := .values.ports -}} {{- range $name, $port := .values.ports -}}
{{- if $port.enabled -}} {{- if $port.enabled -}}

View file

@ -0,0 +1,10 @@
{{/*
Main entrypoint for the common library chart. It will render all underlying templates based on the provided values.
*/}}
{{- define "bjw-s.common.loader.all" -}}
{{- /* Generate chart and dependency values */ -}}
{{- include "bjw-s.common.loader.init" . -}}
{{- /* Generate remaining objects */ -}}
{{- include "bjw-s.common.loader.generate" . -}}
{{- end -}}

View file

@ -0,0 +1,34 @@
{{/*
Secondary entrypoint and primary loader for the common chart
*/}}
{{- define "bjw-s.common.loader.generate" -}}
{{- /* Enable code-server add-on if required */ -}}
{{- if .Values.addons.codeserver.enabled -}}
{{- include "bjw-s.common.addon.codeserver" . | nindent 0 -}}
{{- end -}}
{{- /* Enable VPN add-on if required */ -}}
{{- if .Values.addons.vpn.enabled -}}
{{- include "bjw-s.common.addon.vpn" . | nindent 0 -}}
{{- end -}}
{{- /* Enable promtail add-on if required */ -}}
{{- if .Values.addons.promtail.enabled -}}
{{- include "bjw-s.common.addon.promtail" . | nindent 0 -}}
{{- end -}}
{{- /* Enable netshoot add-on if required */ -}}
{{- if .Values.addons.netshoot.enabled -}}
{{- include "bjw-s.common.addon.netshoot" . | nindent 0 -}}
{{- end -}}
{{- /* Build the templates */ -}}
{{- include "bjw-s.common.render.configmaps" . | nindent 0 -}}
{{- include "bjw-s.common.render.secrets" . | nindent 0 -}}
{{- include "bjw-s.common.render.pvcs" . | nindent 0 -}}
{{- include "bjw-s.common.render.serviceAccount" . | nindent 0 -}}
{{- include "bjw-s.common.render.controller" . | nindent 0 -}}
{{- include "bjw-s.common.render.services" . | nindent 0 -}}
{{- include "bjw-s.common.render.ingresses" . | nindent 0 -}}
{{- include "bjw-s.common.render.serviceMonitors" . | nindent 0 -}}
{{- end -}}

View file

@ -0,0 +1,4 @@
{{- define "bjw-s.common.loader.init" -}}
{{- /* Merge the local chart values and the common chart defaults */ -}}
{{- include "bjw-s.common.values.init" . }}
{{- end -}}

View file

@ -1,19 +1,19 @@
{{/* {{/*
Renders the configMap objects required by the chart. Renders the configMap objects required by the chart.
*/}} */}}
{{- define "common.configmap" -}} {{- define "bjw-s.common.render.configmaps" -}}
{{- /* Generate named configMaps as required */ -}} {{- /* Generate named configMaps as required */ -}}
{{- range $name, $configmap := .Values.configmap }} {{- range $name, $configmap := .Values.configMaps -}}
{{- if $configmap.enabled -}} {{- if $configmap.enabled -}}
{{- $configmapValues := $configmap -}} {{- $configmapValues := $configmap -}}
{{/* set the default nameOverride to the configMap name */}} {{- /* set the default nameOverride to the configMap name */ -}}
{{- if not $configmapValues.nameOverride -}} {{- if not $configmapValues.nameOverride -}}
{{- $_ := set $configmapValues "nameOverride" $name -}} {{- $_ := set $configmapValues "nameOverride" $name -}}
{{ end -}} {{ end -}}
{{- $_ := set $ "ObjectValues" (dict "configmap" $configmapValues) -}} {{- $_ := set $ "ObjectValues" (dict "configmap" $configmapValues) -}}
{{- include "common.classes.configmap" $ }} {{- include "bjw-s.common.class.configmap" $ | nindent 0 -}}
{{- end }} {{- end -}}
{{- end }} {{- end -}}
{{- end }} {{- end -}}

View file

@ -0,0 +1,16 @@
{{/*
Renders the controller object required by the chart.
*/}}
{{- define "bjw-s.common.render.controller" -}}
{{- if .Values.controller.enabled -}}
{{- if eq .Values.controller.type "deployment" -}}
{{- include "bjw-s.common.class.deployment" . | nindent 0 -}}
{{ else if eq .Values.controller.type "daemonset" -}}
{{- include "bjw-s.common.class.daemonset" . | nindent 0 -}}
{{ else if eq .Values.controller.type "statefulset" -}}
{{- include "bjw-s.common.class.statefulset" . | nindent 0 -}}
{{ else -}}
{{- fail (printf "Not a valid controller.type (%s)" .Values.controller.type) -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -0,0 +1,19 @@
{{/*
Renders the Ingress objects required by the chart.
*/}}
{{- define "bjw-s.common.render.ingresses" -}}
{{- /* 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 "bjw-s.common.lib.ingress.primary" $)) -}}
{{- $_ := set $ingressValues "nameOverride" $name -}}
{{- end -}}
{{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}}
{{- include "bjw-s.common.class.ingress" $ | nindent 0 -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -1,16 +1,16 @@
{{/* {{/*
Renders the Persistent Volume Claim objects required by the chart. Renders the Persistent Volume Claim objects required by the chart.
*/}} */}}
{{- define "common.pvc" -}} {{- define "bjw-s.common.render.pvcs" -}}
{{- /* Generate pvc as required */ -}} {{- /* Generate pvc as required */ -}}
{{- range $index, $PVC := .Values.persistence }} {{- range $index, $PVC := .Values.persistence -}}
{{- if and $PVC.enabled (eq (default "pvc" $PVC.type) "pvc") (not $PVC.existingClaim) -}} {{- if and $PVC.enabled (eq (default "pvc" $PVC.type) "pvc") (not $PVC.existingClaim) -}}
{{- $persistenceValues := $PVC -}} {{- $persistenceValues := $PVC -}}
{{- if not $persistenceValues.nameOverride -}} {{- if not $persistenceValues.nameOverride -}}
{{- $_ := set $persistenceValues "nameOverride" $index -}} {{- $_ := set $persistenceValues "nameOverride" $index -}}
{{- end -}} {{- end -}}
{{- $_ := set $ "ObjectValues" (dict "persistence" $persistenceValues) -}} {{- $_ := set $ "ObjectValues" (dict "persistence" $persistenceValues) -}}
{{- include "common.classes.pvc" $ | nindent 0 -}} {{- include "bjw-s.common.class.pvc" $ | nindent 0 -}}
{{- end }} {{- end -}}
{{- end }} {{- end -}}
{{- end }} {{- end -}}

View file

@ -0,0 +1,19 @@
{{/*
Renders the Secret objects required by the chart.
*/}}
{{- define "bjw-s.common.render.secrets" -}}
{{- /* Generate named Secrets as required */ -}}
{{- range $name, $secret := .Values.secrets -}}
{{- if $secret.enabled -}}
{{- $secretValues := $secret -}}
{{- /* set the default nameOverride to the Secret name */ -}}
{{- if not $secretValues.nameOverride -}}
{{- $_ := set $secretValues "nameOverride" $name -}}
{{ end -}}
{{- $_ := set $ "ObjectValues" (dict "secret" $secretValues) -}}
{{- include "bjw-s.common.class.secret" $ | nindent 0 -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -0,0 +1,20 @@
{{/*
Renders the serviceMonitor objects required by the chart.
*/}}
{{- define "bjw-s.common.render.serviceMonitors" -}}
{{- /* Generate named services as required */ -}}
{{- range $name, $serviceMonitor := .Values.serviceMonitor -}}
{{- if $serviceMonitor.enabled -}}
{{- $serviceMonitorValues := $serviceMonitor -}}
{{- if and (not $serviceMonitorValues.nameOverride) (ne $name "main") -}}
{{- $_ := set $serviceMonitorValues "nameOverride" $name -}}
{{- end -}}
{{/* Include the serviceMonitor class */}}
{{- $_ := set $ "ObjectValues" (dict "serviceMonitor" $serviceMonitorValues) -}}
{{- include "bjw-s.common.class.serviceMonitor" $ | nindent 0 -}}
{{- $_ := unset $.ObjectValues "serviceMonitor" -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -0,0 +1,8 @@
{{/*
Renders the serviceAccount object required by the chart.
*/}}
{{- define "bjw-s.common.render.serviceAccount" -}}
{{- if .Values.serviceAccount.create -}}
{{- include "bjw-s.common.class.serviceAccount" $ | nindent 0 -}}
{{- end -}}
{{- end -}}

View file

@ -0,0 +1,21 @@
{{/*
Renders the Service objects required by the chart.
*/}}
{{- define "bjw-s.common.render.services" -}}
{{- /* Generate named services as required */ -}}
{{- range $name, $service := .Values.service -}}
{{- if $service.enabled -}}
{{- $serviceValues := $service -}}
{{/* set the default nameOverride to the service name */}}
{{- if and (not $serviceValues.nameOverride) (ne $name (include "bjw-s.common.lib.service.primary" $)) -}}
{{- $_ := set $serviceValues "nameOverride" $name -}}
{{ end -}}
{{/* Include the Service class */}}
{{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}}
{{- include "bjw-s.common.class.service" $ | nindent 0 -}}
{{- $_ := unset $.ObjectValues "service" -}}
{{- end -}}
{{- end -}}
{{- end -}}

View file

@ -1,5 +1,7 @@
{{/* Merge the local chart values and the common chart defaults */}} {{/*
{{- define "common.values.setup" -}} Merge the local chart values and the common chart defaults
*/}}
{{- define "bjw-s.common.values.init" -}}
{{- if .Values.common -}} {{- if .Values.common -}}
{{- $defaultValues := deepCopy .Values.common -}} {{- $defaultValues := deepCopy .Values.common -}}
{{- $userValues := deepCopy (omit .Values "common") -}} {{- $userValues := deepCopy (omit .Values "common") -}}

View file

@ -59,16 +59,6 @@ podAnnotations: {}
# -- Set labels on the pod # -- Set labels on the pod
podLabels: {} podLabels: {}
# -- Add a Horizontal Pod Autoscaler
# @default -- <disabled>
autoscaling:
enabled: false
target: # deploymentname
minReplicas: # 1
maxReplicas: # 100
targetCPUUtilizationPercentage: # 80
targetMemoryUtilizationPercentage: # 80
serviceAccount: serviceAccount:
# -- Specifies whether a service account should be created # -- Specifies whether a service account should be created
create: false create: false
@ -83,16 +73,27 @@ serviceAccount:
# -- Specifies whether a service account token should be automatically mounted. # -- Specifies whether a service account token should be automatically mounted.
automountServiceAccountToken: true automountServiceAccountToken: true
# -- Use this to populate a secret with the values you specify. # -- Use this to populate secrets with the values you specify.
# Be aware that these values are not encrypted by default, and could therefore visible # Be aware that these values are not encrypted by default, and could therefore visible
# to anybody with access to the values.yaml file. # to anybody with access to the values.yaml file.
secret: {} # Additional Secrets can be added by adding a dictionary key similar to the 'secret' object.
# PASSWORD: my-password # @default -- See below
secrets:
secret:
# -- Enables or disables the Secret
enabled: false
# -- Labels to add to the Secret
labels: {}
# -- Annotations to add to the Secret
annotations: {}
# -- Secret stringData content. Helm template enabled.
stringData: {}
# foo: bar
# -- Configure configMaps for the chart here. # -- Configure configMaps for the chart here.
# Additional configMaps can be added by adding a dictionary key similar to the 'config' object. # Additional configMaps can be added by adding a dictionary key similar to the 'config' object.
# @default -- See below # @default -- See below
configmap: configMaps:
config: config:
# -- Enables or disables the configMap # -- Enables or disables the configMap
enabled: false enabled: false
@ -188,6 +189,9 @@ probes:
enabled: true enabled: true
# -- Set this to `true` if you wish to specify your own livenessProbe # -- Set this to `true` if you wish to specify your own livenessProbe
custom: false custom: false
# -- sets the probe type when not using a custom probe
# @default -- "TCP"
type: TCP
# -- The spec field contains the values for the default livenessProbe. # -- The spec field contains the values for the default livenessProbe.
# If you selected `custom: true`, this field holds the definition of the livenessProbe. # If you selected `custom: true`, this field holds the definition of the livenessProbe.
# @default -- See below # @default -- See below
@ -204,6 +208,9 @@ probes:
enabled: true enabled: true
# -- Set this to `true` if you wish to specify your own readinessProbe # -- Set this to `true` if you wish to specify your own readinessProbe
custom: false custom: false
# -- sets the probe type when not using a custom probe
# @default -- "TCP"
type: TCP
# -- The spec field contains the values for the default readinessProbe. # -- The spec field contains the values for the default readinessProbe.
# If you selected `custom: true`, this field holds the definition of the readinessProbe. # If you selected `custom: true`, this field holds the definition of the readinessProbe.
# @default -- See below # @default -- See below
@ -220,6 +227,9 @@ probes:
enabled: true enabled: true
# -- Set this to `true` if you wish to specify your own startupProbe # -- Set this to `true` if you wish to specify your own startupProbe
custom: false custom: false
# -- sets the probe type when not using a custom probe
# @default -- "TCP"
type: TCP
# -- The spec field contains the values for the default startupProbe. # -- The spec field contains the values for the default startupProbe.
# If you selected `custom: true`, this field holds the definition of the startupProbe. # If you selected `custom: true`, this field holds the definition of the startupProbe.
# @default -- See below # @default -- See below
@ -277,20 +287,6 @@ service:
# -- Provide additional labels which may be required. # -- Provide additional labels which may be required.
labels: {} labels: {}
# -- Configure a serviceMonitor for this Service.
# @default -- See below
monitor:
# -- Enables or disables the serviceMonitor.
enabled: false
# -- Configures the endpoints for the serviceMonitor.
# @default -- See values.yaml
endpoints:
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
# -- Configure the Service port information here. # -- Configure the Service port information here.
# Additional ports can be added by adding a dictionary key similar to the 'http' service. # Additional ports can be added by adding a dictionary key similar to the 'http' service.
# @default -- See below # @default -- See below
@ -320,6 +316,43 @@ service:
# [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport) # [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport)
nodePort: nodePort:
# -- Allow adding additional match labels
extraSelectorLabels: {}
# -- Configure the ServiceMonitors for the chart here.
# Additional ServiceMonitors can be added by adding a dictionary key similar to the 'main' ServiceMonitors.
# @default -- See below
serviceMonitor:
main:
# -- Enables or disables the serviceMonitor.
enabled: false
# -- Override the name suffix that is used for this serviceMonitor.
nameOverride:
# -- Provide additional annotations which may be required.
annotations: {}
# -- Provide additional labels which may be required.
labels: {}
# -- Configures a custom selector for the serviceMonitor, this takes precedence over
# specifying a service name.
# Helm templates can be used.
selector: {}
# -- Configures the target Service for the serviceMonitor. Helm templates can be used.
serviceName: main
# -- Configures the endpoints for the serviceMonitor.
# @default -- See values.yaml
endpoints:
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
# -- Configure the ingresses for the chart here. # -- Configure the ingresses for the chart here.
# Additional ingresses can be added by adding a dictionary key similar to the 'main' ingress. # Additional ingresses can be added by adding a dictionary key similar to the 'main' ingress.
# @default -- See below # @default -- See below
@ -344,7 +377,6 @@ ingress:
labels: {} labels: {}
# -- Set the ingressClass that is used for this ingress. # -- Set the ingressClass that is used for this ingress.
# Requires Kubernetes >=1.19
ingressClassName: # "nginx" ingressClassName: # "nginx"
## Configure the hosts for the ingress ## Configure the hosts for the ingress
@ -355,7 +387,6 @@ ingress:
paths: paths:
- # -- Path. Helm template can be passed. - # -- Path. Helm template can be passed.
path: / path: /
# -- Ignored if not kubeVersion >= 1.14-0
pathType: Prefix pathType: Prefix
service: service:
# -- Overrides the service name reference for this path # -- Overrides the service name reference for this path
@ -435,10 +466,14 @@ persistence:
# -- Used in conjunction with `controller.type: statefulset` to create individual disks for each instance. # -- Used in conjunction with `controller.type: statefulset` to create individual disks for each instance.
volumeClaimTemplates: [] volumeClaimTemplates: []
# - name: data # - name: data
# labels: {}
# annotations: {}
# mountPath: /data # mountPath: /data
# accessMode: "ReadWriteOnce" # accessMode: "ReadWriteOnce"
# size: 1Gi # size: 1Gi
# - name: backup # - name: backup
# labels: {}
# annotations: {}
# mountPath: /backup # mountPath: /backup
# subPath: theSubPath # subPath: theSubPath
# accessMode: "ReadWriteOnce" # accessMode: "ReadWriteOnce"
@ -507,7 +542,7 @@ addons:
# -- Specify the Gluetun image # -- Specify the Gluetun image
repository: docker.io/qmcgaw/gluetun repository: docker.io/qmcgaw/gluetun
# -- Specify the Gluetun image tag # -- Specify the Gluetun image tag
tag: v3.31.1 tag: v3.32.0
# -- Specify the Gluetun image pull policy # -- Specify the Gluetun image pull policy
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
@ -604,7 +639,7 @@ addons:
# -- Specify the code-server image # -- Specify the code-server image
repository: ghcr.io/coder/code-server repository: ghcr.io/coder/code-server
# -- Specify the code-server image tag # -- Specify the code-server image tag
tag: 4.7.1 tag: 4.8.2
# -- Specify the code-server image pull policy # -- Specify the code-server image pull policy
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
@ -651,7 +686,7 @@ addons:
port: 12321 port: 12321
enabled: true enabled: true
protocol: TCP protocol: TCP
targetPort: codeserver targetPort: 12321
## Specify the nodePort value for the LoadBalancer and NodePort service types. ## Specify the nodePort value for the LoadBalancer and NodePort service types.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
## ##
@ -670,14 +705,12 @@ addons:
labels: {} labels: {}
# -- Set the ingressClass that is used for this ingress. # -- Set the ingressClass that is used for this ingress.
# Requires Kubernetes >=1.19
ingressClassName: # "nginx" ingressClassName: # "nginx"
hosts: hosts:
- host: code.chart-example.local - host: code.chart-example.local
paths: paths:
- path: / - path: /
# Ignored if not kubeVersion >= 1.14-0
pathType: Prefix pathType: Prefix
tls: [] tls: []
# - secretName: chart-example-tls # - secretName: chart-example-tls

View file

@ -2,19 +2,20 @@
apiVersion: v2 apiVersion: v2
description: A common powered chart template. This can be useful for small projects that don't have their own chart. description: A common powered chart template. This can be useful for small projects that don't have their own chart.
name: app-template name: app-template
version: 0.2.2 version: 1.0.0
kubeVersion: ">=1.22.0-0"
maintainers: maintainers:
- name: bjw-s - name: bjw-s
email: me@bjw-s.dev email: me@bjw-s.dev
dependencies: dependencies:
- name: common - name: common
repository: https://bjw-s.github.io/helm-charts repository: https://bjw-s.github.io/helm-charts
version: 0.2.2 version: 1.0.0
annotations: annotations:
artifacthub.io/changes: |- artifacthub.io/changes: |-
- kind: changed - kind: changed
description: | description: |
Updated library version to 0.2.2. **BREAKING**: Updated library version to 1.0.0.
links: links:
- name: Common library chart definition - name: Common library chart definition
url: https://github.com/bjw-s/helm-charts/blob/main/charts/library/common/Chart.yaml url: https://github.com/bjw-s/helm-charts/blob/main/charts/library/common/Chart.yaml

View file

@ -23,9 +23,10 @@ persistence:
addons: addons:
codeserver: codeserver:
enabled: true enabled: true
git:
deployKey: test
workingDir: "/www/assets" workingDir: "/www/assets"
ingress: ingress:
main:
enabled: true enabled: true
volumeMounts: volumeMounts:
- name: config - name: config

View file

@ -1,15 +1,14 @@
--- ---
{{- include "common.values.setup" . }} {{- include "bjw-s.common.loader.init" . }}
{{- define "app-template.hardcodedValues" -}} {{- define "app-template.hardcodedValues" -}}
# Set the nameOverride based on the release name if no override has been set # Set the nameOverride based on the release name if no override has been set
{{ if not .Values.global.nameOverride }} {{ if not .Values.global.nameOverride }}
global: global:
nameOverride: "{{ .Release.Name }}" nameOverride: "{{ .Release.Name }}"
{{ end }} {{ end }}
{{- end -}} {{- end -}}
{{- $_ := mergeOverwrite .Values (include "app-template.hardcodedValues" . | fromYaml) -}} {{- $_ := mergeOverwrite .Values (include "app-template.hardcodedValues" . | fromYaml) -}}
{{ include "common.all" . }} {{/* Render the templates */}}
{{ include "bjw-s.common.loader.generate" . }}

View file

@ -29,15 +29,15 @@ tests:
asserts: asserts:
- hasDocuments: - hasDocuments:
count: 3 count: 3
- documentIndex: 0 - documentIndex: &DeploymentDocument 0
isKind:
of: Service
- documentIndex: &DeploymentDocument 1
isKind: isKind:
of: Deployment of: Deployment
- documentIndex: &AddonServiceDocument 2 - documentIndex: &AddonServiceDocument 2
isKind: isKind:
of: Service of: Service
- documentIndex: 1
isKind:
of: Service
- documentIndex: *DeploymentDocument - documentIndex: *DeploymentDocument
equal: equal:
path: spec.template.spec.containers[1].name path: spec.template.spec.containers[1].name
@ -63,87 +63,6 @@ tests:
- documentIndex: &AddonDeployKeySecretDocument 0 - documentIndex: &AddonDeployKeySecretDocument 0
isKind: isKind:
of: Secret of: Secret
- documentIndex: &DeploymentDocument 2
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /root/.ssh/id_rsa
name: deploykey
subPath: id_rsa
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: deploykey
secret:
defaultMode: 256
items:
- key: id_rsa
path: id_rsa
secretName: RELEASE-NAME-deploykey
- documentIndex: *AddonDeployKeySecretDocument
equal:
path: metadata.name
value: RELEASE-NAME-deploykey
- it: addon enabled with InlineBase64 deployKey should pass
set:
addons:
codeserver:
enabled: true
git:
deployKeyBase64: dGVzdEtleQ==
volumeMounts:
- name: "config"
mountPath: "/data/config"
asserts:
- hasDocuments:
count: 4
- documentIndex: &AddonDeployKeySecretDocument 0
isKind:
of: Secret
- documentIndex: &DeploymentDocument 2
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /root/.ssh/id_rsa
name: deploykey
subPath: id_rsa
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: deploykey
secret:
defaultMode: 256
items:
- key: id_rsa
path: id_rsa
secretName: RELEASE-NAME-deploykey
- documentIndex: *AddonDeployKeySecretDocument
equal:
path: metadata.name
value: RELEASE-NAME-deploykey
- it: addon enabled with existingSecret deployKey should pass
set:
addons:
codeserver:
enabled: true
git:
deployKeySecret: test-secret
volumeMounts:
- name: "config"
mountPath: "/data/config"
asserts:
- hasDocuments:
count: 3
- documentIndex: &DeploymentDocument 1 - documentIndex: &DeploymentDocument 1
isKind: isKind:
of: Deployment of: Deployment
@ -154,6 +73,87 @@ tests:
mountPath: /root/.ssh/id_rsa mountPath: /root/.ssh/id_rsa
name: deploykey name: deploykey
subPath: id_rsa subPath: id_rsa
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: deploykey
secret:
defaultMode: 256
items:
- key: id_rsa
path: id_rsa
secretName: RELEASE-NAME-addon-codeserver-deploykey
- documentIndex: *AddonDeployKeySecretDocument
equal:
path: metadata.name
value: RELEASE-NAME-addon-codeserver-deploykey
- it: addon enabled with InlineBase64 deployKey should pass
set:
addons:
codeserver:
enabled: true
git:
deployKeyBase64: dGVzdEtleQ==
volumeMounts:
- name: "config"
mountPath: "/data/config"
asserts:
- hasDocuments:
count: 4
- documentIndex: &AddonDeployKeySecretDocument 0
isKind:
of: Secret
- documentIndex: &DeploymentDocument 1
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /root/.ssh/id_rsa
name: deploykey
subPath: id_rsa
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: deploykey
secret:
defaultMode: 256
items:
- key: id_rsa
path: id_rsa
secretName: RELEASE-NAME-addon-codeserver-deploykey
- documentIndex: *AddonDeployKeySecretDocument
equal:
path: metadata.name
value: RELEASE-NAME-addon-codeserver-deploykey
- it: addon enabled with existingSecret deployKey should pass
set:
addons:
codeserver:
enabled: true
git:
deployKeySecret: test-secret
volumeMounts:
- name: "config"
mountPath: "/data/config"
asserts:
- hasDocuments:
count: 3
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /root/.ssh/id_rsa
name: deploykey
subPath: id_rsa
- documentIndex: *DeploymentDocument - documentIndex: *DeploymentDocument
contains: contains:
path: spec.template.spec.volumes path: spec.template.spec.volumes

View file

@ -68,11 +68,63 @@ tests:
items: items:
- key: vpnConfigfile - key: vpnConfigfile
path: vpnConfigfile path: vpnConfigfile
secretName: RELEASE-NAME-vpnconfig secretName: RELEASE-NAME-addon-vpn-config
- documentIndex: *AddonVPNConfigSecretDocument - documentIndex: *AddonVPNConfigSecretDocument
equal: equal:
path: metadata.name path: metadata.name
value: RELEASE-NAME-vpnconfig value: RELEASE-NAME-addon-vpn-config
- it: addon enabled with up/down scripts should pass
set:
addons:
vpn:
enabled: true
scripts:
up: |
test_up
down: |
test_down
asserts:
- hasDocuments:
count: 3
- documentIndex: &AddonVPNConfigConfigMapDocument 0
isKind:
of: ConfigMap
- documentIndex: &DeploymentDocument 1
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /gluetun/scripts/up.sh
name: vpnscript
subPath: up.sh
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /gluetun/scripts/down.sh
name: vpnscript
subPath: down.sh
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
configMap:
items:
- key: up.sh
mode: 511
path: up.sh
- key: down.sh
mode: 511
path: down.sh
name: RELEASE-NAME-addon-vpn
name: vpnscript
- documentIndex: *AddonVPNConfigConfigMapDocument
equal:
path: metadata.name
value: RELEASE-NAME-addon-vpn
- it: addon enabled with existing configFile secret should pass - it: addon enabled with existing configFile secret should pass
set: set:

View file

@ -4,7 +4,7 @@ templates:
tests: tests:
- it: default metadata should pass - it: default metadata should pass
set: set:
configmap: configMaps:
config: config:
enabled: true enabled: true
asserts: asserts:
@ -21,11 +21,11 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
- it: custom metadata should pass - it: custom metadata should pass
set: set:
configmap: configMaps:
config: config:
enabled: true enabled: true
annotations: annotations:
@ -48,7 +48,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test
- it: custom metadata with global metadata should pass - it: custom metadata with global metadata should pass
@ -58,7 +58,7 @@ tests:
global_label: test global_label: test
annotations: annotations:
global_annotation: test global_annotation: test
configmap: configMaps:
config: config:
enabled: true enabled: true
annotations: annotations:
@ -83,5 +83,5 @@ tests:
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
global_label: test global_label: test
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test

View file

@ -17,7 +17,7 @@ tests:
- it: with disabled configMap should pass - it: with disabled configMap should pass
set: set:
configmap: configMaps:
config: config:
enabled: false enabled: false
asserts: asserts:
@ -34,7 +34,7 @@ tests:
- it: with multiple configMap should pass - it: with multiple configMap should pass
set: set:
configmap: configMaps:
config: config:
enabled: true enabled: true
data: data:
@ -59,7 +59,7 @@ tests:
- it: default name should pass - it: default name should pass
set: set:
configmap: configMaps:
config: config:
enabled: true enabled: true
asserts: asserts:
@ -75,7 +75,7 @@ tests:
- it: with nameOverride should pass - it: with nameOverride should pass
set: set:
configmap: configMaps:
config: config:
enabled: true enabled: true
nameOverride: http nameOverride: http

View file

@ -4,7 +4,7 @@ templates:
tests: tests:
- it: default metadata should pass - it: default metadata should pass
set: set:
configmap: configMaps:
config: config:
enabled: true enabled: true
data: data:

View file

@ -19,7 +19,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
- it: custom metadata should pass - it: custom metadata should pass
set: set:
@ -45,7 +45,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test
- it: custom metadata with global metadata should pass - it: custom metadata with global metadata should pass
@ -79,5 +79,5 @@ tests:
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
global_label: test global_label: test
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test

View file

@ -19,7 +19,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
- it: custom metadata should pass - it: custom metadata should pass
set: set:
@ -45,7 +45,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test
- it: custom metadata with global metadata should pass - it: custom metadata with global metadata should pass
@ -79,5 +79,5 @@ tests:
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
global_label: test global_label: test
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test

View file

@ -19,7 +19,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
- it: custom metadata should pass - it: custom metadata should pass
set: set:
@ -45,7 +45,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test
- it: custom metadata with global metadata should pass - it: custom metadata with global metadata should pass
@ -79,5 +79,5 @@ tests:
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
global_label: test global_label: test
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test

View file

@ -19,7 +19,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
- it: custom metadata should pass - it: custom metadata should pass
set: set:
@ -45,7 +45,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test
- it: custom metadata with global metadata should pass - it: custom metadata with global metadata should pass
@ -79,5 +79,5 @@ tests:
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
global_label: test global_label: test
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test

View file

@ -13,8 +13,10 @@ tests:
equal: equal:
path: spec.rules[0].http.paths[0].backend path: spec.rules[0].http.paths[0].backend
value: value:
serviceName: RELEASE-NAME service:
servicePort: null name: RELEASE-NAME
port:
number: null
- it: custom service reference should pass - it: custom service reference should pass
set: set:
@ -35,5 +37,7 @@ tests:
equal: equal:
path: spec.rules[0].http.paths[0].backend path: spec.rules[0].http.paths[0].backend
value: value:
serviceName: pathService service:
servicePort: 1234 name: pathService
port:
number: 1234

View file

@ -54,7 +54,7 @@ tests:
configmap: configmap:
enabled: true enabled: true
type: configMap type: configMap
name: "{{ include \"common.names.fullname\" $ }}-config" name: "{{ include \"bjw-s.common.lib.chart.names.fullname\" $ }}-config"
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
isKind: isKind:

View file

@ -11,6 +11,10 @@ tests:
accessMode: "ReadWriteOnce" accessMode: "ReadWriteOnce"
size: "10Gi" size: "10Gi"
storageClass: "storage" storageClass: "storage"
labels:
test: "label"
annotations:
test: "annotation"
asserts: asserts:
- documentIndex: 0 - documentIndex: 0
isKind: isKind:
@ -21,6 +25,10 @@ tests:
value: value:
metadata: metadata:
name: storage name: storage
labels:
test: "label"
annotations:
test: "annotation"
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce

View file

@ -19,7 +19,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
- it: retain enabled should pass - it: retain enabled should pass
set: set:
@ -42,7 +42,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
- it: custom metadata should pass - it: custom metadata should pass
set: set:
@ -68,7 +68,7 @@ tests:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test
- it: custom metadata with global metadata should pass - it: custom metadata with global metadata should pass
@ -102,5 +102,5 @@ tests:
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
global_label: test global_label: test
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test

View file

@ -18,7 +18,7 @@ tests:
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
app.kubernetes.io/service: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
- it: custom metadata should pass - it: custom metadata should pass
set: set:
@ -45,7 +45,7 @@ tests:
app.kubernetes.io/managed-by: Helm app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
app.kubernetes.io/service: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test
- it: custom metadata with global metadata should pass - it: custom metadata with global metadata should pass
@ -80,5 +80,5 @@ tests:
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
app.kubernetes.io/service: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME
global_label: test global_label: test
helm.sh/chart: app-template-0.2.2 helm.sh/chart: app-template-1.0.0
test_label: test test_label: test

View file

@ -1,4 +1,4 @@
suite: service values suite: serviceMonitor values
templates: templates:
- common.yaml - common.yaml
tests: tests:
@ -15,9 +15,8 @@ tests:
- it: a serviceMonitor is not created when disabled - it: a serviceMonitor is not created when disabled
set: set:
service: serviceMonitor:
main: main:
monitor:
enabled: false enabled: false
asserts: asserts:
- hasDocuments: - hasDocuments:
@ -31,9 +30,8 @@ tests:
- it: a serviceMonitor is created - it: a serviceMonitor is created
set: set:
service: serviceMonitor:
main: main:
monitor:
enabled: true enabled: true
endpoints: endpoints:
- port: http - port: http
@ -57,7 +55,7 @@ tests:
value: value:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
app.kubernetes.io/service: RELEASE-NAME app.kubernetes.io/service: main
- documentIndex: *ServiceMonitorDocument - documentIndex: *ServiceMonitorDocument
equal: equal:
path: spec.endpoints path: spec.endpoints
@ -70,17 +68,10 @@ tests:
- it: a serviceMonitor is created with nameOverride - it: a serviceMonitor is created with nameOverride
set: set:
service: serviceMonitor:
main: main:
nameOverride: test
monitor:
enabled: true enabled: true
endpoints: nameOverride: test
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
asserts: asserts:
- hasDocuments: - hasDocuments:
count: 3 count: 3
@ -97,13 +88,53 @@ tests:
value: value:
app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME
app.kubernetes.io/service: RELEASE-NAME-test app.kubernetes.io/service: main
- it: a serviceMonitor is created with a templated service
set:
serviceMonitor:
main:
enabled: true
serviceName: "{{ .Release.Name }}"
asserts:
- hasDocuments:
count: 3
- documentIndex: &ServiceMonitorDocument 2
isKind:
of: ServiceMonitor
- documentIndex: *ServiceMonitorDocument - documentIndex: *ServiceMonitorDocument
equal: equal:
path: spec.endpoints path: metadata.name
value: RELEASE-NAME
- documentIndex: *ServiceMonitorDocument
equal:
path: spec.selector.matchLabels
value: value:
- port: http app.kubernetes.io/instance: RELEASE-NAME
scheme: http app.kubernetes.io/name: RELEASE-NAME
path: /metrics app.kubernetes.io/service: RELEASE-NAME
interval: 1m
scrapeTimeout: 10s - it: a serviceMonitor is created with a custom selector
set:
serviceMonitor:
main:
enabled: true
selector:
mySelector:
test: "true"
asserts:
- hasDocuments:
count: 3
- documentIndex: &ServiceMonitorDocument 2
isKind:
of: ServiceMonitor
- documentIndex: *ServiceMonitorDocument
equal:
path: metadata.name
value: RELEASE-NAME
- documentIndex: *ServiceMonitorDocument
equal:
path: spec.selector
value:
mySelector:
test: "true"