mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
fix(common): Release 2.0.2 (#196)
This commit is contained in:
parent
d86b0de790
commit
f729651dbe
16 changed files with 260 additions and 41 deletions
|
@ -75,9 +75,10 @@ nav:
|
||||||
- NFS share: common-library/storage/types/nfs-share.md
|
- NFS share: common-library/storage/types/nfs-share.md
|
||||||
- persistentVolumeClaim: common-library/storage/types/persistentVolumeClaim.md
|
- persistentVolumeClaim: common-library/storage/types/persistentVolumeClaim.md
|
||||||
- Secret: common-library/storage/types/secret.md
|
- Secret: common-library/storage/types/secret.md
|
||||||
- How To...:
|
|
||||||
- common-library/howto/index.md
|
|
||||||
- Helm templates: common-library/howto/helm-templates.md
|
|
||||||
- Multiple subPaths for 1 volume: common-library/howto/multiple-subpath.md
|
|
||||||
- App Template:
|
- App Template:
|
||||||
- app-template/index.md
|
- app-template/index.md
|
||||||
|
- How To...:
|
||||||
|
- app-template/howto/index.md
|
||||||
|
- Helm templates: app-template/howto/helm-templates.md
|
||||||
|
- Multiple subPaths for 1 volume: app-template/howto/multiple-subpath.md
|
||||||
|
- Multiple services with 1 or more controllers: app-template/howto/multiple-services.md
|
||||||
|
|
|
@ -6,13 +6,88 @@ templates:
|
||||||
tests:
|
tests:
|
||||||
- it: default should pass
|
- it: default should pass
|
||||||
asserts:
|
asserts:
|
||||||
- documentIndex: &ControllerDoc 0
|
- documentIndex: &deploymentDoc 0
|
||||||
isKind:
|
isKind:
|
||||||
of: Deployment
|
of: Deployment
|
||||||
- documentIndex: *ControllerDoc
|
- documentIndex: *deploymentDoc
|
||||||
equal:
|
equal:
|
||||||
path: metadata.name
|
path: metadata.name
|
||||||
value: RELEASE-NAME
|
value: RELEASE-NAME
|
||||||
|
- documentIndex: *deploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.labels['app.kubernetes.io/component']
|
||||||
|
value: main
|
||||||
|
|
||||||
|
- it: additional controllers should pass
|
||||||
|
set:
|
||||||
|
controllers:
|
||||||
|
second:
|
||||||
|
containers:
|
||||||
|
main:
|
||||||
|
image:
|
||||||
|
repository: ghcr.io/mendhak/http-https-echo
|
||||||
|
tag: 30
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 3
|
||||||
|
- documentIndex: &firstDeploymentDoc 0
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: *firstDeploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.name
|
||||||
|
value: RELEASE-NAME
|
||||||
|
- documentIndex: *firstDeploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.labels['app.kubernetes.io/component']
|
||||||
|
value: main
|
||||||
|
- documentIndex: &secondDeploymentDoc 1
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: *secondDeploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.name
|
||||||
|
value: RELEASE-NAME-second
|
||||||
|
- documentIndex: *secondDeploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.labels['app.kubernetes.io/component']
|
||||||
|
value: second
|
||||||
|
|
||||||
|
- it: additional controllers with nameOverride should pass
|
||||||
|
set:
|
||||||
|
controllers:
|
||||||
|
second:
|
||||||
|
nameOverride: testOverride
|
||||||
|
containers:
|
||||||
|
main:
|
||||||
|
image:
|
||||||
|
repository: ghcr.io/mendhak/http-https-echo
|
||||||
|
tag: 30
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 3
|
||||||
|
- documentIndex: &firstDeploymentDoc 0
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: *firstDeploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.name
|
||||||
|
value: RELEASE-NAME
|
||||||
|
- documentIndex: *firstDeploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.labels['app.kubernetes.io/component']
|
||||||
|
value: main
|
||||||
|
- documentIndex: &secondDeploymentDoc 1
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: *secondDeploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.name
|
||||||
|
value: RELEASE-NAME-testOverride
|
||||||
|
- documentIndex: *secondDeploymentDoc
|
||||||
|
equal:
|
||||||
|
path: metadata.labels['app.kubernetes.io/component']
|
||||||
|
value: second
|
||||||
|
|
||||||
- it: daemonset should pass
|
- it: daemonset should pass
|
||||||
set:
|
set:
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
---
|
||||||
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||||
|
suite: pod serviceAccount
|
||||||
|
templates:
|
||||||
|
- common.yaml
|
||||||
|
tests:
|
||||||
|
- it: default should pass
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 2
|
||||||
|
- documentIndex: &deploymentDocument 0
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: *deploymentDocument
|
||||||
|
equal:
|
||||||
|
path: spec.template.spec.serviceAccountName
|
||||||
|
value: default
|
||||||
|
|
||||||
|
- it: with create, without name should pass
|
||||||
|
set:
|
||||||
|
serviceAccount:
|
||||||
|
create: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 4
|
||||||
|
- documentIndex: &serviceAccountDocument 0
|
||||||
|
isKind:
|
||||||
|
of: ServiceAccount
|
||||||
|
- documentIndex: &deploymentDocument 1
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: *deploymentDocument
|
||||||
|
equal:
|
||||||
|
path: spec.template.spec.serviceAccountName
|
||||||
|
value: RELEASE-NAME
|
||||||
|
|
||||||
|
- it: with create, with name should pass
|
||||||
|
set:
|
||||||
|
serviceAccount:
|
||||||
|
create: true
|
||||||
|
name: mySA
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 4
|
||||||
|
- documentIndex: &serviceAccountDocument 0
|
||||||
|
isKind:
|
||||||
|
of: ServiceAccount
|
||||||
|
- documentIndex: &deploymentDocument 1
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: *deploymentDocument
|
||||||
|
equal:
|
||||||
|
path: spec.template.spec.serviceAccountName
|
||||||
|
value: mySA
|
||||||
|
|
||||||
|
- it: without create, with name should pass
|
||||||
|
set:
|
||||||
|
serviceAccount:
|
||||||
|
create: false
|
||||||
|
name: mySA
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 2
|
||||||
|
- documentIndex: &deploymentDocument 0
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: *deploymentDocument
|
||||||
|
equal:
|
||||||
|
path: spec.template.spec.serviceAccountName
|
||||||
|
value: mySA
|
|
@ -3,7 +3,7 @@ apiVersion: v2
|
||||||
name: common
|
name: common
|
||||||
description: Function library for Helm charts
|
description: Function library for Helm charts
|
||||||
type: library
|
type: library
|
||||||
version: 2.0.1
|
version: 2.0.2
|
||||||
kubeVersion: ">=1.22.0-0"
|
kubeVersion: ">=1.22.0-0"
|
||||||
keywords:
|
keywords:
|
||||||
- common
|
- common
|
||||||
|
@ -16,10 +16,7 @@ annotations:
|
||||||
artifacthub.io/changes: |-
|
artifacthub.io/changes: |-
|
||||||
- kind: fixed
|
- kind: fixed
|
||||||
description: |-
|
description: |-
|
||||||
Mounting of volumeClaimTemplates was not implemented properly.
|
ServiceAccount could not be referenced without creating
|
||||||
- kind: fixed
|
- kind: fixed
|
||||||
description: |-
|
description: |-
|
||||||
Using advancedMounts for initContainers resulted in an error.
|
Controllers without a type did not default to Deployment
|
||||||
- kind: fixed
|
|
||||||
description: |-
|
|
||||||
Validations for container images have been improved.
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# common
|
# common
|
||||||
|
|
||||||
 
|
 
|
||||||
|
|
||||||
Function library for Helm charts
|
Function library for Helm charts
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
|
||||||
# Chart.yaml
|
# Chart.yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: common
|
- name: common
|
||||||
version: 2.0.1
|
version: 2.0.2
|
||||||
repository: https://bjw-s.github.io/helm-charts/
|
repository: https://bjw-s.github.io/helm-charts/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,11 @@ Convert controller values to an object
|
||||||
{{- $identifier := .id -}}
|
{{- $identifier := .id -}}
|
||||||
{{- $objectValues := .values -}}
|
{{- $objectValues := .values -}}
|
||||||
|
|
||||||
|
{{- /* Default the controller type to Deployment */ -}}
|
||||||
|
{{- if eq (dig "type" "" $objectValues) "" -}}
|
||||||
|
{{- $_ := set $objectValues "type" "deployment" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{- /* Determine and inject the controller name */ -}}
|
{{- /* Determine and inject the controller name */ -}}
|
||||||
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
|
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
|
||||||
|
|
||||||
|
|
|
@ -4,15 +4,8 @@ Returns the value for serviceAccountName
|
||||||
{{- define "bjw-s.common.lib.pod.field.serviceAccountName" -}}
|
{{- define "bjw-s.common.lib.pod.field.serviceAccountName" -}}
|
||||||
{{- $rootContext := .ctx.rootContext -}}
|
{{- $rootContext := .ctx.rootContext -}}
|
||||||
|
|
||||||
{{- /* Default to "default" */ -}}
|
|
||||||
{{- $name := "default" -}}
|
|
||||||
|
|
||||||
{{- /* See if an override is needed */ -}}
|
|
||||||
{{- if $rootContext.Values.serviceAccount.create -}}
|
|
||||||
{{- $serviceAccountValues := (mustDeepCopy $rootContext.Values.serviceAccount) -}}
|
{{- $serviceAccountValues := (mustDeepCopy $rootContext.Values.serviceAccount) -}}
|
||||||
{{- $serviceAccountObject := (include "bjw-s.common.lib.serviceAccount.valuesToObject" (dict "rootContext" $rootContext "id" "default" "values" $serviceAccountValues)) | fromYaml -}}
|
{{- $serviceAccountObject := (include "bjw-s.common.lib.serviceAccount.valuesToObject" (dict "rootContext" $rootContext "id" "default" "values" $serviceAccountValues)) | fromYaml -}}
|
||||||
{{- $name = $serviceAccountObject.name -}}
|
{{- $serviceAccountObject.name -}}
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- $name -}}
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -6,7 +6,7 @@ Validate Service values
|
||||||
{{- $serviceObject := .object -}}
|
{{- $serviceObject := .object -}}
|
||||||
|
|
||||||
{{- if empty (get $serviceObject "controller") -}}
|
{{- if empty (get $serviceObject "controller") -}}
|
||||||
{{- fail (printf "controller is required for Service. (service: %s)" $serviceObject.identifier) -}}
|
{{- fail (printf "controller field is required for Service. (service: %s)" $serviceObject.identifier) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- /* Validate Service type */ -}}
|
{{- /* Validate Service type */ -}}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{/*
|
{{/*
|
||||||
Convert Secret values to an object
|
Convert ServiceAccount values to an object
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "bjw-s.common.lib.serviceAccount.valuesToObject" -}}
|
{{- define "bjw-s.common.lib.serviceAccount.valuesToObject" -}}
|
||||||
{{- $rootContext := .rootContext -}}
|
{{- $rootContext := .rootContext -}}
|
||||||
|
@ -7,12 +7,15 @@ Convert Secret values to an object
|
||||||
{{- $objectValues := .values -}}
|
{{- $objectValues := .values -}}
|
||||||
|
|
||||||
{{- /* Determine and inject the serviceAccount name */ -}}
|
{{- /* Determine and inject the serviceAccount name */ -}}
|
||||||
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
|
{{- $serviceAccountName := "" -}}
|
||||||
|
{{- $defaultServiceAccountName := "default" -}}
|
||||||
{{- if $objectValues.name -}}
|
{{- if $objectValues.create -}}
|
||||||
{{- $objectName = $objectValues.name -}}
|
{{- $defaultServiceAccountName = (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- $_ := set $objectValues "name" $objectName -}}
|
|
||||||
|
{{- $serviceAccountName = default $defaultServiceAccountName $objectValues.name -}}
|
||||||
|
|
||||||
|
{{- $_ := set $objectValues "name" $serviceAccountName -}}
|
||||||
{{- $_ := set $objectValues "identifier" $identifier -}}
|
{{- $_ := set $objectValues "identifier" $identifier -}}
|
||||||
|
|
||||||
{{- /* Return the serviceAccount object */ -}}
|
{{- /* Return the serviceAccount object */ -}}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
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: 2.0.1
|
version: 2.0.2
|
||||||
kubeVersion: ">=1.22.0-0"
|
kubeVersion: ">=1.22.0-0"
|
||||||
maintainers:
|
maintainers:
|
||||||
- name: bjw-s
|
- name: bjw-s
|
||||||
|
@ -10,12 +10,12 @@ maintainers:
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: common
|
- name: common
|
||||||
repository: https://bjw-s.github.io/helm-charts
|
repository: https://bjw-s.github.io/helm-charts
|
||||||
version: 2.0.1
|
version: 2.0.2
|
||||||
annotations:
|
annotations:
|
||||||
artifacthub.io/changes: |-
|
artifacthub.io/changes: |-
|
||||||
- kind: changed
|
- kind: changed
|
||||||
description: |
|
description: |
|
||||||
Updated library version to 2.0.1.
|
Updated library version to 2.0.2.
|
||||||
links:
|
links:
|
||||||
- name: Upgrade instructions from v1.x
|
- name: Upgrade instructions from v1.x
|
||||||
url: https://github.com/bjw-s/helm-charts/tree/main/charts/other/app-template#from-1xx-to-20x
|
url: https://github.com/bjw-s/helm-charts/tree/main/charts/other/app-template#from-1xx-to-20x
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# app-template
|
# app-template
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
A common powered chart template. This can be useful for small projects that don't have their own chart.
|
A common powered chart template. This can be useful for small projects that don't have their own chart.
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ Kubernetes: `>=1.22.0-0`
|
||||||
|
|
||||||
| Repository | Name | Version |
|
| Repository | Name | Version |
|
||||||
|------------|------|---------|
|
|------------|------|---------|
|
||||||
| https://bjw-s.github.io/helm-charts | common | 2.0.1 |
|
| https://bjw-s.github.io/helm-charts | common | 2.0.2 |
|
||||||
|
|
||||||
## Installing the Chart
|
## Installing the Chart
|
||||||
|
|
||||||
|
|
80
docs/app-template/howto/multiple-services.md
Normal file
80
docs/app-template/howto/multiple-services.md
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
# Multiple Services
|
||||||
|
|
||||||
|
## With a single controller
|
||||||
|
|
||||||
|
It is possible to have multiple Service objects that point to a single controller.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
controllers:
|
||||||
|
main:
|
||||||
|
containers:
|
||||||
|
main:
|
||||||
|
image:
|
||||||
|
repository: ghcr.io/mendhak/http-https-echo
|
||||||
|
tag: 30
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
service:
|
||||||
|
main:
|
||||||
|
# The controller for this service is set to
|
||||||
|
# "main" by the default app-template values
|
||||||
|
# controller: main
|
||||||
|
ports:
|
||||||
|
http:
|
||||||
|
port: 8080
|
||||||
|
second:
|
||||||
|
controller: main # (1)!
|
||||||
|
ports:
|
||||||
|
http:
|
||||||
|
port: 8081
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Point to the controller with the "main" identifier
|
||||||
|
|
||||||
|
## With multiple controllers
|
||||||
|
|
||||||
|
It is also possible have multiple Service objects that point to different controllers.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
controllers:
|
||||||
|
main:
|
||||||
|
containers:
|
||||||
|
main:
|
||||||
|
image:
|
||||||
|
repository: ghcr.io/mendhak/http-https-echo
|
||||||
|
tag: 30
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
second:
|
||||||
|
containers:
|
||||||
|
main:
|
||||||
|
image:
|
||||||
|
repository: ghcr.io/mendhak/http-https-echo
|
||||||
|
tag: 30
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
service:
|
||||||
|
main:
|
||||||
|
# The controller for this service is set to
|
||||||
|
# "main" by the default app-template values
|
||||||
|
# controller: main
|
||||||
|
ports:
|
||||||
|
http:
|
||||||
|
port: 8080
|
||||||
|
second:
|
||||||
|
controller: main # (1)!
|
||||||
|
ports:
|
||||||
|
http:
|
||||||
|
port: 8081
|
||||||
|
third:
|
||||||
|
controller: second # (2)!
|
||||||
|
ports:
|
||||||
|
http:
|
||||||
|
port: 8081
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Point to the controller with the "main" identifier
|
||||||
|
2. Point to the controller with the "second" identifier
|
|
@ -1,8 +1,3 @@
|
||||||
---
|
|
||||||
hide:
|
|
||||||
- navigation
|
|
||||||
---
|
|
||||||
|
|
||||||
# App Template
|
# App Template
|
||||||
|
|
||||||
## Background
|
## Background
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue