mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 00:27:04 +02:00
feat: Bump common library to v3.4.0 (#349)
This commit is contained in:
parent
a78c21ab00
commit
86062681a9
45 changed files with 1023 additions and 149 deletions
|
@ -75,6 +75,9 @@ nav:
|
|||
- NFS share: common-library/storage/types/nfs-share.md
|
||||
- persistentVolumeClaim: common-library/storage/types/persistentVolumeClaim.md
|
||||
- Secret: common-library/storage/types/secret.md
|
||||
- How To...:
|
||||
- common-library/howto/index.md
|
||||
- Default container options: common-library/howto/default-container-options.md
|
||||
- App Template:
|
||||
- app-template/index.md
|
||||
- How To...:
|
||||
|
|
5
.github/workflows/charts-release-oci.yaml
vendored
5
.github/workflows/charts-release-oci.yaml
vendored
|
@ -21,6 +21,7 @@ jobs:
|
|||
name: Release charts
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write # needed for ghcr access
|
||||
actions: read # for detecting the Github Actions environment.
|
||||
id-token: write # for creating OIDC tokens for signing.
|
||||
|
@ -61,8 +62,8 @@ jobs:
|
|||
helm package "${{ env.CHARTS_SRC_DIR }}/${CHART_TYPE}/${CHART_NAME}" --dependency-update --destination "${{ env.CHARTS_SRC_DIR }}/${CHART_TYPE}" --version "${CHART_VERSION}"
|
||||
helm push "${{ env.CHARTS_SRC_DIR }}/${CHART_TYPE}/${CHART_NAME}-${CHART_VERSION}.tgz" oci://${{ env.TARGET_REGISTRY }}/${{ github.actor }}/helm &> push-metadata.txt
|
||||
CHART_DIGEST=$(awk '/Digest: /{print $2}' push-metadata.txt)
|
||||
cosign sign -y "${{ env.TARGET_REGISTRY }}/${{ github.actor }}/helm/${CHART_NAME}:${CHART_VERSION}@${CHART_DIGEST}"
|
||||
cosign sign --yes "${{ env.TARGET_REGISTRY }}/${{ github.actor }}/helm/${CHART_NAME}:${CHART_VERSION}@${CHART_DIGEST}"
|
||||
cosign verify "${{ env.TARGET_REGISTRY }}/${{ github.actor }}/helm/${CHART_NAME}:${CHART_VERSION}@${CHART_DIGEST}" \
|
||||
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
|
||||
--certificate-identity "https://github.com/${GITHUB_WORKFLOW_REF}"
|
||||
--certificate-identity "https://github.com/bjw-s/helm-charts/.github/workflows/charts-release-oci.yaml@refs/heads/main"
|
||||
done
|
||||
|
|
1
.github/workflows/pr-validate.yaml
vendored
1
.github/workflows/pr-validate.yaml
vendored
|
@ -4,7 +4,6 @@ on:
|
|||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
- reopened
|
||||
- ready_for_review
|
||||
- synchronize
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
apiVersion: v2
|
||||
description: Kubernetes admission controller to remove CPU limits from Pods.
|
||||
name: k8s-ycl
|
||||
version: 1.3.2
|
||||
version: 1.3.3
|
||||
appVersion: v0.2.0
|
||||
kubeVersion: ">=1.22.0-0"
|
||||
sources:
|
||||
|
@ -19,12 +19,12 @@ maintainers:
|
|||
dependencies:
|
||||
- name: common
|
||||
repository: https://bjw-s.github.io/helm-charts
|
||||
version: 3.3.2
|
||||
version: 3.4.0
|
||||
annotations:
|
||||
artifacthub.io/changes: |-
|
||||
- kind: changed
|
||||
description: |
|
||||
Update common library to 3.3.2
|
||||
Update common library to 3.4.0
|
||||
artifacthub.io/links: |
|
||||
- name: "source"
|
||||
url: "https://github.com/bjw-s/k8s-ycl"
|
||||
|
|
|
@ -20,7 +20,7 @@ Kubernetes: `>=1.22.0-0`
|
|||
|
||||
| Repository | Name | Version |
|
||||
|------------|------|---------|
|
||||
| https://bjw-s.github.io/helm-charts | common | 3.3.2 |
|
||||
| https://bjw-s.github.io/helm-charts | common | 3.4.0 |
|
||||
|
||||
## Values
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.3.2/charts/library/common/values.schema.json"
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.4.0/charts/library/common/values.schema.json"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#! /bin/bash
|
||||
echo "Hello!"
|
|
@ -0,0 +1,2 @@
|
|||
test:
|
||||
test: "{{ .Values.configMapsFromFolderBasePath }}"
|
|
@ -0,0 +1,2 @@
|
|||
test:
|
||||
test: "{{ .Values.configMapsFromFolderBasePath }}"
|
|
@ -6,4 +6,3 @@ controllers:
|
|||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
pullPolicy: IfNotPresent
|
||||
|
|
|
@ -98,3 +98,56 @@ tests:
|
|||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: default metadata from folder should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
configMapsFromFolderBasePath: ci/configMapsFolder
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
- documentIndex: &SecondConfigmapDocument 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
- documentIndex: &ThirdConfigmapDocument 3
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
|
|
|
@ -107,3 +107,36 @@ tests:
|
|||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: with templated nameOverride and from folder should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
configMapsFromFolderBasePath: ci/configMapsFolder
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: &SecondConfigmapDocument 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test_1
|
||||
- documentIndex: &ThirdConfigmapDocument 3
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test_2
|
||||
|
|
|
@ -75,3 +75,35 @@ tests:
|
|||
- sleep
|
||||
- infinity
|
||||
- test
|
||||
|
||||
- it: args from defaultContainerOptions should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
args: value_of_args
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].args
|
||||
value:
|
||||
- value_of_args
|
||||
|
||||
- it: args from defaultContainerOptions with container override should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
args: value_of_args
|
||||
controllers.main.containers.main.args:
|
||||
- value 1
|
||||
- value 2
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].args
|
||||
value:
|
||||
- value 1
|
||||
- value 2
|
|
@ -73,3 +73,35 @@ tests:
|
|||
value:
|
||||
- /bin/sh
|
||||
- -c
|
||||
|
||||
- it: command from defaultContainerOptions should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
command: value_of_command
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].command
|
||||
value:
|
||||
- value_of_command
|
||||
|
||||
- it: command from defaultContainerOptions with container override should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
command: value_of_command
|
||||
controllers.main.containers.main.command:
|
||||
- value 1
|
||||
- value 2
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].command
|
||||
value:
|
||||
- value 1
|
||||
- value 2
|
|
@ -237,3 +237,37 @@ tests:
|
|||
value:
|
||||
name: DEPENDENT_ENV
|
||||
value: moo_two
|
||||
|
||||
- it: env from defaultContainerOptions should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
env:
|
||||
string: value_of_env
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].env[0]
|
||||
value:
|
||||
name: string
|
||||
value: value_of_env
|
||||
|
||||
- it: env from defaultContainerOptions with container override should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
env:
|
||||
string: value_of_env
|
||||
controllers.main.containers.main.env:
|
||||
someThingElse: value_of_env
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].env[0]
|
||||
value:
|
||||
name: someThingElse
|
||||
value: value_of_env
|
|
@ -41,6 +41,61 @@ tests:
|
|||
configMapRef:
|
||||
name: myCustomConfig
|
||||
|
||||
- it: envFrom from defaultContainerOptions should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: myCustomSecret
|
||||
prefix: test
|
||||
- configMapRef:
|
||||
name: myCustomConfig
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].envFrom[0]
|
||||
value:
|
||||
secretRef:
|
||||
name: myCustomSecret
|
||||
prefix: test
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].envFrom[1]
|
||||
value:
|
||||
configMapRef:
|
||||
name: myCustomConfig
|
||||
|
||||
- it: envFrom from defaultContainerOptions with container override should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: myCustomSecret
|
||||
prefix: test
|
||||
- configMapRef:
|
||||
name: myCustomConfig
|
||||
controllers.main.containers.main.envFrom:
|
||||
- secretRef:
|
||||
name: myCustomSecretOverride
|
||||
prefix: test
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].envFrom[0]
|
||||
value:
|
||||
secretRef:
|
||||
name: myCustomSecretOverride
|
||||
prefix: test
|
||||
- documentIndex: *DeploymentDoc
|
||||
notExists:
|
||||
path: spec.template.spec.containers[0].envFrom[1]
|
||||
|
||||
- it: envFrom configmap identifier reference should pass
|
||||
set:
|
||||
controllers.main.containers.main.envFrom:
|
|
@ -3,10 +3,10 @@
|
|||
suite: container image tag
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: string tag should pass
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
controllers.main.containers.main.image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
|
@ -21,6 +21,8 @@ tests:
|
|||
value: ghcr.io/mendhak/http-https-echo:latest
|
||||
|
||||
- it: integer tag should pass
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
controllers.main.containers.main.image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
|
@ -35,6 +37,8 @@ tests:
|
|||
value: ghcr.io/mendhak/http-https-echo:1.23
|
||||
|
||||
- it: template tag should pass
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
set:
|
||||
controllers.main.containers.main.image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
|
@ -47,3 +51,38 @@ tests:
|
|||
equal:
|
||||
path: spec.template.spec.containers[0].image
|
||||
value: ghcr.io/mendhak/http-https-echo:1.0.0
|
||||
|
||||
- it: tag from defaultContainerOptions should pass
|
||||
set:
|
||||
controllers.main:
|
||||
defaultContainerOptions:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 32
|
||||
containers:
|
||||
main: {} # needed to have at least a container enabled
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].image
|
||||
value: ghcr.io/mendhak/http-https-echo:32
|
||||
|
||||
- it: tag from defaultContainerOptions with container override should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions.image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 32
|
||||
controllers.main.containers.main.image:
|
||||
repository: ghcr.io/mendhak/http-https-echo-override
|
||||
tag: 33
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].image
|
||||
value: ghcr.io/mendhak/http-https-echo-override:33
|
|
@ -0,0 +1,142 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: container resources
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
|
||||
- it: defaultContainerOption should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
initContainers:
|
||||
test:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.initContainers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
|
||||
- it: defaultContainerOption with container override should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
containers:
|
||||
main:
|
||||
resources:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
initContainers:
|
||||
test:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.initContainers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
|
||||
- it: defaultContainerOption with initContainer override should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
initContainers:
|
||||
test:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
resources:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.initContainers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
|
||||
- it: defaultContainerOption disabled for initContainer should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
applyDefaultContainerOptionsToInitContainers: false
|
||||
defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
initContainers:
|
||||
test:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
path: spec.template.spec.initContainers[0].resources
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: container securityContext
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
path: spec.template.spec.containers[0].securityContext
|
||||
|
||||
- it: defaultContainerOption should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
defaultContainerOptions:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].securityContext
|
||||
value:
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
|
||||
- it: defaultContainerOption with container override should pass
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
defaultContainerOptions:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
containers:
|
||||
main:
|
||||
securityContext:
|
||||
runAsUser: 568
|
||||
runAsGroup: 568
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].securityContext
|
||||
value:
|
||||
runAsUser: 568
|
||||
runAsGroup: 568
|
|
@ -0,0 +1,136 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: controller defaultContainerOptions
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
|
||||
- it: defaultContainerOption with implicit strategy should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 150m
|
||||
controllers.main.containers.main.resources:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
|
||||
- it: defaultContainerOption with overwrite strategy should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptionsStrategy: overwrite
|
||||
controllers.main.defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 150m
|
||||
controllers.main.containers.main.resources:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
|
||||
- it: defaultContainerOption with merge strategy should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptionsStrategy: merge
|
||||
controllers.main.defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 150m
|
||||
controllers.main.containers.main.resources:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 2Gi
|
||||
cpu: 150m
|
||||
|
||||
- it: Default applyDefaultContainerOptionsToInitContainers (true) should pass
|
||||
set:
|
||||
controllers.main.defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
controllers.main.initContainers:
|
||||
test:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.initContainers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
|
||||
- it: applyDefaultContainerOptionsToInitContainers false should pass
|
||||
set:
|
||||
controllers.main.applyDefaultContainerOptionsToInitContainers: false
|
||||
controllers.main.defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
controllers.main.initContainers:
|
||||
test:
|
||||
image:
|
||||
repository: ghcr.io/mendhak/http-https-echo
|
||||
tag: 31
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].resources
|
||||
value:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
path: spec.template.spec.initContainers[0].resources
|
|
@ -3,7 +3,7 @@ apiVersion: v2
|
|||
name: common
|
||||
description: Function library for Helm charts
|
||||
type: library
|
||||
version: 3.3.2
|
||||
version: 3.4.0
|
||||
kubeVersion: ">=1.22.0-0"
|
||||
keywords:
|
||||
- common
|
||||
|
@ -16,16 +16,16 @@ annotations:
|
|||
artifacthub.io/changes: |-
|
||||
- kind: added
|
||||
description: |-
|
||||
Added support for specifying unsupported raw resources.
|
||||
Add configMapsFromFolderBasePath to create ConfigMaps from a folder
|
||||
- kind: added
|
||||
description: |-
|
||||
Added `stdin` and `tty` fields to container spec. (fixed in v3.3.2)
|
||||
Added support for setting `defaultContainerOptions`.
|
||||
links:
|
||||
- name: Documentation
|
||||
url: https://bjw-s.github.io/helm-charts/docs/common-library/howto/default-container-options
|
||||
- kind: added
|
||||
description: |-
|
||||
Added `persistentVolumeClaimRetentionPolicy` field to statefulset spec.
|
||||
Added support for `loadBalancerClass`.
|
||||
- kind: fixed
|
||||
description: |-
|
||||
Added `externalName` field to service schema. (fixed in v3.3.1)
|
||||
- kind: fixed
|
||||
description: |-
|
||||
Always allow specifying `nodePort` field on service ports.
|
||||
Fixed volume name reference when persistence key matches release name.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# common
|
||||
|
||||
 
|
||||
 
|
||||
|
||||
Function library for Helm charts
|
||||
|
||||
|
@ -27,7 +27,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
|
|||
# Chart.yaml
|
||||
dependencies:
|
||||
- name: common
|
||||
version: 3.3.2
|
||||
version: 3.4.0
|
||||
repository: https://bjw-s.github.io/helm-charts/
|
||||
```
|
||||
|
||||
|
@ -50,4 +50,4 @@ These values will be validated by a JSON schema which can be found [here](https:
|
|||
- Join the home-operations [Discord](https://discord.gg/home-operations) community
|
||||
|
||||
----------------------------------------------
|
||||
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
|
||||
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
|
||||
|
|
|
@ -9,22 +9,10 @@
|
|||
"default": true
|
||||
},
|
||||
"args": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
{"type": "string"}
|
||||
]
|
||||
"$ref": "#/args"
|
||||
},
|
||||
"command": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
{"type": "string"}
|
||||
]
|
||||
"$ref": "#/command"
|
||||
},
|
||||
"dependsOn": {
|
||||
"oneOf": [
|
||||
|
@ -36,82 +24,13 @@
|
|||
]
|
||||
},
|
||||
"env": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"$ref": "envVars.json#/envVarListItem"},
|
||||
{"$ref": "envVars.json#/valueFromListItem"}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{"$ref": "envVars.json#/envVarValue"},
|
||||
{"$ref": "envVars.json#/envVarItem"},
|
||||
{"$ref": "envVars.json#/valueFromItem"}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
"$ref": "#/env"
|
||||
},
|
||||
"envFrom": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"configMap": {
|
||||
"type": "string"
|
||||
},
|
||||
"configMapRef": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"identifier": {"type": "string"},
|
||||
"optional": {"type": "boolean"}
|
||||
},
|
||||
"oneOf": [{"required": ["name"]}, {"required": ["identifier"]}]
|
||||
},
|
||||
"prefix": {
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"secret": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretRef": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"identifier": {"type": "string"},
|
||||
"optional": {"type": "boolean"}
|
||||
},
|
||||
"oneOf": [{"required": ["name"]}, {"required": ["identifier"]}]
|
||||
}
|
||||
}
|
||||
}
|
||||
"$ref": "#/envFrom"
|
||||
},
|
||||
"image": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"pullPolicy": {
|
||||
"type": "string",
|
||||
"enum": ["Always", "IfNotPresent"]
|
||||
},
|
||||
"repository": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": ["string", "number"]
|
||||
}
|
||||
},
|
||||
"required": ["repository", "tag"]
|
||||
"$ref": "#/image"
|
||||
},
|
||||
"lifecycle": {
|
||||
"$ref": "k8s-api.json#/core.v1.Lifecycle"
|
||||
|
@ -170,6 +89,106 @@
|
|||
}
|
||||
},
|
||||
|
||||
"args": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
{"type": "string"}
|
||||
]
|
||||
},
|
||||
|
||||
"command": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
{"type": "string"}
|
||||
]
|
||||
},
|
||||
|
||||
"env": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"$ref": "envVars.json#/envVarListItem"},
|
||||
{"$ref": "envVars.json#/valueFromListItem"}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{"$ref": "envVars.json#/envVarValue"},
|
||||
{"$ref": "envVars.json#/envVarItem"},
|
||||
{"$ref": "envVars.json#/valueFromItem"}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"envFrom": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"configMap": {
|
||||
"type": "string"
|
||||
},
|
||||
"configMapRef": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"identifier": {"type": "string"},
|
||||
"optional": {"type": "boolean"}
|
||||
},
|
||||
"oneOf": [{"required": ["name"]}, {"required": ["identifier"]}]
|
||||
},
|
||||
"prefix": {
|
||||
"type": ["string", "null"]
|
||||
},
|
||||
"secret": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretRef": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"name": {"type": "string"},
|
||||
"identifier": {"type": "string"},
|
||||
"optional": {"type": "boolean"}
|
||||
},
|
||||
"oneOf": [{"required": ["name"]}, {"required": ["identifier"]}]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"image": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"pullPolicy": {
|
||||
"type": "string",
|
||||
"enum": ["Always", "IfNotPresent"]
|
||||
},
|
||||
"repository": {
|
||||
"type": "string"
|
||||
},
|
||||
"tag": {
|
||||
"type": ["string", "number"]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"probe": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
|
|
@ -47,6 +47,42 @@
|
|||
"statefulset": {
|
||||
"$ref": "#/statefulset"
|
||||
},
|
||||
"applyDefaultContainerOptionsToInitContainers": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"defaultContainerOptionsStrategy": {
|
||||
"type": "string",
|
||||
"default": "overwrite",
|
||||
"enum": ["overwrite", "merge"]
|
||||
},
|
||||
"defaultContainerOptions": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"args": {
|
||||
"$ref": "containers.json#/args"
|
||||
},
|
||||
"command": {
|
||||
"$ref": "containers.json#/command"
|
||||
},
|
||||
"env": {
|
||||
"$ref": "containers.json#/env"
|
||||
},
|
||||
"envFrom": {
|
||||
"$ref": "containers.json#/envFrom"
|
||||
},
|
||||
"image": {
|
||||
"$ref": "containers.json#/image"
|
||||
},
|
||||
"resources": {
|
||||
"$ref": "k8s-api.json#/core.v1.ResourceRequirements"
|
||||
},
|
||||
"securityContext": {
|
||||
"$ref": "k8s-api.json#/core.v1.ContainerSecurityContext"
|
||||
}
|
||||
}
|
||||
},
|
||||
"initContainers": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"loadBalancerClass": {
|
||||
"type": "string"
|
||||
},
|
||||
"externalTrafficPolicy": {
|
||||
"type": "string",
|
||||
"enum": ["Cluster", "Local"]
|
||||
|
|
|
@ -49,6 +49,9 @@ spec:
|
|||
loadBalancerSourceRanges:
|
||||
{{ toYaml $serviceObject.loadBalancerSourceRanges | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- if $serviceObject.loadBalancerClass }}
|
||||
loadBalancerClass: {{ $serviceObject.loadBalancerClass }}
|
||||
{{- end -}}
|
||||
{{- else if eq $svcType "ExternalName" }}
|
||||
type: {{ $svcType }}
|
||||
{{- if $serviceObject.externalName }}
|
||||
|
|
|
@ -3,11 +3,39 @@ Convert container values to an object
|
|||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.valuesToObject" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $controllerObject := mustDeepCopy .controllerObject -}}
|
||||
{{- $containerType := .containerType -}}
|
||||
{{- $identifier := .id -}}
|
||||
{{- $objectValues := .values -}}
|
||||
{{- $objectValues := mustDeepCopy .values -}}
|
||||
{{- $defaultContainerOptionsStrategy := dig "defaultContainerOptionsStrategy" "overwrite" $controllerObject -}}
|
||||
{{- $mergeDefaultContainerOptions := true -}}
|
||||
|
||||
{{- $_ := set $objectValues "identifier" $identifier -}}
|
||||
|
||||
{{- /* Allow disabling default options for initContainers */ -}}
|
||||
{{- if (eq "init" $containerType) -}}
|
||||
{{- $applyDefaultContainerOptionsToInitContainers := dig "applyDefaultContainerOptionsToInitContainers" true $controllerObject -}}
|
||||
{{- if (not (eq $applyDefaultContainerOptionsToInitContainers true)) -}}
|
||||
{{- $mergeDefaultContainerOptions = false -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Merge default container options if required */ -}}
|
||||
{{- if (eq true $mergeDefaultContainerOptions) -}}
|
||||
{{- if eq "overwrite" $defaultContainerOptionsStrategy -}}
|
||||
{{- range $key, $defaultValue := (dig "defaultContainerOptions" dict $controllerObject) }}
|
||||
{{- $specificValue := dig $key nil $objectValues -}}
|
||||
{{- if not (empty $specificValue) -}}
|
||||
{{- $_ := set $objectValues $key $specificValue -}}
|
||||
{{- else -}}
|
||||
{{- $_ := set $objectValues $key $defaultValue -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else if eq "merge" $defaultContainerOptionsStrategy -}}
|
||||
{{- $objectValues = merge $objectValues (dig "defaultContainerOptions" dict $controllerObject) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Process image tags */ -}}
|
||||
{{- if kindIs "map" $objectValues.image -}}
|
||||
{{- $imageTag := dig "image" "tag" "" $objectValues -}}
|
||||
|
|
|
@ -4,19 +4,17 @@ Args used by the container.
|
|||
{{- define "bjw-s.common.lib.container.field.args" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
{{- $argValues := get $containerObject "args" -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $args := list -}}
|
||||
|
||||
{{- /* See if an override is desired */ -}}
|
||||
{{- if not (empty (get $containerObject "args")) -}}
|
||||
{{- $option := get $containerObject "args" -}}
|
||||
{{- if not (empty $option) -}}
|
||||
{{- if kindIs "string" $option -}}
|
||||
{{- $args = append $args $option -}}
|
||||
{{- else -}}
|
||||
{{- $args = $option -}}
|
||||
{{- end -}}
|
||||
{{- if not (empty $argValues) -}}
|
||||
{{- if kindIs "string" $argValues -}}
|
||||
{{- $args = append $args $argValues -}}
|
||||
{{- else -}}
|
||||
{{- $args = $argValues -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
|
|
@ -4,19 +4,17 @@ Command used by the container.
|
|||
{{- define "bjw-s.common.lib.container.field.command" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
{{- $commandValues := get $containerObject "command" -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $command := list -}}
|
||||
|
||||
{{- /* See if an override is desired */ -}}
|
||||
{{- if not (empty (get $containerObject "command")) -}}
|
||||
{{- $option := get $containerObject "command" -}}
|
||||
{{- if not (empty $option) -}}
|
||||
{{- if kindIs "string" $option -}}
|
||||
{{- $command = append $command $option -}}
|
||||
{{- else -}}
|
||||
{{- $command = $option -}}
|
||||
{{- end -}}
|
||||
{{- if not (empty $commandValues) -}}
|
||||
{{- if kindIs "string" $commandValues -}}
|
||||
{{- $command = append $command $commandValues -}}
|
||||
{{- else -}}
|
||||
{{- $command = $commandValues -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
|
|
@ -5,25 +5,26 @@ Env field used by the container.
|
|||
{{- $ctx := .ctx -}}
|
||||
{{- $rootContext := $ctx.rootContext -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
{{- $envValues := get $containerObject "env" -}}
|
||||
|
||||
{{- /* Default to empty list */ -}}
|
||||
{{- $envList := list -}}
|
||||
|
||||
{{- /* See if an override is desired */ -}}
|
||||
{{- if not (empty (get $containerObject "env")) -}}
|
||||
{{- if kindIs "slice" $containerObject.env -}}
|
||||
{{- if not (empty $envValues) -}}
|
||||
{{- if kindIs "slice" $envValues -}}
|
||||
{{- /* Env is a list so we assume the order is already as desired */ -}}
|
||||
{{- range $name, $var := $containerObject.env -}}
|
||||
{{- range $name, $var := $envValues -}}
|
||||
{{- if kindIs "int" $name -}}
|
||||
{{- $name = required "environment variables as a list of maps require a name field" $var.name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $envList = $containerObject.env -}}
|
||||
{{- $envList = $envValues -}}
|
||||
{{- else -}}
|
||||
{{- /* Env is a map so we must check if ordering is desired */ -}}
|
||||
{{- $graph := dict -}}
|
||||
|
||||
{{- range $name, $var := $containerObject.env -}}
|
||||
{{- range $name, $var := $envValues -}}
|
||||
{{- if kindIs "map" $var -}}
|
||||
{{- /* Value is a map so ordering can be specified */ -}}
|
||||
{{- if empty (dig "dependsOn" nil $var) -}}
|
||||
|
@ -44,7 +45,7 @@ Env field used by the container.
|
|||
|
||||
{{- range $name := $args.out -}}
|
||||
{{- $envItem := dict "name" $name -}}
|
||||
{{- $envValue := get $containerObject.env $name -}}
|
||||
{{- $envValue := get $envValues $name -}}
|
||||
|
||||
{{- if kindIs "map" $envValue -}}
|
||||
{{- $envItem := merge $envItem (omit $envValue "dependsOn") -}}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
{{/*
|
||||
Env field used by the container.
|
||||
envFrom field used by the container.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.container.field.envFrom" -}}
|
||||
{{- $ctx := .ctx -}}
|
||||
{{- $rootContext := $ctx.rootContext -}}
|
||||
{{- $containerObject := $ctx.containerObject -}}
|
||||
{{- $envFromValues := get $containerObject "envFrom" -}}
|
||||
|
||||
{{- if not (empty (get $containerObject "envFrom")) -}}
|
||||
{{- if not (empty $envFromValues) -}}
|
||||
{{- $envFrom := list -}}
|
||||
{{- range $containerObject.envFrom -}}
|
||||
{{- range $envFromValues -}}
|
||||
{{- $item := dict -}}
|
||||
|
||||
{{- if hasKey . "configMap" -}}
|
||||
|
|
|
@ -15,7 +15,7 @@ Returns the value for containers
|
|||
|
||||
{{- range $key, $containerValues := $enabledContainers -}}
|
||||
{{- /* Create object from the container values */ -}}
|
||||
{{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $containerValues)) | fromYaml -}}
|
||||
{{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $rootContext "controllerObject" $controllerObject "containerType" "default" "id" $key "values" $containerValues)) | fromYaml -}}
|
||||
|
||||
{{- /* Perform validations on the Container before rendering */ -}}
|
||||
{{- include "bjw-s.common.lib.container.validate" (dict "rootContext" $ "controllerObject" $controllerObject "containerObject" $containerObject) -}}
|
||||
|
|
|
@ -21,7 +21,7 @@ Returns the value for initContainers
|
|||
|
||||
{{- if $containerEnabled -}}
|
||||
{{- /* Create object from the container values */ -}}
|
||||
{{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $containerValues)) | fromYaml -}}
|
||||
{{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $rootContext "controllerObject" $controllerObject "containerType" "init" "id" $key "values" $containerValues)) | fromYaml -}}
|
||||
|
||||
{{- /* Perform validations on the Container before rendering */ -}}
|
||||
{{- include "bjw-s.common.lib.container.validate" (dict "rootContext" $ "controllerObject" $controllerObject "containerObject" $containerObject) -}}
|
||||
|
|
|
@ -51,7 +51,9 @@ Returns the value for volumes
|
|||
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $rootContext) $persistenceValues.nameOverride) -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $rootContext) $identifier) -}}
|
||||
{{- if not (eq $pvcName $identifier) -}}
|
||||
{{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $rootContext) $identifier) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $volume "persistentVolumeClaim" (dict "claimName" $pvcName) -}}
|
||||
|
|
|
@ -13,6 +13,7 @@ Secondary entrypoint and primary loader for the common chart
|
|||
{{- include "bjw-s.common.render.ingresses" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.serviceMonitors" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.routes" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps.fromFiles" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.secrets" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.networkpolicies" . | nindent 0 -}}
|
||||
|
|
|
@ -24,3 +24,36 @@ Renders the configMap objects required by the chart.
|
|||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Renders configMap objects required by the chart from a folder in the repo's path.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.configMaps.fromFiles" -}}
|
||||
{{- $rootValues := .Values -}}
|
||||
|
||||
{{/* Generate a list of unique top level folders */}}
|
||||
{{ $topLevelFolders := dict}}
|
||||
{{- range $path, $_ := .Files.Glob (printf "%s/*/*" .Values.configMapsFromFolderBasePath) -}}
|
||||
{{- $_ := set $topLevelFolders (dir $path) "" -}}
|
||||
{{- end -}}
|
||||
{{- $top_level_folder_list := keys $topLevelFolders | sortAlpha -}}
|
||||
|
||||
{{/* Iterate over the top level folders */}}
|
||||
{{ range $path := $top_level_folder_list }}
|
||||
{{- $filesContentNoFormat := ($.Files.Glob (printf "%s/*" $path)) -}}
|
||||
{{- $filesContent := dict -}}
|
||||
{{- range $file_name, $content := $filesContentNoFormat -}}
|
||||
{{- $key := base $file_name -}}
|
||||
{{- if contains ".escape" $key -}}
|
||||
{{- $key := $key | replace ".escape" "" -}}
|
||||
{{- $filesContent = merge $filesContent (dict $key (($.Files.Get $file_name) | replace "{{" "{{ `{{` }}")) -}}
|
||||
{{- else -}}
|
||||
{{- $filesContent = merge $filesContent (dict $key ($.Files.Get $file_name)) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $configMapValues := dict "enabled" true "labels" dict "annotations" dict "data" $filesContent -}}
|
||||
{{- $existingConfigMaps := (get $rootValues "configMaps"| default dict) -}}
|
||||
{{- $mergedConfigMaps := deepCopy $existingConfigMaps | merge (dict (base $path) $configMapValues) -}}
|
||||
{{- $rootValues := merge $rootValues (dict "configMaps" $mergedConfigMaps) -}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.3.2/charts/library/common/values.schema.json",
|
||||
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.4.0/charts/library/common/values.schema.json",
|
||||
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -194,6 +194,36 @@ controllers: {}
|
|||
# # Controller-specific overrides for `defaultPodOptions` keys
|
||||
# pod: {}
|
||||
|
||||
# # -- Whether to apply defaultContainerOptions to initContainers
|
||||
# applyDefaultContainerOptionsToInitContainers: true
|
||||
# # -- Set the strategy for the default container options. Defaults to
|
||||
# # overwrite: If container-level options are set, use those instead of the defaults.
|
||||
# # merge: If container-level options are set, merge them with the defaults
|
||||
# # @default -- overwrite
|
||||
# defaultContainerOptionsStrategy: overwrite
|
||||
# # -- Set default options for all (init)Containers here
|
||||
# # Each of these options can be overridden on a container level
|
||||
# defaultContainerOptions:
|
||||
# image:
|
||||
# # -- Override the image repository for the containers
|
||||
# repository:
|
||||
# # -- Override the image tag for the containers
|
||||
# tag:
|
||||
# # -- Override the image pull policy for the containers
|
||||
# pullPolicy:
|
||||
# # -- Override the command(s) for the containers
|
||||
# command:
|
||||
# # -- Override the args for the containers
|
||||
# args:
|
||||
# # -- Environment variables.
|
||||
# env:
|
||||
# # -- Secrets and/or ConfigMaps that will be loaded as environment variables.
|
||||
# envFrom: {}
|
||||
# # -- Set the resource requests / limits for the container.
|
||||
# resources:
|
||||
# # -- Configure the Security Context for the container
|
||||
# securityContext: {}
|
||||
|
||||
# containers:
|
||||
# main:
|
||||
# # -- Override the container name
|
||||
|
@ -211,11 +241,11 @@ controllers: {}
|
|||
# # -- image pull policy
|
||||
# pullPolicy:
|
||||
|
||||
# # -- Override the command(s) for the default container
|
||||
# # -- Override the command(s) for the container
|
||||
# command: []
|
||||
# # -- Override the args for the default container
|
||||
# # -- Override the args for the container
|
||||
# args: []
|
||||
# # -- Override the working directory for the default container
|
||||
# # -- Override the working directory for the container
|
||||
# workingDir:
|
||||
|
||||
# # -- Environment variables. Template enabled.
|
||||
|
@ -410,6 +440,18 @@ configMaps:
|
|||
# data:
|
||||
# foo: bar
|
||||
|
||||
# -- A path in your parent's chart filesystem where you can add files to be converted into individual ConfigMaps.
|
||||
# Your files will need to be two levels deep from the base path.
|
||||
# For example, if you set this to `files/`, and you have this file tree
|
||||
# files:
|
||||
# └── configmap1
|
||||
# ├── file1
|
||||
# └── file2
|
||||
# This will generate a ConfigMap named `configmap1` with keys `file1` and `file2`, values being the respective contents of those files.
|
||||
# If your file contains `gotpl` syntax that you don't want templated by Helm, prefix the file extension with `.escape` and it will be treated as a regular string.
|
||||
# For example, `file1.escape.yaml` will be converted to `file1.yaml` in the ConfigMap with the contents of the file not templated.
|
||||
configMapsFromFolderBasePath: null
|
||||
|
||||
# -- Configure the services for the chart here.
|
||||
# Additional services can be added by adding a dictionary key similar to the 'main' service.
|
||||
# @default -- See below
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
apiVersion: v2
|
||||
description: A common powered chart template. This can be useful for small projects that don't have their own chart.
|
||||
name: app-template
|
||||
version: 3.3.2
|
||||
version: 3.4.0
|
||||
kubeVersion: ">=1.22.0-0"
|
||||
maintainers:
|
||||
- name: bjw-s
|
||||
|
@ -10,12 +10,12 @@ maintainers:
|
|||
dependencies:
|
||||
- name: common
|
||||
repository: https://bjw-s.github.io/helm-charts
|
||||
version: 3.3.2
|
||||
version: 3.4.0
|
||||
annotations:
|
||||
artifacthub.io/changes: |-
|
||||
- kind: changed
|
||||
description: |
|
||||
Updated library version to 3.3.2.
|
||||
Updated library version to 3.4.0.
|
||||
links:
|
||||
- name: Upgrade instructions from v2.x
|
||||
url: https://bjw-s.github.io/helm-charts/docs/app-template/#from-2xx-to-30x
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# app-template
|
||||
|
||||

|
||||

|
||||
|
||||
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 |
|
||||
|------------|------|---------|
|
||||
| https://bjw-s.github.io/helm-charts | common | 3.3.2 |
|
||||
| https://bjw-s.github.io/helm-charts | common | 3.4.0 |
|
||||
|
||||
## Installing the Chart
|
||||
|
||||
|
|
|
@ -726,7 +726,7 @@
|
|||
"values": {
|
||||
"description": "Values holds the values for this Helm release.",
|
||||
"x-kubernetes-preserve-unknown-fields": true,
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.3.2/charts/library/common/values.schema.json"
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.4.0/charts/library/common/values.schema.json"
|
||||
},
|
||||
"valuesFrom": {
|
||||
"description": "ValuesFrom holds references to resources containing Helm values for this HelmRelease,\nand information about how they should be merged.",
|
||||
|
|
|
@ -727,7 +727,7 @@
|
|||
"values": {
|
||||
"description": "Values holds the values for this Helm release.",
|
||||
"x-kubernetes-preserve-unknown-fields": true,
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.3.2/charts/library/common/values.schema.json"
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.4.0/charts/library/common/values.schema.json"
|
||||
},
|
||||
"valuesFrom": {
|
||||
"description": "ValuesFrom holds references to resources containing Helm values for this HelmRelease, and information about how they should be merged.",
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.3.2/charts/library/common/values.schema.json"
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.4.0/charts/library/common/values.schema.json"
|
||||
}
|
||||
|
|
83
docs/common-library/howto/default-container-options.md
Normal file
83
docs/common-library/howto/default-container-options.md
Normal file
|
@ -0,0 +1,83 @@
|
|||
---
|
||||
hide:
|
||||
- toc
|
||||
---
|
||||
|
||||
# Setting default container options
|
||||
|
||||
It is possible to configure default container options under the `controllers.*.defaultContainerOptions` key. These options will be applied to all containers within the controller.
|
||||
|
||||
## Only applying to regular containers
|
||||
|
||||
By default the `defaultContainerOptions` will be applied to both `initContainers` and regular `containers`.
|
||||
If you wish to only apply the default options to regular containers, set `controllers.*.applyDefaultContainerOptionsToInitContainers` to `false`.
|
||||
|
||||
## Default value strategies
|
||||
|
||||
### Overwrite
|
||||
|
||||
The default strategy for configuring default container options is `overwrite`. This means that if a container has an entry for a default container option it will be overwritten entirely by the container-specific configuration.
|
||||
|
||||
This behavior can be set explicitly by setting `controllers.*.defaultContainerOptionsStrategy` to `overwrite`.
|
||||
|
||||
An (abbreviated) example of the `overwrite` strategy:
|
||||
|
||||
```yaml
|
||||
controllers:
|
||||
main:
|
||||
defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 150m
|
||||
|
||||
containers:
|
||||
main:
|
||||
...
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
```
|
||||
|
||||
The expected `resources` field on the `main` container is expected to look like this:
|
||||
|
||||
```yaml
|
||||
resources:
|
||||
requests:
|
||||
cpu: 150m
|
||||
```
|
||||
|
||||
### Merge
|
||||
|
||||
An alternative strategy for configuring default container options is `merge`. This means that if a container has an entry for a default container option it will be merged with the container-specific configuration.
|
||||
|
||||
This behavior can be set explicitly by setting `defaultContainerOptionsStrategy` to `merge`.
|
||||
|
||||
An (abbreviated) example of the `merge` strategy:
|
||||
|
||||
```yaml
|
||||
controllers:
|
||||
main:
|
||||
defaultContainerOptionsStrategy: merge
|
||||
defaultContainerOptions:
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 150m
|
||||
|
||||
containers:
|
||||
main:
|
||||
...
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
```
|
||||
|
||||
The expected `resources` field on the `main` container is expected to look like this:
|
||||
|
||||
```yaml
|
||||
resources:
|
||||
requests:
|
||||
memory: 1Gi
|
||||
cpu: 150m
|
||||
```
|
3
docs/common-library/howto/index.md
Normal file
3
docs/common-library/howto/index.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# How to...
|
||||
|
||||
Here you can find information on how to accomplish specific scenario's.
|
Loading…
Add table
Add a link
Reference in a new issue