diff --git a/.ci/ct/ct.yaml b/.ci/ct/ct.yaml index d8e624ce..6c66e39c 100644 --- a/.ci/ct/ct.yaml +++ b/.ci/ct/ct.yaml @@ -12,5 +12,4 @@ chart-dirs: - charts/other chart-repos: - - bitnami=https://charts.bitnami.com/bitnami - bjw-s=https://bjw-s.github.io/helm-charts diff --git a/.ci/prettier/.prettierignore b/.ci/prettier/.prettierignore new file mode 100644 index 00000000..63574156 --- /dev/null +++ b/.ci/prettier/.prettierignore @@ -0,0 +1,4 @@ +.direnv +.private +.vscode +*.sops.* diff --git a/.ci/prettier/.prettierrc.yaml b/.ci/prettier/.prettierrc.yaml new file mode 100644 index 00000000..00c81c75 --- /dev/null +++ b/.ci/prettier/.prettierrc.yaml @@ -0,0 +1,6 @@ +--- +trailingComma: "es5" +tabWidth: 2 +semi: false +singleQuote: false +bracketSpacing: false diff --git a/.ci/repo-config.yaml b/.ci/repo-config.yaml index eb6cfdb5..195310f1 100644 --- a/.ci/repo-config.yaml +++ b/.ci/repo-config.yaml @@ -1,5 +1,10 @@ -excluded-charts-lint: [] +--- +excluded-charts-lint: + - library/common-test excluded-charts-install: - apps/k8s-ycl - library/common + +excluded-charts-release: + - library/common-test diff --git a/.github/workflows/charts-test.yaml b/.github/workflows/charts-test.yaml index 6c11fb39..9c80f8b0 100644 --- a/.github/workflows/charts-test.yaml +++ b/.github/workflows/charts-test.yaml @@ -118,7 +118,7 @@ jobs: - name: Run tests run: | - helm plugin install https://github.com/vbehar/helm3-unittest --version v1.0.16 + helm plugin install https://github.com/helm-unittest/helm-unittest.git helm dep update "charts/${{ matrix.chart }}" helm unittest -f "tests/**/*_test.yaml" "charts/${{ matrix.chart }}" diff --git a/.github/workflows/pr-validate.yaml b/.github/workflows/pr-validate.yaml index 9305a7e8..3a9d04d1 100644 --- a/.github/workflows/pr-validate.yaml +++ b/.github/workflows/pr-validate.yaml @@ -35,13 +35,6 @@ jobs: checkoutCommit: ${{ github.sha }} chartsToLint: ${{ needs.pr-metadata.outputs.chartsToLint }} isRenovatePR: ${{ needs.pr-metadata.outputs.isRenovatePR }} - overrideDeps: |- - ${{ - ( - needs.pr-metadata.outputs.commonLibraryUpdated && - '[{"name": "common", "repository": "file://../../library/common", "version": "*"}]' - ) || '[]' - }} charts-test: uses: ./.github/workflows/charts-test.yaml @@ -53,13 +46,6 @@ jobs: ${{ ( (needs.pr-metadata.outputs.commonLibraryUpdated=='true') && - '["other/app-template"]' + '["library/common-test"]' ) || needs.pr-metadata.outputs.chartsToInstall }} - overrideDeps: |- - ${{ - ( - (needs.pr-metadata.outputs.commonLibraryUpdated=='true') && - '[{"name": "common", "repository": "file://../../library/common", "version": "*"}]' - ) || '[]' - }} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..5c288705 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "prettier.configPath": ".ci/prettier/.prettierrc.yaml" +} diff --git a/charts/library/common-test/.helmignore b/charts/library/common-test/.helmignore new file mode 100644 index 00000000..ab04375e --- /dev/null +++ b/charts/library/common-test/.helmignore @@ -0,0 +1,30 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ +# OWNERS file for Kubernetes +OWNERS + +# helm-docs templates +*.gotmpl + +# helm unit tests +tests/ diff --git a/charts/library/common-test/Chart.yaml b/charts/library/common-test/Chart.yaml new file mode 100644 index 00000000..acd7bd3d --- /dev/null +++ b/charts/library/common-test/Chart.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v2 +description: A helper chart that is used to test the common library chart +name: common-test +version: 1.0.0 +kubeVersion: ">=1.22.0-0" +maintainers: + - name: bjw-s + email: me@bjw-s.dev +dependencies: + - name: common + repository: file://../common + version: ">0.0.0-0" diff --git a/charts/library/common-test/ci/advanced-values.yaml b/charts/library/common-test/ci/advanced-values.yaml new file mode 100644 index 00000000..8c5f2a8e --- /dev/null +++ b/charts/library/common-test/ci/advanced-values.yaml @@ -0,0 +1,78 @@ +controllers: + main: + containers: + main: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + pullPolicy: IfNotPresent + + env: + HTTP_PORT: 8887 + HTTPS_PORT: 9997 + + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true + + second-container: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + env: + HTTP_PORT: 8888 + HTTPS_PORT: 9998 + + third-container: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + + second-controller: + type: deployment + containers: + main: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + pullPolicy: IfNotPresent + env: + HTTP_PORT: 8889 + HTTPS_PORT: 9999 + +ingress: + main: + enabled: true + +configMaps: + config: + enabled: true + data: + test: value 1 + +persistence: + config: + enabled: true + + data: + type: configMap + name: |- + {{- (include "bjw-s.common.lib.chart.names.fullname" $) -}}-config + advancedMounts: + main: # the controller with whe "main" identifier + main: # the container with whe "main" identifier + - path: /data/config.yaml + readOnly: false + subPath: config.yaml + second-container: # the container with whe "second-container" identifier + - path: /appdata/config + readOnly: true + second-controller: # the controller with whe "second-controller" identifier + main: # the container with whe "main" identifier + - path: /data/config.yaml + readOnly: false + subPath: config.yaml diff --git a/charts/library/common-test/ci/basic-values.yaml b/charts/library/common-test/ci/basic-values.yaml new file mode 100644 index 00000000..8f50a367 --- /dev/null +++ b/charts/library/common-test/ci/basic-values.yaml @@ -0,0 +1,24 @@ +controllers: + main: + containers: + main: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + pullPolicy: IfNotPresent + + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true + +ingress: + main: + enabled: true + +persistence: + config: + enabled: true diff --git a/charts/library/common-test/ci/cronjob-values.yaml b/charts/library/common-test/ci/cronjob-values.yaml new file mode 100644 index 00000000..f9b1b019 --- /dev/null +++ b/charts/library/common-test/ci/cronjob-values.yaml @@ -0,0 +1,19 @@ +controllers: + main: + type: cronjob + containers: + main: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + pullPolicy: IfNotPresent + +service: + main: + enabled: false + +configMaps: + config: + enabled: true + data: + test: value 1 diff --git a/charts/other/app-template/ci/no-service.yaml b/charts/library/common-test/ci/no-service.yaml similarity index 50% rename from charts/other/app-template/ci/no-service.yaml rename to charts/library/common-test/ci/no-service.yaml index e463e326..497037a1 100644 --- a/charts/other/app-template/ci/no-service.yaml +++ b/charts/library/common-test/ci/no-service.yaml @@ -1,7 +1,11 @@ -image: - repository: b4bz/homer - tag: latest - pullPolicy: IfNotPresent +controllers: + main: + containers: + main: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + pullPolicy: IfNotPresent service: main: diff --git a/charts/library/common-test/ci/vaultwarden-example.yaml b/charts/library/common-test/ci/vaultwarden-example.yaml new file mode 120000 index 00000000..12bce3a0 --- /dev/null +++ b/charts/library/common-test/ci/vaultwarden-example.yaml @@ -0,0 +1 @@ +../../../../examples/helm/values.yaml \ No newline at end of file diff --git a/charts/library/common-test/templates/common.yaml b/charts/library/common-test/templates/common.yaml new file mode 100644 index 00000000..6da812bd --- /dev/null +++ b/charts/library/common-test/templates/common.yaml @@ -0,0 +1,14 @@ +--- +{{- include "bjw-s.common.loader.init" . }} + +{{- define "app-template.hardcodedValues" -}} +# Set the nameOverride based on the release name if no override has been set +{{ if not .Values.global.nameOverride }} +global: + nameOverride: "{{ .Release.Name }}" +{{ end }} +{{- end -}} +{{- $_ := mergeOverwrite .Values (include "app-template.hardcodedValues" . | fromYaml) -}} + +{{/* Render the templates */}} +{{ include "bjw-s.common.loader.generate" . }} diff --git a/charts/other/app-template/tests/configmap/metadata_test.yaml b/charts/library/common-test/tests/configmap/metadata_test.yaml similarity index 94% rename from charts/other/app-template/tests/configmap/metadata_test.yaml rename to charts/library/common-test/tests/configmap/metadata_test.yaml index f84da5cf..a24aee5f 100644 --- a/charts/other/app-template/tests/configmap/metadata_test.yaml +++ b/charts/library/common-test/tests/configmap/metadata_test.yaml @@ -23,7 +23,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: @@ -52,7 +52,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -89,5 +89,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test diff --git a/charts/other/app-template/tests/configmap/names_test.yaml b/charts/library/common-test/tests/configmap/names_test.yaml similarity index 100% rename from charts/other/app-template/tests/configmap/names_test.yaml rename to charts/library/common-test/tests/configmap/names_test.yaml diff --git a/charts/other/app-template/tests/configmap/pod_metadata_test.yaml b/charts/library/common-test/tests/configmap/pod_metadata_test.yaml similarity index 81% rename from charts/other/app-template/tests/configmap/pod_metadata_test.yaml rename to charts/library/common-test/tests/configmap/pod_metadata_test.yaml index 93ab0a36..3184a162 100644 --- a/charts/other/app-template/tests/configmap/pod_metadata_test.yaml +++ b/charts/library/common-test/tests/configmap/pod_metadata_test.yaml @@ -17,4 +17,4 @@ tests: equal: path: spec.template.metadata.annotations value: - checksum/config: afdf20f511621d5cb358c5e8b0da2d14cdbe2549fb12fa123f6a6e9baabef26e + checksum/configMaps: afdf20f511621d5cb358c5e8b0da2d14cdbe2549fb12fa123f6a6e9baabef26e diff --git a/charts/other/app-template/tests/container/args_test.yaml b/charts/library/common-test/tests/container/args_test.yaml similarity index 87% rename from charts/other/app-template/tests/container/args_test.yaml rename to charts/library/common-test/tests/container/args_test.yaml index 4a5470cd..2393fb2a 100644 --- a/charts/other/app-template/tests/container/args_test.yaml +++ b/charts/library/common-test/tests/container/args_test.yaml @@ -13,7 +13,7 @@ tests: - it: single string should pass set: - args: sleep infinity + controllers.main.containers.main.args: sleep infinity asserts: - documentIndex: 0 isKind: @@ -26,7 +26,7 @@ tests: - it: multiline string should pass set: - args: | + controllers.main.containers.main.args: | echo hello echo world asserts: @@ -43,7 +43,7 @@ tests: - it: single quoted string should pass set: - args: "sleep infinity" + controllers.main.containers.main.args: "sleep infinity" asserts: - documentIndex: 0 isKind: @@ -56,7 +56,7 @@ tests: - it: list of strings should pass set: - args: + controllers.main.containers.main.args: - sleep - infinity - "test" diff --git a/charts/other/app-template/tests/container/command_test.yaml b/charts/library/common-test/tests/container/command_test.yaml similarity index 87% rename from charts/other/app-template/tests/container/command_test.yaml rename to charts/library/common-test/tests/container/command_test.yaml index f0be880e..3e9326f1 100644 --- a/charts/other/app-template/tests/container/command_test.yaml +++ b/charts/library/common-test/tests/container/command_test.yaml @@ -13,7 +13,7 @@ tests: - it: single string should pass set: - command: /bin/sh + controllers.main.containers.main.command: /bin/sh asserts: - documentIndex: 0 isKind: @@ -26,7 +26,7 @@ tests: - it: multiline string should pass set: - command: | + controllers.main.containers.main.command: | /bin/sh -c asserts: @@ -43,7 +43,7 @@ tests: - it: single quoted string should pass set: - command: "/bin/sh" + controllers.main.containers.main.command: "/bin/sh" asserts: - documentIndex: 0 isKind: @@ -56,7 +56,7 @@ tests: - it: list of strings should pass set: - command: + controllers.main.containers.main.command: - /bin/sh - "-c" asserts: diff --git a/charts/other/app-template/tests/container/env_test.yaml b/charts/library/common-test/tests/container/env_test.yaml similarity index 91% rename from charts/other/app-template/tests/container/env_test.yaml rename to charts/library/common-test/tests/container/env_test.yaml index 244b5ba8..22a50e86 100644 --- a/charts/other/app-template/tests/container/env_test.yaml +++ b/charts/library/common-test/tests/container/env_test.yaml @@ -13,7 +13,7 @@ tests: - it: KeyValue string should pass set: - env: + controllers.main.containers.main.env: string: value_of_env asserts: - documentIndex: &DeploymentDoc 0 @@ -28,7 +28,7 @@ tests: - it: KeyValue float should pass set: - env: + controllers.main.containers.main.env: string: 4.2 asserts: - documentIndex: &DeploymentDoc 0 @@ -43,7 +43,7 @@ tests: - it: KeyValue int should pass set: - env: + controllers.main.containers.main.env: string: 1 asserts: - documentIndex: &DeploymentDoc 0 @@ -58,7 +58,7 @@ tests: - it: List should pass set: - env: + controllers.main.containers.main.env: - name: STATIC_ENV_FROM_LIST value: STATIC_ENV_VALUE_FROM_LIST asserts: @@ -74,7 +74,7 @@ tests: - it: Explicit ValueFrom in list should pass set: - env: + controllers.main.containers.main.env: - name: DYNAMIC_ENV_FROM_LIST valueFrom: fieldRef: @@ -94,7 +94,7 @@ tests: - it: Implicit ValueFrom should pass set: - env: + controllers.main.containers.main.env: DYNAMIC_ENV: fieldRef: fieldPath: spec.nodeName @@ -113,7 +113,7 @@ tests: - it: Templated value should pass set: - env: + controllers.main.containers.main.env: DYNAMIC_ENV: "{{ .Release.Name }}-admin" asserts: - documentIndex: &DeploymentDoc 0 @@ -128,7 +128,7 @@ tests: - it: Combined KeyValue with Explicit ValueFrom should pass set: - env: + controllers.main.containers.main.env: STATIC_ENV: static DYNAMIC_ENV: valueFrom: diff --git a/charts/other/app-template/tests/container/envfrom_test.yaml b/charts/library/common-test/tests/container/envfrom_test.yaml similarity index 93% rename from charts/other/app-template/tests/container/envfrom_test.yaml rename to charts/library/common-test/tests/container/envfrom_test.yaml index 34d7bd30..d010d4b9 100644 --- a/charts/other/app-template/tests/container/envfrom_test.yaml +++ b/charts/library/common-test/tests/container/envfrom_test.yaml @@ -13,7 +13,7 @@ tests: - it: explicit envFrom should pass set: - envFrom: + controllers.main.containers.main.envFrom: - secretRef: name: myCustomSecret asserts: diff --git a/charts/other/app-template/tests/container/image_test.yaml b/charts/library/common-test/tests/container/image_test.yaml similarity index 63% rename from charts/other/app-template/tests/container/image_test.yaml rename to charts/library/common-test/tests/container/image_test.yaml index b14d86f5..663bbbb9 100644 --- a/charts/other/app-template/tests/container/image_test.yaml +++ b/charts/library/common-test/tests/container/image_test.yaml @@ -4,8 +4,8 @@ templates: tests: - it: string tag should pass set: - image: - repository: b4bz/homer + controllers.main.containers.main.image: + repository: ghcr.io/mendhak/http-https-echo tag: latest asserts: - documentIndex: 0 @@ -14,12 +14,12 @@ tests: - documentIndex: 0 equal: path: spec.template.spec.containers[0].image - value: b4bz/homer:latest + value: ghcr.io/mendhak/http-https-echo:latest - it: integer tag should pass set: - image: - repository: b4bz/homer + controllers.main.containers.main.image: + repository: ghcr.io/mendhak/http-https-echo tag: 1.23 asserts: - documentIndex: 0 @@ -28,4 +28,4 @@ tests: - documentIndex: 0 equal: path: spec.template.spec.containers[0].image - value: b4bz/homer:1.23 + value: ghcr.io/mendhak/http-https-echo:1.23 diff --git a/charts/library/common-test/tests/container/name_test.yaml b/charts/library/common-test/tests/container/name_test.yaml new file mode 100644 index 00000000..788d182c --- /dev/null +++ b/charts/library/common-test/tests/container/name_test.yaml @@ -0,0 +1,53 @@ +suite: container name +templates: + - common.yaml +tests: + - it: with explicit name should pass + set: + controllers.main.containers: + main: + nameOverride: template-test + controller: main + image: + repository: ghcr.io/mendhak/http-https-echo + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].name + value: template-test + + - it: with implicit name should pass + set: + controllers.main.containers: + main: + controller: main + image: + repository: ghcr.io/mendhak/http-https-echo + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].name + value: main + + - it: with templated name should pass + set: + controllers.main.containers: + main: + nameOverride: "{{ .Release.Name }}-container" + controller: main + image: + repository: ghcr.io/mendhak/http-https-echo + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].name + value: RELEASE-NAME-container diff --git a/charts/library/common-test/tests/container/ports_test.yaml b/charts/library/common-test/tests/container/ports_test.yaml new file mode 100644 index 00000000..685a0e85 --- /dev/null +++ b/charts/library/common-test/tests/container/ports_test.yaml @@ -0,0 +1,35 @@ +suite: container ports +templates: + - common.yaml +tests: + - it: default should pass + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + isNull: + path: spec.template.spec.containers[0].ports + + - it: custom port should pass + set: + controllers: + main: + containers: + main: + ports: + - containerPort: 8080 + name: http + protocol: TCP + + asserts: + - documentIndex: 0 + isKind: + of: Deployment + - documentIndex: 0 + equal: + path: spec.template.spec.containers[0].ports[0] + value: + containerPort: 8080 + name: http + protocol: TCP diff --git a/charts/other/app-template/tests/container/probes_test.yaml b/charts/library/common-test/tests/container/probes_test.yaml similarity index 95% rename from charts/other/app-template/tests/container/probes_test.yaml rename to charts/library/common-test/tests/container/probes_test.yaml index a24f509d..ce81cd73 100644 --- a/charts/other/app-template/tests/container/probes_test.yaml +++ b/charts/library/common-test/tests/container/probes_test.yaml @@ -162,7 +162,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: liveness: enabled: true type: AUTO @@ -193,7 +193,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: liveness: enabled: true type: HTTP @@ -224,7 +224,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: liveness: enabled: true type: HTTPS @@ -255,7 +255,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: liveness: enabled: true custom: true @@ -291,7 +291,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: readiness: enabled: true custom: true @@ -327,7 +327,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: startup: enabled: true custom: true @@ -363,7 +363,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: liveness: enabled: true port: &port http @@ -391,7 +391,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: liveness: enabled: true port: &port http @@ -419,7 +419,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: readiness: enabled: true port: &port http @@ -447,7 +447,7 @@ tests: http: port: &port 80 - probes: + controllers.main.containers.main.probes: startup: enabled: true port: &port http diff --git a/charts/other/app-template/tests/container/volumemounts_test.yaml b/charts/library/common-test/tests/container/volumemounts_test.yaml similarity index 67% rename from charts/other/app-template/tests/container/volumemounts_test.yaml rename to charts/library/common-test/tests/container/volumemounts_test.yaml index 121f17d0..b3c15d25 100644 --- a/charts/other/app-template/tests/container/volumemounts_test.yaml +++ b/charts/library/common-test/tests/container/volumemounts_test.yaml @@ -27,11 +27,53 @@ tests: name: config mountPath: /config + - it: advanced mount config should pass + set: + controllers: + main: + containers: + second-container: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + + persistence: + data: + type: configMap + name: myConfigMap + advancedMounts: + main: + main: + - path: /data/config.yaml + readOnly: false + subPath: config.yaml + second-container: + - path: /appdata/config + readOnly: true + + asserts: + - documentIndex: &DeploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *DeploymentDoc + equal: + path: spec.template.spec.containers[0].volumeMounts[0] + value: + name: data + mountPath: /data/config.yaml + subPath: config.yaml + - documentIndex: *DeploymentDoc + equal: + path: spec.template.spec.containers[1].volumeMounts[0] + value: + name: data + mountPath: /appdata/config + readOnly: true + - it: emptyDir should pass set: persistence: cache: - enabled: true type: emptyDir asserts: - documentIndex: &DeploymentDoc 0 @@ -49,9 +91,10 @@ tests: persistence: config: enabled: true - mountPath: /custom accessMode: ReadWriteMany size: 1G + globalMounts: + - path: /custom asserts: - documentIndex: &DeploymentDoc 1 isKind: @@ -69,7 +112,9 @@ tests: config: enabled: true existingClaim: myClaim - subPath: "mySubPath" + globalMounts: + - path: /config + subPath: "mySubPath" asserts: - documentIndex: &DeploymentDoc 0 isKind: @@ -88,8 +133,9 @@ tests: config: enabled: true type: hostPath - mountPath: /data hostPath: /tmp + globalMounts: + - path: /data asserts: - documentIndex: &DeploymentDoc 0 isKind: @@ -108,7 +154,8 @@ tests: enabled: true type: hostPath hostPath: /dev - subPath: mySubPath + globalMounts: + - subPath: mySubPath asserts: - documentIndex: &DeploymentDoc 0 isKind: diff --git a/charts/other/app-template/tests/controller/cronjob_test.yaml b/charts/library/common-test/tests/controller/cronjob_test.yaml similarity index 79% rename from charts/other/app-template/tests/controller/cronjob_test.yaml rename to charts/library/common-test/tests/controller/cronjob_test.yaml index f9acf510..dfc616f5 100644 --- a/charts/other/app-template/tests/controller/cronjob_test.yaml +++ b/charts/library/common-test/tests/controller/cronjob_test.yaml @@ -4,8 +4,9 @@ templates: tests: - it: default cronjob configuration should pass set: - controller: - type: cronjob + controllers: + main: + type: cronjob asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -36,15 +37,17 @@ tests: - it: custom cronjob configuration should pass set: - controller: - type: cronjob - restartPolicy: OnFailure - cronjob: - schedule: &CronJobSchedule "0 3 * * *" - concurrencyPolicy: &CronJobConcurrencyPolicy "Test" - failedJobsHistory: &CronJobFailedJobsHistory 2 - successfulJobsHistory: &CronJobSuccessfulJobsHistory 3 - ttlSecondsAfterFinished: &ttlSecondsAfterFinished 3600 + controllers: + main: + type: cronjob + pod: + restartPolicy: OnFailure + cronjob: + schedule: &CronJobSchedule "0 3 * * *" + concurrencyPolicy: &CronJobConcurrencyPolicy "Test" + failedJobsHistory: &CronJobFailedJobsHistory 2 + successfulJobsHistory: &CronJobSuccessfulJobsHistory 3 + ttlSecondsAfterFinished: &ttlSecondsAfterFinished 3600 asserts: - documentIndex: &ControllerDoc 0 isKind: diff --git a/charts/other/app-template/tests/controller/metadata_cronjob_test.yaml b/charts/library/common-test/tests/controller/metadata_cronjob_test.yaml similarity index 73% rename from charts/other/app-template/tests/controller/metadata_cronjob_test.yaml rename to charts/library/common-test/tests/controller/metadata_cronjob_test.yaml index 0cc6e1b8..348586ee 100644 --- a/charts/other/app-template/tests/controller/metadata_cronjob_test.yaml +++ b/charts/library/common-test/tests/controller/metadata_cronjob_test.yaml @@ -4,7 +4,7 @@ templates: tests: - it: default metadata should pass set: - controller.type: cronjob + controllers.main.type: cronjob asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -16,19 +16,21 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: - controller: - type: cronjob - annotations: - test_annotation: test - labels: - test_label: test + controllers: + main: + type: cronjob + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -42,10 +44,11 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -55,12 +58,13 @@ tests: global_label: test annotations: global_annotation: test - controller: - type: cronjob - annotations: - test_annotation: test - labels: - test_label: test + controllers: + main: + type: cronjob + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -75,20 +79,24 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: jobTemplate metadata should pass set: - controller.type: cronjob - podAnnotations: - test_annotation: test - podLabels: - test_label: test + controllers: + main: + type: cronjob + pod: + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -102,6 +110,7 @@ tests: equal: path: spec.jobTemplate.spec.template.metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/name: RELEASE-NAME test_label: test diff --git a/charts/other/app-template/tests/controller/metadata_daemonset_test.yaml b/charts/library/common-test/tests/controller/metadata_daemonset_test.yaml similarity index 74% rename from charts/other/app-template/tests/controller/metadata_daemonset_test.yaml rename to charts/library/common-test/tests/controller/metadata_daemonset_test.yaml index f7a4c2a1..63758eae 100644 --- a/charts/other/app-template/tests/controller/metadata_daemonset_test.yaml +++ b/charts/library/common-test/tests/controller/metadata_daemonset_test.yaml @@ -4,7 +4,7 @@ templates: tests: - it: default metadata should pass set: - controller.type: daemonset + controllers.main.type: daemonset asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -16,19 +16,21 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: - controller: - type: daemonset - annotations: - test_annotation: test - labels: - test_label: test + controllers: + main: + type: daemonset + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -42,10 +44,11 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -55,12 +58,13 @@ tests: global_label: test annotations: global_annotation: test - controller: - type: daemonset - annotations: - test_annotation: test - labels: - test_label: test + controllers: + main: + type: daemonset + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -75,9 +79,10 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test diff --git a/charts/other/app-template/tests/controller/metadata_deployment_test.yaml b/charts/library/common-test/tests/controller/metadata_deployment_test.yaml similarity index 74% rename from charts/other/app-template/tests/controller/metadata_deployment_test.yaml rename to charts/library/common-test/tests/controller/metadata_deployment_test.yaml index 958d1ecb..01adab17 100644 --- a/charts/other/app-template/tests/controller/metadata_deployment_test.yaml +++ b/charts/library/common-test/tests/controller/metadata_deployment_test.yaml @@ -4,7 +4,7 @@ templates: tests: - it: default metadata should pass set: - controller.type: deployment + controllers.main.type: deployment asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -16,19 +16,21 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: - controller: - type: deployment - annotations: - test_annotation: test - labels: - test_label: test + controllers: + main: + type: deployment + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -42,10 +44,11 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -55,12 +58,13 @@ tests: global_label: test annotations: global_annotation: test - controller: - type: deployment - annotations: - test_annotation: test - labels: - test_label: test + controllers: + main: + type: deployment + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -75,9 +79,10 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test diff --git a/charts/other/app-template/tests/controller/metadata_statefulset_test.yaml b/charts/library/common-test/tests/controller/metadata_statefulset_test.yaml similarity index 74% rename from charts/other/app-template/tests/controller/metadata_statefulset_test.yaml rename to charts/library/common-test/tests/controller/metadata_statefulset_test.yaml index bbf4a475..1c3a1caa 100644 --- a/charts/other/app-template/tests/controller/metadata_statefulset_test.yaml +++ b/charts/library/common-test/tests/controller/metadata_statefulset_test.yaml @@ -4,7 +4,7 @@ templates: tests: - it: default metadata should pass set: - controller.type: statefulset + controllers.main.type: statefulset asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -16,19 +16,21 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: - controller: - type: statefulset - annotations: - test_annotation: test - labels: - test_label: test + controllers: + main: + type: statefulset + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -42,10 +44,11 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -55,12 +58,13 @@ tests: global_label: test annotations: global_annotation: test - controller: - type: statefulset - annotations: - test_annotation: test - labels: - test_label: test + controllers: + main: + type: statefulset + annotations: + test_annotation: test + labels: + test_label: test asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -75,9 +79,10 @@ tests: equal: path: metadata.labels value: + app.kubernetes.io/component: main app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test diff --git a/charts/other/app-template/tests/controller/type_test.yaml b/charts/library/common-test/tests/controller/type_test.yaml similarity index 90% rename from charts/other/app-template/tests/controller/type_test.yaml rename to charts/library/common-test/tests/controller/type_test.yaml index ec00667c..4a002b14 100644 --- a/charts/other/app-template/tests/controller/type_test.yaml +++ b/charts/library/common-test/tests/controller/type_test.yaml @@ -14,7 +14,7 @@ tests: - it: daemonset should pass set: - controller.type: daemonset + controllers.main.type: daemonset asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -26,7 +26,7 @@ tests: - it: statefulset should pass set: - controller.type: statefulset + controllers.main.type: statefulset asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -38,7 +38,7 @@ tests: - it: cronjob should pass set: - controller.type: cronjob + controllers.main.type: cronjob asserts: - documentIndex: &ControllerDoc 0 isKind: @@ -50,7 +50,7 @@ tests: - it: disabled should pass set: - controller.enabled: false + controllers.main.enabled: false asserts: - hasDocuments: count: 1 diff --git a/charts/other/app-template/tests/ingress/metadata_test.yaml b/charts/library/common-test/tests/ingress/metadata_test.yaml similarity index 94% rename from charts/other/app-template/tests/ingress/metadata_test.yaml rename to charts/library/common-test/tests/ingress/metadata_test.yaml index ae474972..7f84c294 100644 --- a/charts/other/app-template/tests/ingress/metadata_test.yaml +++ b/charts/library/common-test/tests/ingress/metadata_test.yaml @@ -19,7 +19,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: @@ -45,7 +45,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -79,5 +79,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test diff --git a/charts/other/app-template/tests/ingress/presence_test.yaml b/charts/library/common-test/tests/ingress/presence_test.yaml similarity index 100% rename from charts/other/app-template/tests/ingress/presence_test.yaml rename to charts/library/common-test/tests/ingress/presence_test.yaml diff --git a/charts/other/app-template/tests/ingress/service_reference_test.yaml b/charts/library/common-test/tests/ingress/service_reference_test.yaml similarity index 97% rename from charts/other/app-template/tests/ingress/service_reference_test.yaml rename to charts/library/common-test/tests/ingress/service_reference_test.yaml index 6992ce5a..9fa4ce39 100644 --- a/charts/other/app-template/tests/ingress/service_reference_test.yaml +++ b/charts/library/common-test/tests/ingress/service_reference_test.yaml @@ -16,7 +16,7 @@ tests: service: name: RELEASE-NAME port: - number: null + number: 8080 - it: custom service reference should pass set: diff --git a/charts/other/app-template/tests/ingress/tls_test.yaml b/charts/library/common-test/tests/ingress/tls_test.yaml similarity index 100% rename from charts/other/app-template/tests/ingress/tls_test.yaml rename to charts/library/common-test/tests/ingress/tls_test.yaml diff --git a/charts/other/app-template/tests/ingress/values_test.yaml b/charts/library/common-test/tests/ingress/values_test.yaml similarity index 94% rename from charts/other/app-template/tests/ingress/values_test.yaml rename to charts/library/common-test/tests/ingress/values_test.yaml index ed142166..ce9aad6a 100644 --- a/charts/other/app-template/tests/ingress/values_test.yaml +++ b/charts/library/common-test/tests/ingress/values_test.yaml @@ -26,6 +26,8 @@ tests: - host: chart-test.local paths: - path: /test + service: + name: main asserts: - documentIndex: &IngressDocument 2 isKind: @@ -45,6 +47,7 @@ tests: enabled: true hosts: - host: "{{ .Release.Name }}.hostname" + asserts: - documentIndex: &IngressDocument 2 isKind: @@ -62,6 +65,8 @@ tests: - host: chart-test.local paths: - path: "/{{ .Release.Name }}.path" + service: + name: main asserts: - documentIndex: &IngressDocument 2 isKind: diff --git a/charts/other/app-template/tests/misc/nameoverride_test.yaml b/charts/library/common-test/tests/misc/nameoverride_test.yaml similarity index 100% rename from charts/other/app-template/tests/misc/nameoverride_test.yaml rename to charts/library/common-test/tests/misc/nameoverride_test.yaml diff --git a/charts/other/app-template/tests/persistence/claimnames_test.yaml b/charts/library/common-test/tests/persistence/claimnames_test.yaml similarity index 86% rename from charts/other/app-template/tests/persistence/claimnames_test.yaml rename to charts/library/common-test/tests/persistence/claimnames_test.yaml index 7e361a1a..f517b958 100644 --- a/charts/other/app-template/tests/persistence/claimnames_test.yaml +++ b/charts/library/common-test/tests/persistence/claimnames_test.yaml @@ -25,6 +25,10 @@ tests: existingClaim: enabled: true existingClaim: myClaim + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 0 isKind: @@ -45,6 +49,10 @@ tests: nameOverride: "-" accessMode: ReadWriteMany size: 1G + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 1 isKind: @@ -65,6 +73,10 @@ tests: nameOverride: suffix accessMode: ReadWriteMany size: 1G + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 1 isKind: diff --git a/charts/other/app-template/tests/persistence/emptydir_test.yaml b/charts/library/common-test/tests/persistence/emptydir_test.yaml similarity index 100% rename from charts/other/app-template/tests/persistence/emptydir_test.yaml rename to charts/library/common-test/tests/persistence/emptydir_test.yaml diff --git a/charts/other/app-template/tests/persistence/hostpath_test.yaml b/charts/library/common-test/tests/persistence/hostpath_test.yaml similarity index 83% rename from charts/other/app-template/tests/persistence/hostpath_test.yaml rename to charts/library/common-test/tests/persistence/hostpath_test.yaml index 40ce62cd..883259eb 100644 --- a/charts/other/app-template/tests/persistence/hostpath_test.yaml +++ b/charts/library/common-test/tests/persistence/hostpath_test.yaml @@ -9,7 +9,10 @@ tests: enabled: true type: hostPath hostPath: "/tmp1" - mountPath: "/data" + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 0 isKind: @@ -30,7 +33,10 @@ tests: type: hostPath hostPath: "/tmp2" hostPathType: "Directory" - mountPath: "/data2" + mounts: + - controllers: + - main + mountPath: "/data2" asserts: - documentIndex: 0 isKind: diff --git a/charts/other/app-template/tests/persistence/types_test.yaml b/charts/library/common-test/tests/persistence/types_test.yaml similarity index 78% rename from charts/other/app-template/tests/persistence/types_test.yaml rename to charts/library/common-test/tests/persistence/types_test.yaml index 0a330c0b..e650aab3 100644 --- a/charts/other/app-template/tests/persistence/types_test.yaml +++ b/charts/library/common-test/tests/persistence/types_test.yaml @@ -14,6 +14,10 @@ tests: - path: "labels" fieldRef: fieldPath: metadata.labels + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 0 isKind: @@ -25,9 +29,9 @@ tests: name: custom-mount downwardAPI: items: - - fieldRef: - fieldPath: metadata.labels - path: labels + - fieldRef: + fieldPath: metadata.labels + path: labels - it: configmap persistence type should pass set: @@ -36,6 +40,10 @@ tests: enabled: true type: configMap name: mySettings + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 0 isKind: @@ -54,7 +62,11 @@ tests: configmap: enabled: true type: configMap - name: "{{ include \"bjw-s.common.lib.chart.names.fullname\" $ }}-config" + name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-config' + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 0 isKind: @@ -74,6 +86,10 @@ tests: enabled: true type: secret name: mySettings + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 0 isKind: @@ -93,6 +109,10 @@ tests: enabled: true type: secret name: "{{ .Release.Name }}-config" + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 0 isKind: @@ -113,6 +133,10 @@ tests: type: nfs server: 10.10.0.8 path: /tank/nas/library + mounts: + - controllers: + - main + mountPath: "/data" asserts: - documentIndex: 0 isKind: diff --git a/charts/other/app-template/tests/persistence/volumeclaimtemplates_test.yaml b/charts/library/common-test/tests/persistence/volumeclaimtemplates_test.yaml similarity index 67% rename from charts/other/app-template/tests/persistence/volumeclaimtemplates_test.yaml rename to charts/library/common-test/tests/persistence/volumeclaimtemplates_test.yaml index fd26bc72..ce8e2765 100644 --- a/charts/other/app-template/tests/persistence/volumeclaimtemplates_test.yaml +++ b/charts/library/common-test/tests/persistence/volumeclaimtemplates_test.yaml @@ -4,17 +4,18 @@ templates: tests: - it: volumeClaimTemplates should pass set: - controller: + controllers.main: type: statefulset - volumeClaimTemplates: - - name: "storage" - accessMode: "ReadWriteOnce" - size: "10Gi" - storageClass: "storage" - labels: - test: "label" - annotations: - test: "annotation" + statefulset: + volumeClaimTemplates: + - name: "storage" + accessMode: "ReadWriteOnce" + size: "10Gi" + storageClass: "storage" + labels: + test: "label" + annotations: + test: "annotation" asserts: - documentIndex: 0 isKind: diff --git a/charts/other/app-template/tests/pod/hostIPC_test.yaml b/charts/library/common-test/tests/pod/hostIPC_test.yaml similarity index 79% rename from charts/other/app-template/tests/pod/hostIPC_test.yaml rename to charts/library/common-test/tests/pod/hostIPC_test.yaml index 3256dc9e..00b2a20b 100644 --- a/charts/other/app-template/tests/pod/hostIPC_test.yaml +++ b/charts/library/common-test/tests/pod/hostIPC_test.yaml @@ -8,23 +8,27 @@ tests: isKind: of: Deployment - documentIndex: 0 - isNull: + equal: path: spec.template.spec.hostIPC + value: false - it: hostIPC disabled should pass set: - hostIPC: false + defaultPodOptions: + hostIPC: false asserts: - documentIndex: 0 isKind: of: Deployment - documentIndex: 0 - isNull: + equal: path: spec.template.spec.hostIPC + value: false - it: hostIPC enabled should pass set: - hostIPC: true + defaultPodOptions: + hostIPC: true asserts: - documentIndex: 0 isKind: diff --git a/charts/other/app-template/tests/pod/hostPID_test.yaml b/charts/library/common-test/tests/pod/hostPID_test.yaml similarity index 79% rename from charts/other/app-template/tests/pod/hostPID_test.yaml rename to charts/library/common-test/tests/pod/hostPID_test.yaml index d902f217..2dde4aae 100644 --- a/charts/other/app-template/tests/pod/hostPID_test.yaml +++ b/charts/library/common-test/tests/pod/hostPID_test.yaml @@ -8,23 +8,27 @@ tests: isKind: of: Deployment - documentIndex: 0 - isNull: + equal: path: spec.template.spec.hostPID + value: false - it: hostPID disabled should pass set: - hostPID: false + defaultPodOptions: + hostPID: false asserts: - documentIndex: 0 isKind: of: Deployment - documentIndex: 0 - isNull: + equal: path: spec.template.spec.hostPID + value: false - it: hostPID enabled should pass set: - hostPID: true + defaultPodOptions: + hostPID: true asserts: - documentIndex: 0 isKind: diff --git a/charts/other/app-template/tests/pod/initcontainers_test.yaml b/charts/library/common-test/tests/pod/initcontainers_test.yaml similarity index 52% rename from charts/other/app-template/tests/pod/initcontainers_test.yaml rename to charts/library/common-test/tests/pod/initcontainers_test.yaml index 45d69ff4..fd28b1c0 100644 --- a/charts/other/app-template/tests/pod/initcontainers_test.yaml +++ b/charts/library/common-test/tests/pod/initcontainers_test.yaml @@ -2,52 +2,12 @@ suite: pod initContainers templates: - common.yaml tests: - - it: with explicit name should pass - set: - initContainers: - init1: - name: template-test - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.initContainers[0].name - value: template-test - - - it: with implicit name should pass - set: - initContainers: - init1: - image: template-test - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.initContainers[0].name - value: init1 - - - it: with templated name should pass - set: - initContainers: - init1: - name: "{{ .Release.Name }}-container" - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.initContainers[0].name - value: RELEASE-NAME-container - - it: with custom env vars dict should pass set: - initContainers: + controllers.main.initContainers: init1: + image: + repository: ghcr.io/mendhak/http-https-echo env: int: 1 float: 1.5 diff --git a/charts/other/app-template/tests/pod/network_test.yaml b/charts/library/common-test/tests/pod/network_test.yaml similarity index 83% rename from charts/other/app-template/tests/pod/network_test.yaml rename to charts/library/common-test/tests/pod/network_test.yaml index a8bcd4f1..b309f912 100644 --- a/charts/other/app-template/tests/pod/network_test.yaml +++ b/charts/library/common-test/tests/pod/network_test.yaml @@ -1,4 +1,4 @@ -suite: pod replicas +suite: pod network templates: - common.yaml tests: @@ -8,8 +8,9 @@ tests: isKind: of: Deployment - documentIndex: 0 - isNull: + equal: path: spec.template.spec.hostNetwork + value: false - documentIndex: 0 equal: path: spec.template.spec.dnsPolicy @@ -17,14 +18,16 @@ tests: - it: hostNetwork disabled should pass set: - hostNetwork: false + defaultPodOptions: + hostNetwork: false asserts: - documentIndex: 0 isKind: of: Deployment - documentIndex: 0 - isNull: + equal: path: spec.template.spec.hostNetwork + value: false - documentIndex: 0 equal: path: spec.template.spec.dnsPolicy @@ -32,7 +35,8 @@ tests: - it: hostNetwork enabled should pass set: - hostNetwork: true + defaultPodOptions: + hostNetwork: true asserts: - documentIndex: 0 isKind: @@ -48,7 +52,8 @@ tests: - it: custom dnsPolicy should pass set: - dnsPolicy: None + defaultPodOptions: + dnsPolicy: None asserts: - documentIndex: 0 isKind: diff --git a/charts/other/app-template/tests/pod/replicas_test.yaml b/charts/library/common-test/tests/pod/replicas_test.yaml similarity index 92% rename from charts/other/app-template/tests/pod/replicas_test.yaml rename to charts/library/common-test/tests/pod/replicas_test.yaml index 7e4a3793..c800b7b2 100644 --- a/charts/other/app-template/tests/pod/replicas_test.yaml +++ b/charts/library/common-test/tests/pod/replicas_test.yaml @@ -14,7 +14,7 @@ tests: - it: custom replicas should pass set: - controller.replicas: 3 + controllers.main.replicas: 3 asserts: - documentIndex: 0 isKind: diff --git a/charts/other/app-template/tests/pod/sidecars_test.yaml b/charts/library/common-test/tests/pod/sidecars_test.yaml similarity index 62% rename from charts/other/app-template/tests/pod/sidecars_test.yaml rename to charts/library/common-test/tests/pod/sidecars_test.yaml index d831c488..5233f8c6 100644 --- a/charts/other/app-template/tests/pod/sidecars_test.yaml +++ b/charts/library/common-test/tests/pod/sidecars_test.yaml @@ -4,52 +4,64 @@ templates: tests: - it: with explicit name should pass set: - sidecars: + controllers.main.containers: additional1: - name: template-test + nameOverride: template-test + image: + repository: test + tag: test asserts: - documentIndex: 0 isKind: of: Deployment - documentIndex: 0 equal: - path: spec.template.spec.containers[1].name + path: spec.template.spec.containers[0].name value: template-test - it: with implicit name should pass set: - sidecars: + controllers.main.containers: additional1: - image: template-test + image: + repository: test + tag: test asserts: - documentIndex: 0 isKind: of: Deployment - documentIndex: 0 equal: - path: spec.template.spec.containers[1].name + path: spec.template.spec.containers[0].name value: additional1 - it: with templated name should pass set: - sidecars: + controllers.main.containers: additional1: - name: "{{ .Release.Name }}-container" + nameOverride: "{{ .Release.Name }}-container" + image: + repository: test + tag: test asserts: - documentIndex: 0 isKind: of: Deployment - documentIndex: 0 equal: - path: spec.template.spec.containers[1].name + path: spec.template.spec.containers[0].name value: RELEASE-NAME-container - it: with custom env vars dict should pass set: - env: - main_env: value - sidecars: + controllers.main.containers: + main: + env: + main_env: value additional1: + image: + repository: test + tag: test env: int: 1 float: 1.5 @@ -61,52 +73,31 @@ tests: of: Deployment - documentIndex: *DeploymentDocument equal: - path: spec.template.spec.containers[0].env[0] + path: spec.template.spec.containers[1].env[0] value: name: main_env value: "value" - documentIndex: *DeploymentDocument equal: - path: spec.template.spec.containers[1].env[0] + path: spec.template.spec.containers[0].env[0] value: name: float value: "1.5" - documentIndex: *DeploymentDocument equal: - path: spec.template.spec.containers[1].env[1] + path: spec.template.spec.containers[0].env[1] value: name: int value: "1" - documentIndex: *DeploymentDocument equal: - path: spec.template.spec.containers[1].env[2] + path: spec.template.spec.containers[0].env[2] value: name: string value: value_of_env - documentIndex: *DeploymentDocument equal: - path: spec.template.spec.containers[1].env[3] + path: spec.template.spec.containers[0].env[3] value: name: template value: RELEASE-NAME-admin - - - it: with legacy additionalContainers should pass - set: - sidecars: - additional1: - name: sidecar - additionalContainers: - additional2: - name: legacy-sidecar - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.containers[1].name - value: sidecar - - documentIndex: 0 - equal: - path: spec.template.spec.containers[2].name - value: legacy-sidecar diff --git a/charts/other/app-template/tests/pvc/metadata_test.yaml b/charts/library/common-test/tests/pvc/metadata_test.yaml similarity index 94% rename from charts/other/app-template/tests/pvc/metadata_test.yaml rename to charts/library/common-test/tests/pvc/metadata_test.yaml index 836e9dd8..7047d250 100644 --- a/charts/other/app-template/tests/pvc/metadata_test.yaml +++ b/charts/library/common-test/tests/pvc/metadata_test.yaml @@ -19,7 +19,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: retain enabled should pass set: @@ -42,7 +42,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: @@ -68,7 +68,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -102,5 +102,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test diff --git a/charts/other/app-template/tests/pvc/names_test.yaml b/charts/library/common-test/tests/pvc/names_test.yaml similarity index 100% rename from charts/other/app-template/tests/pvc/names_test.yaml rename to charts/library/common-test/tests/pvc/names_test.yaml diff --git a/charts/other/app-template/tests/pvc/storageclass_test.yaml b/charts/library/common-test/tests/pvc/storageclass_test.yaml similarity index 100% rename from charts/other/app-template/tests/pvc/storageclass_test.yaml rename to charts/library/common-test/tests/pvc/storageclass_test.yaml diff --git a/charts/other/app-template/tests/route/metadata_test.yaml b/charts/library/common-test/tests/route/metadata_test.yaml similarity index 94% rename from charts/other/app-template/tests/route/metadata_test.yaml rename to charts/library/common-test/tests/route/metadata_test.yaml index 5b85282b..8e583e83 100644 --- a/charts/other/app-template/tests/route/metadata_test.yaml +++ b/charts/library/common-test/tests/route/metadata_test.yaml @@ -23,7 +23,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: @@ -52,7 +52,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -89,5 +89,5 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test diff --git a/charts/other/app-template/tests/route/presence_test.yaml b/charts/library/common-test/tests/route/presence_test.yaml similarity index 100% rename from charts/other/app-template/tests/route/presence_test.yaml rename to charts/library/common-test/tests/route/presence_test.yaml diff --git a/charts/other/app-template/tests/route/service_reference_test.yaml b/charts/library/common-test/tests/route/service_reference_test.yaml similarity index 86% rename from charts/other/app-template/tests/route/service_reference_test.yaml rename to charts/library/common-test/tests/route/service_reference_test.yaml index a08be3b9..37cf89b1 100644 --- a/charts/other/app-template/tests/route/service_reference_test.yaml +++ b/charts/library/common-test/tests/route/service_reference_test.yaml @@ -21,7 +21,7 @@ tests: kind: Service name: RELEASE-NAME namespace: NAMESPACE - port: null + port: 8080 weight: 1 - it: custom service reference should pass @@ -33,11 +33,11 @@ tests: namespace: parentNamespace rules: - backendRefs: - - group: test - name: pathService - port: 1234 - namespace: serviceNamespace - weight: 123 + - group: test + name: pathService + port: 1234 + namespace: serviceNamespace + weight: 123 asserts: - documentIndex: &HTTPRouteDocument 2 isKind: diff --git a/charts/other/app-template/tests/route/values_test.yaml b/charts/library/common-test/tests/route/values_test.yaml similarity index 100% rename from charts/other/app-template/tests/route/values_test.yaml rename to charts/library/common-test/tests/route/values_test.yaml diff --git a/charts/other/app-template/tests/secret/metadata_test.yaml b/charts/library/common-test/tests/secret/metadata_test.yaml similarity index 95% rename from charts/other/app-template/tests/secret/metadata_test.yaml rename to charts/library/common-test/tests/secret/metadata_test.yaml index 27ab4f5a..1d9d9d19 100644 --- a/charts/other/app-template/tests/secret/metadata_test.yaml +++ b/charts/library/common-test/tests/secret/metadata_test.yaml @@ -23,7 +23,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: @@ -52,7 +52,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -89,7 +89,7 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom secret type should pass diff --git a/charts/other/app-template/tests/secret/names_test.yaml b/charts/library/common-test/tests/secret/names_test.yaml similarity index 100% rename from charts/other/app-template/tests/secret/names_test.yaml rename to charts/library/common-test/tests/secret/names_test.yaml diff --git a/charts/other/app-template/tests/secret/pod_metadata_test.yaml b/charts/library/common-test/tests/secret/pod_metadata_test.yaml similarity index 84% rename from charts/other/app-template/tests/secret/pod_metadata_test.yaml rename to charts/library/common-test/tests/secret/pod_metadata_test.yaml index d69c81b7..3bba66cc 100644 --- a/charts/other/app-template/tests/secret/pod_metadata_test.yaml +++ b/charts/library/common-test/tests/secret/pod_metadata_test.yaml @@ -22,4 +22,4 @@ tests: equal: path: spec.template.metadata.annotations value: - checksum/secrets: cd4e5076088172611ca1c43c659a275232d9eeb887acc20575ac141038b9aacb + checksum/secrets: 4107837201f46be5279f7accdf3942edabd38f0eb534a61c91d2d7cba7ffc557 diff --git a/charts/other/app-template/tests/service/metadata_test.yaml b/charts/library/common-test/tests/service/metadata_test.yaml similarity index 94% rename from charts/other/app-template/tests/service/metadata_test.yaml rename to charts/library/common-test/tests/service/metadata_test.yaml index 00476b56..acb5dd97 100644 --- a/charts/other/app-template/tests/service/metadata_test.yaml +++ b/charts/library/common-test/tests/service/metadata_test.yaml @@ -18,7 +18,7 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass set: @@ -45,7 +45,7 @@ tests: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test - it: custom metadata with global metadata should pass @@ -80,5 +80,5 @@ tests: app.kubernetes.io/name: RELEASE-NAME app.kubernetes.io/service: RELEASE-NAME global_label: test - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test_label: test diff --git a/charts/other/app-template/tests/service/names_test.yaml b/charts/library/common-test/tests/service/names_test.yaml similarity index 100% rename from charts/other/app-template/tests/service/names_test.yaml rename to charts/library/common-test/tests/service/names_test.yaml diff --git a/charts/other/app-template/tests/service/port_protocols_test.yaml b/charts/library/common-test/tests/service/port_protocols_test.yaml similarity index 89% rename from charts/other/app-template/tests/service/port_protocols_test.yaml rename to charts/library/common-test/tests/service/port_protocols_test.yaml index 6db69bea..7d43cb3f 100644 --- a/charts/other/app-template/tests/service/port_protocols_test.yaml +++ b/charts/library/common-test/tests/service/port_protocols_test.yaml @@ -64,8 +64,3 @@ tests: equal: path: spec.ports[0].protocol value: TCP - - documentIndex: *ServiceDocument - equal: - path: metadata.annotations - value: - traefik.ingress.kubernetes.io/service.serversscheme: https diff --git a/charts/other/app-template/tests/service/port_names_test.yaml b/charts/library/common-test/tests/service/ports_test.yaml similarity index 90% rename from charts/other/app-template/tests/service/port_names_test.yaml rename to charts/library/common-test/tests/service/ports_test.yaml index fff36fe3..4d52d16a 100644 --- a/charts/other/app-template/tests/service/port_names_test.yaml +++ b/charts/library/common-test/tests/service/ports_test.yaml @@ -1,4 +1,4 @@ -suite: service port names +suite: service ports templates: - common.yaml tests: @@ -14,9 +14,9 @@ tests: path: spec.ports[0] value: name: http - port: null + port: 8080 protocol: TCP - targetPort: http + targetPort: 8080 - it: custom name should pass set: @@ -39,7 +39,7 @@ tests: name: server port: 8080 protocol: TCP - targetPort: server + targetPort: 8080 - it: custom target port should pass set: @@ -58,6 +58,6 @@ tests: path: spec.ports[0] value: name: http - port: null + port: 8080 protocol: TCP targetPort: 80 diff --git a/charts/other/app-template/tests/service/values_test.yaml b/charts/library/common-test/tests/service/values_test.yaml similarity index 57% rename from charts/other/app-template/tests/service/values_test.yaml rename to charts/library/common-test/tests/service/values_test.yaml index 6fff202b..2ac8f0ba 100644 --- a/charts/other/app-template/tests/service/values_test.yaml +++ b/charts/library/common-test/tests/service/values_test.yaml @@ -1,3 +1,5 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json suite: service values templates: - common.yaml @@ -7,6 +9,7 @@ tests: service: second: type: ClusterIP + controller: main ports: first: port: 80 @@ -19,6 +22,9 @@ tests: - documentIndex: &SecondServiceDocument 2 isKind: of: Service + - documentIndex: *FirstServiceDocument + notExists: + path: spec.allocateLoadBalancerNodePorts - it: services can be disabled set: @@ -61,3 +67,33 @@ tests: equal: path: spec.externalTrafficPolicy value: Local + + - it: allocateLoadBalancerNodePorts can be set to true + set: + service: + main: + type: LoadBalancer + allocateLoadBalancerNodePorts: true + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.allocateLoadBalancerNodePorts + value: true + + - it: allocateLoadBalancerNodePorts can be set to false + set: + service: + main: + type: LoadBalancer + allocateLoadBalancerNodePorts: false + asserts: + - documentIndex: &ServiceDocument 1 + isKind: + of: Service + - documentIndex: *ServiceDocument + equal: + path: spec.allocateLoadBalancerNodePorts + value: false diff --git a/charts/other/app-template/tests/serviceAccount/serviceaccount_test.yaml b/charts/library/common-test/tests/serviceAccount/serviceaccount_test.yaml similarity index 100% rename from charts/other/app-template/tests/serviceAccount/serviceaccount_test.yaml rename to charts/library/common-test/tests/serviceAccount/serviceaccount_test.yaml diff --git a/charts/other/app-template/tests/serviceMonitor/servicemonitor_test.yaml b/charts/library/common-test/tests/serviceMonitor/servicemonitor_test.yaml similarity index 98% rename from charts/other/app-template/tests/serviceMonitor/servicemonitor_test.yaml rename to charts/library/common-test/tests/serviceMonitor/servicemonitor_test.yaml index ff5fb938..ef009d9c 100644 --- a/charts/other/app-template/tests/serviceMonitor/servicemonitor_test.yaml +++ b/charts/library/common-test/tests/serviceMonitor/servicemonitor_test.yaml @@ -74,7 +74,7 @@ tests: app.kubernetes.io/instance: RELEASE-NAME app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME - helm.sh/chart: app-template-1.5.1 + helm.sh/chart: common-test-1.0.0 test.label: testvalue - it: a serviceMonitor is created with nameOverride diff --git a/charts/library/common-test/values.yaml b/charts/library/common-test/values.yaml new file mode 100644 index 00000000..6c7996b6 --- /dev/null +++ b/charts/library/common-test/values.yaml @@ -0,0 +1,15 @@ +--- +controllers: + main: + containers: + main: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 29 + pullPolicy: IfNotPresent + +service: + main: + ports: + http: + port: 8080 diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index b530259f..5bef7dc5 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v2 name: common description: Function library for Helm charts type: library -version: 1.5.1 +version: 2.0.0-beta.1 kubeVersion: ">=1.22.0-0" keywords: - common @@ -13,12 +13,7 @@ maintainers: - name: bjw-s email: me@bjw-s.dev annotations: + # TODO: Update this before releasing artifacthub.io/changes: |- - - kind: fixed - description: Ingress secret name template is evaluated before deciding whether to omit it - kind: changed - description: Updated code-server image tag to v4.13.0 - - kind: changed - description: Updated netshoot image tag to v0.11 - - kind: changed - description: Updated gluetun image tag to v3.34.3 + description: Many things :P diff --git a/charts/library/common/README.md b/charts/library/common/README.md index 5acf288c..f4620860 100644 --- a/charts/library/common/README.md +++ b/charts/library/common/README.md @@ -1,6 +1,6 @@ # common -![Version: 1.5.0](https://img.shields.io/badge/Version-1.5.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) +![Version: 2.0.0](https://img.shields.io/badge/Version-2.0.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) Function library for Helm charts @@ -29,7 +29,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g. # Chart.yaml dependencies: - name: common - version: 1.5.0 + version: 2.0.0 repository: https://bjw-s.github.io/helm-charts/ ``` @@ -49,147 +49,111 @@ N/A | Key | Type | Default | Description | |-----|------|---------|-------------| -| addons | object | See below | The common chart supports several add-ons. These can be configured under this key. | -| addons.codeserver | object | See values.yaml | The common library supports adding a code-server add-on to access files. It can be configured under this key. | -| addons.codeserver.args | list | `["--auth","none"]` | Set codeserver command line arguments. Consider setting --user-data-dir to a persistent location to preserve code-server setting changes | -| addons.codeserver.enabled | bool | `false` | Enable running a code-server container in the pod | -| addons.codeserver.env | object | `{}` | Set any environment variables for code-server here | -| addons.codeserver.git | object | See below | Optionally allow access a Git repository by passing in a private SSH key | -| addons.codeserver.git.deployKey | string | `""` | Raw SSH private key | -| addons.codeserver.git.deployKeyBase64 | string | `""` | Base64-encoded SSH private key. When both variables are set, the raw SSH key takes precedence. | -| addons.codeserver.git.deployKeySecret | string | `""` | Existing secret containing SSH private key The chart expects it to be present under the `id_rsa` key. | -| addons.codeserver.image.pullPolicy | string | `"IfNotPresent"` | Specify the code-server image pull policy | -| addons.codeserver.image.repository | string | `"ghcr.io/coder/code-server"` | Specify the code-server image | -| addons.codeserver.image.tag | string | `"4.12.0"` | Specify the code-server image tag | -| addons.codeserver.ingress.enabled | bool | `false` | Enable an ingress for the code-server add-on. | -| addons.codeserver.ingress.ingressClassName | string | `nil` | Set the ingressClass that is used for this ingress. | -| addons.codeserver.service.enabled | bool | `true` | Enable a service for the code-server add-on. | -| addons.codeserver.volumeMounts | list | `[]` | Specify a list of volumes that get mounted in the code-server container. At least 1 volumeMount is required! | -| addons.codeserver.workingDir | string | `""` | Specify the working dir that will be opened when code-server starts If not given, the app will default to the mountpah of the first specified volumeMount | -| addons.netshoot | object | See values.yaml | The common library supports adding a netshoot add-on to troubleshoot network issues within a Pod. It can be configured under this key. | -| addons.netshoot.enabled | bool | `false` | Enable running a netshoot container in the pod | -| addons.netshoot.env | object | `{}` | Set any environment variables for netshoot here | -| addons.netshoot.image.pullPolicy | string | `"IfNotPresent"` | Specify the netshoot image pull policy | -| addons.netshoot.image.repository | string | `"ghcr.io/nicolaka/netshoot"` | Specify the netshoot image | -| addons.netshoot.image.tag | string | `"v0.10"` | Specify the netshoot image tag | -| addons.vpn | object | See values.yaml | The common chart supports adding a VPN add-on. It can be configured under this key. | -| addons.vpn.args | list | `[]` | Override the args for the vpn sidecar container | -| addons.vpn.configFile | string | `nil` | Provide a customized vpn configuration file to be used by the VPN. | -| addons.vpn.configFileSecret | string | `nil` | Reference an existing secret that contains the VPN configuration file The chart expects it to be present under the `vpnConfigfile` key. | -| addons.vpn.enabled | bool | `false` | Enable running a VPN in the pod to route traffic through a VPN | -| addons.vpn.env | object | `{}` | All variables specified here will be added to the vpn sidecar container See the documentation of the VPN image for all config values | -| addons.vpn.gluetun | object | See below | Make sure to read the [documentation](https://github.com/qdm12/gluetun/wiki) to see how to configure this addon! | -| addons.vpn.gluetun.image.pullPolicy | string | `"IfNotPresent"` | Specify the Gluetun image pull policy | -| addons.vpn.gluetun.image.repository | string | `"docker.io/qmcgaw/gluetun"` | Specify the Gluetun image | -| addons.vpn.gluetun.image.tag | string | `"v3.33.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.networkPolicy.annotations | object | `{}` | Provide additional annotations which may be required. | -| addons.vpn.networkPolicy.egress | string | `nil` | The egress configuration for your network policy, All outbound traffic from the pod will be blocked unless specified here. [[ref]](https://kubernetes.io/docs/concepts/services-networking/network-policies/) [[recipes]](https://github.com/ahmetb/kubernetes-network-policy-recipes) | -| addons.vpn.networkPolicy.enabled | bool | `false` | If set to true, will deploy a network policy that blocks all outbound traffic except traffic specified as allowed | -| addons.vpn.networkPolicy.labels | object | `{}` | Provide additional labels which may be required. | -| addons.vpn.networkPolicy.podSelectorLabels | object | `{}` | Provide additional podSelector labels which may be required. | -| addons.vpn.scripts | object | See values.yaml | Provide custom up/down scripts that can be used by the vpn configuration. | -| addons.vpn.securityContext | object | See values.yaml | Set the VPN container securityContext | -| addons.vpn.type | string | `"gluetun"` | Specify the VPN type. Valid options are `gluetun`. | -| affinity | object | `{}` | Defines affinity constraint rules. [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) | -| args | list | `[]` | Override the args for the default container | -| automountServiceAccountToken | bool | `true` | Specifies whether a service account token should be automatically mounted. | -| command | list | `[]` | Override the command(s) for the default container | | 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. | | configMaps.config.annotations | object | `{}` | Annotations to add to the configMap | | configMaps.config.data | object | `{}` | configMap data content. Helm template enabled. | | configMaps.config.enabled | bool | `false` | Enables or disables the configMap | | configMaps.config.labels | object | `{}` | Labels to add to the configMap | -| controller.annotations | object | `{}` | Set annotations on the deployment/statefulset/daemonset/cronjob | -| controller.cronjob | object | See below | CronJob configuration. Required only when using `controller.type: cronjob`. | -| controller.cronjob.backoffLimit | int | `6` | Limits the number of times a failed job will be retried | -| controller.cronjob.concurrencyPolicy | string | `"Forbid"` | Specifies how to treat concurrent executions of a job that is created by this cron job valid values are Allow, Forbid or Replace | -| controller.cronjob.failedJobsHistory | int | `1` | The number of failed Jobs to keep | -| controller.cronjob.schedule | string | `"*/20 * * * *"` | Sets the CronJob time when to execute your jobs | -| controller.cronjob.startingDeadlineSeconds | int | `30` | The deadline in seconds for starting the job if it misses its scheduled time for any reason | -| controller.cronjob.successfulJobsHistory | int | `1` | The number of succesful Jobs to keep | -| controller.cronjob.ttlSecondsAfterFinished | string | `nil` | If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. | -| controller.enabled | bool | `true` | enable the controller. | -| controller.labels | object | `{}` | Set labels on the deployment/statefulset/daemonset/cronjob | -| controller.podManagementPolicy | string | `nil` | Set statefulset podManagementPolicy, valid values are Parallel and OrderedReady (default). | -| controller.replicas | int | `1` | Number of desired pods. When using a HorizontalPodAutoscaler, set this to `null`. | -| controller.restartPolicy | string | `Always`. When `controller.type` is `cronjob` it defaults to `Never`. | Set Container restart policy. | -| controller.revisionHistoryLimit | int | `3` | ReplicaSet revision history limit | -| controller.rollingUpdate.partition | string | `nil` | Set statefulset RollingUpdate partition | -| controller.rollingUpdate.surge | string | `nil` | Set deployment RollingUpdate max surge | -| controller.rollingUpdate.unavailable | string | `nil` | Set deployment RollingUpdate max unavailable | -| controller.strategy | string | `nil` | Set the controller upgrade strategy For Deployments, valid values are Recreate (default) and RollingUpdate. For StatefulSets, valid values are OnDelete and RollingUpdate (default). DaemonSets/CronJobs ignore this. | -| controller.type | string | `"deployment"` | Set the controller type. Valid options are deployment, daemonset, statefulset or cronjob | -| dnsConfig | object | `{}` | Configuring the ndots option may resolve nslookup issues on some Kubernetes setups. | -| dnsPolicy | string | `nil` | Defaults to "ClusterFirst" if hostNetwork is false and "ClusterFirstWithHostNet" if hostNetwork is true. | -| enableServiceLinks | bool | `true` | Enable/disable the generation of environment variables for services. [[ref]](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service) | -| env | string | `nil` | Main environment variables. Template enabled. Syntax options: A) TZ: UTC B) PASSWD: '{{ .Release.Name }}' C) PASSWD: configMapKeyRef: name: config-map-name key: key-name D) PASSWD: valueFrom: secretKeyRef: name: secret-name key: key-name ... E) - name: TZ value: UTC F) - name: TZ value: '{{ .Release.Name }}' | -| envFrom | list | `[]` | Secrets and/or ConfigMaps that will be loaded as environment variables. [[ref]](https://unofficial-kubernetes.readthedocs.io/en/latest/tasks/configure-pod-container/configmap/#use-case-consume-configmap-in-environment-variables) | +| controllers.main.annotations | object | `{}` | Set annotations on the deployment/statefulset/daemonset/cronjob | +| controllers.main.containers.main.args | list | `[]` | Override the args for the default container | +| controllers.main.containers.main.command | list | `[]` | Override the command(s) for the default container | +| controllers.main.containers.main.env | string | `nil` | Environment variables. Template enabled. Syntax options: A) TZ: UTC B) PASSWD: '{{ .Release.Name }}' C) PASSWD: configMapKeyRef: name: config-map-name key: key-name D) PASSWD: valueFrom: secretKeyRef: name: secret-name key: key-name ... E) - name: TZ value: UTC F) - name: TZ value: '{{ .Release.Name }}' | +| controllers.main.containers.main.envFrom | list | `[]` | Secrets and/or ConfigMaps that will be loaded as environment variables. [[ref]](https://unofficial-kubernetes.readthedocs.io/en/latest/tasks/configure-pod-container/configmap/#use-case-consume-configmap-in-environment-variables) | +| controllers.main.containers.main.image.pullPolicy | string | `nil` | image pull policy | +| controllers.main.containers.main.image.repository | string | `nil` | image repository | +| controllers.main.containers.main.image.tag | string | `nil` | image tag | +| controllers.main.containers.main.lifecycle | object | `{}` | Configure the lifecycle for the container | +| controllers.main.containers.main.nameOverride | string | `nil` | Override the container name | +| controllers.main.containers.main.probes | object | See below | [[ref]](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) | +| controllers.main.containers.main.probes.liveness | object | See below | Liveness probe configuration | +| controllers.main.containers.main.probes.liveness.custom | bool | `false` | Set this to `true` if you wish to specify your own livenessProbe | +| controllers.main.containers.main.probes.liveness.enabled | bool | `true` | Enable the liveness probe | +| controllers.main.containers.main.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. | +| controllers.main.containers.main.probes.liveness.type | string | "TCP" | sets the probe type when not using a custom probe | +| controllers.main.containers.main.probes.readiness | object | See below | Redainess probe configuration | +| controllers.main.containers.main.probes.readiness.custom | bool | `false` | Set this to `true` if you wish to specify your own readinessProbe | +| controllers.main.containers.main.probes.readiness.enabled | bool | `true` | Enable the readiness probe | +| controllers.main.containers.main.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. | +| controllers.main.containers.main.probes.readiness.type | string | "TCP" | sets the probe type when not using a custom probe | +| controllers.main.containers.main.probes.startup | object | See below | Startup probe configuration | +| controllers.main.containers.main.probes.startup.custom | bool | `false` | Set this to `true` if you wish to specify your own startupProbe | +| controllers.main.containers.main.probes.startup.enabled | bool | `true` | Enable the startup probe | +| controllers.main.containers.main.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. | +| controllers.main.containers.main.probes.startup.type | string | "TCP" | sets the probe type when not using a custom probe | +| controllers.main.containers.main.resources | object | `{}` | Set the resource requests / limits for the container. | +| controllers.main.containers.main.securityContext | object | `{}` | Configure the Security Context for the container | +| controllers.main.containers.main.terminationMessagePath | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] | +| controllers.main.containers.main.terminationMessagePolicy | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] | +| controllers.main.cronjob | object | See below | CronJob configuration. Required only when using `controller.type: cronjob`. | +| controllers.main.cronjob.backoffLimit | int | `6` | Limits the number of times a failed job will be retried | +| controllers.main.cronjob.concurrencyPolicy | string | `"Forbid"` | Specifies how to treat concurrent executions of a job that is created by this cron job valid values are Allow, Forbid or Replace | +| controllers.main.cronjob.failedJobsHistory | int | `1` | The number of failed Jobs to keep | +| controllers.main.cronjob.schedule | string | `"*/20 * * * *"` | Sets the CronJob time when to execute your jobs | +| controllers.main.cronjob.startingDeadlineSeconds | int | `30` | The deadline in seconds for starting the job if it misses its scheduled time for any reason | +| controllers.main.cronjob.successfulJobsHistory | int | `1` | The number of succesful Jobs to keep | +| controllers.main.cronjob.ttlSecondsAfterFinished | string | `nil` | If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. | +| controllers.main.enabled | bool | `true` | enable the controller. | +| controllers.main.initContainers | object | `{}` | Specify any initContainers here as dictionary items. Each initContainer should have its own key. The dictionary item key will determine the order. Helm templates can be used. | +| controllers.main.labels | object | `{}` | Set labels on the deployment/statefulset/daemonset/cronjob | +| controllers.main.replicas | int | `1` | Number of desired pods. When using a HorizontalPodAutoscaler, set this to `null`. | +| controllers.main.revisionHistoryLimit | int | `3` | ReplicaSet revision history limit | +| controllers.main.rollingUpdate.partition | string | `nil` | Set statefulset RollingUpdate partition | +| controllers.main.rollingUpdate.surge | string | `nil` | Set deployment RollingUpdate max surge | +| controllers.main.rollingUpdate.unavailable | string | `nil` | Set deployment RollingUpdate max unavailable | +| controllers.main.statefulset | object | `{"podManagementPolicy":null,"volumeClaimTemplates":[]}` | StatefulSet configuration. Required only when using `controller.type: statefulset`. | +| controllers.main.statefulset.podManagementPolicy | string | `nil` | Set podManagementPolicy, valid values are Parallel and OrderedReady (default). | +| controllers.main.statefulset.volumeClaimTemplates | list | `[]` | Used to create individual disks for each instance. | +| controllers.main.strategy | string | `nil` | Set the controller upgrade strategy For Deployments, valid values are Recreate (default) and RollingUpdate. For StatefulSets, valid values are OnDelete and RollingUpdate (default). DaemonSets/CronJobs ignore this. | +| controllers.main.type | string | `"deployment"` | Set the controller type. Valid options are deployment, daemonset, statefulset or cronjob | +| defaultPodOptions | object | `{"affinity":{},"annotations":{},"automountServiceAccountToken":true,"dnsConfig":{},"dnsPolicy":null,"enableServiceLinks":true,"hostAliases":[],"hostIPC":false,"hostNetwork":false,"hostPID":false,"hostname":null,"imagePullSecrets":[],"labels":{},"nodeSelector":{},"priorityClassName":null,"restartPolicy":null,"runtimeClassName":null,"schedulerName":null,"securityContext":{},"terminationGracePeriodSeconds":null,"tolerations":[],"topologySpreadConstraints":[]}` | Set default options for all controllers / pods here Each of these options can be overridden on a Pod level | +| defaultPodOptions.affinity | object | `{}` | Defines affinity constraint rules. [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) | +| defaultPodOptions.annotations | object | `{}` | Set annotations on the Pod. Pod-specific values will be merged with this. | +| defaultPodOptions.automountServiceAccountToken | bool | `true` | Specifies whether a service account token should be automatically mounted. | +| defaultPodOptions.dnsConfig | object | `{}` | Configuring the ndots option may resolve nslookup issues on some Kubernetes setups. | +| defaultPodOptions.dnsPolicy | string | `nil` | Defaults to "ClusterFirst" if hostNetwork is false and "ClusterFirstWithHostNet" if hostNetwork is true. | +| defaultPodOptions.enableServiceLinks | bool | `true` | Enable/disable the generation of environment variables for services. [[ref]](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service) | +| defaultPodOptions.hostAliases | list | `[]` | Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. [[ref]](https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/) | +| defaultPodOptions.hostIPC | bool | `false` | Use the host's ipc namespace | +| defaultPodOptions.hostNetwork | bool | `false` | When using hostNetwork make sure you set dnsPolicy to `ClusterFirstWithHostNet` | +| defaultPodOptions.hostPID | bool | `false` | Use the host's pid namespace | +| defaultPodOptions.hostname | string | `nil` | Allows specifying explicit hostname setting | +| defaultPodOptions.imagePullSecrets | list | `[]` | Set image pull secrets | +| defaultPodOptions.labels | object | `{}` | Set labels on the Pod. Pod-specific values will be merged with this. | +| defaultPodOptions.nodeSelector | object | `{}` | Node selection constraint [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) | +| defaultPodOptions.priorityClassName | string | `nil` | Custom priority class for different treatment by the scheduler | +| defaultPodOptions.restartPolicy | string | `Always`. When `controller.type` is `cronjob` it defaults to `Never`. | Set Container restart policy. | +| defaultPodOptions.runtimeClassName | string | `nil` | Allow specifying a runtimeClassName other than the default one (ie: nvidia) | +| defaultPodOptions.schedulerName | string | `nil` | Allows specifying a custom scheduler name | +| defaultPodOptions.securityContext | object | `{}` | Configure the Security Context for the Pod | +| defaultPodOptions.terminationGracePeriodSeconds | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)] | +| defaultPodOptions.tolerations | list | `[]` | Specify taint tolerations [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) | +| defaultPodOptions.topologySpreadConstraints | list | `[]` | Defines topologySpreadConstraint rules. [[ref]](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) | | global.annotations | object | `{}` | Set additional global annotations. Helm templates can be used. | | global.fullnameOverride | string | `nil` | Set the entire name definition | | global.labels | object | `{}` | Set additional global labels. Helm templates can be used. | | global.nameOverride | string | `nil` | Set an override for the prefix of the fullname | -| hostAliases | list | `[]` | Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. [[ref]](https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/) | -| hostIPC | bool | `false` | Use the host's ipc namespace | -| hostNetwork | bool | `false` | When using hostNetwork make sure you set dnsPolicy to `ClusterFirstWithHostNet` | -| hostPID | bool | `false` | Use the host's pid namespace | -| hostname | string | `nil` | Allows specifying explicit hostname setting | -| image.pullPolicy | string | `nil` | image pull policy | -| image.repository | string | `nil` | image repository | -| image.tag | string | `nil` | image tag | -| imagePullSecrets | list | `[]` | Set image pull secrets | | ingress | object | See below | Configure the ingresses for the chart here. Additional ingresses can be added by adding a dictionary key similar to the 'main' ingress. | | ingress.main.annotations | object | `{}` | Provide additional annotations which may be required. | +| ingress.main.className | string | `nil` | Set the ingressClass that is used for this 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].paths[0].path | string | `"/"` | Path. Helm template can be passed. | -| ingress.main.hosts[0].paths[0].service.name | string | `nil` | Overrides the service name reference for this path | -| ingress.main.hosts[0].paths[0].service.port | string | `nil` | Overrides the service port reference for this path | -| ingress.main.ingressClassName | string | `nil` | Set the ingressClass that is used for this ingress. | +| ingress.main.hosts[0].paths[0].service.name | string | `"main"` | Overrides the service name reference for this path This can be an actual service name, or reference a service identifier from this values.yaml | +| ingress.main.hosts[0].paths[0].service.port | string | `nil` | Overrides the service port number reference for this path | | ingress.main.labels | object | `{}` | Provide additional labels which may be required. | | ingress.main.nameOverride | string | `nil` | Override the name suffix that is used for this ingress. | | ingress.main.primary | bool | `true` | Make this the primary ingress (used in probes, notes, etc...). If there is more than 1 ingress, make sure that only 1 ingress is marked as primary. | | ingress.main.tls | list | `[]` | Configure TLS for the ingress. Both secretName and hosts can process a Helm template. | -| initContainers | object | `{}` | Specify any initContainers here as dictionary items. Each initContainer should have its own key. The dictionary item key will determine the order. Helm templates can be used. | -| lifecycle | object | `{}` | Configure the lifecycle for the main container | -| nodeSelector | object | `{}` | Node selection constraint [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) | | persistence | object | See below | Configure persistence for the chart here. Additional items can be added by adding a dictionary key similar to the 'config' key. [[ref]](https://bjw-s.github.io/helm-charts/docs/common-library/common-library-storage) | -| persistence.config | object | See below | Default persistence for configuration files. | | persistence.config.accessMode | string | `"ReadWriteOnce"` | AccessMode for the persistent volume. Make sure to select an access mode that is supported by your storage provider! [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) | -| persistence.config.enabled | bool | `false` | Enables or disables the persistence item | +| persistence.config.advancedMounts | object | `{}` | Explicitly configure mounts for specific controllers and containers. Example: advancedMounts: main: # the controller with whe "main" identifier main: # the container with whe "main" identifier - path: /data/config.yaml readOnly: true subPath: config.yaml second-container: # the container with whe "second-container" identifier - path: /appdata/config readOnly: true second-controller: # the controller with whe "second-controller" identifier main: # the container with whe "main" identifier - path: /data/config.yaml readOnly: false subPath: config.yaml | +| persistence.config.enabled | bool | `false` | Enables or disables the persistence item. Defaults to true | | persistence.config.existingClaim | string | `nil` | If you want to reuse an existing claim, the name of the existing PVC can be passed here. | -| persistence.config.mountPath | string | `nil` | Where to mount the volume in the main container. Defaults to `/`, setting to '-' creates the volume but disables the volumeMount. | -| persistence.config.nameOverride | string | `nil` | Override the name suffix that is used for this volume. | -| persistence.config.readOnly | bool | `false` | Specify if the volume should be mounted read-only. | +| persistence.config.globalMounts | list | `[]` | Configure mounts to all controllers and containers. By default the persistence item will be mounted to `/`. Example: globalMounts: - path: /config readOnly: false | | persistence.config.retain | bool | `false` | Set to true to retain the PVC upon `helm uninstall` | | persistence.config.size | string | `"1Gi"` | The amount of storage that is requested for the persistent volume. | | persistence.config.storageClass | string | `nil` | Storage Class for the config volume. If set to `-`, dynamic provisioning is disabled. If set to something else, the given storageClass is used. If undefined (the default) or set to null, no storageClassName spec is set, choosing the default provisioner. | -| persistence.config.subPath | string | `nil` | Used in conjunction with `existingClaim`. Specifies a sub-path inside the referenced volume instead of its root | -| persistence.config.type | string | `"pvc"` | Sets the persistence type Valid options are pvc, emptyDir, hostPath, secret, configMap or custom | -| persistence.shared | object | See below | Create an emptyDir volume to share between all containers [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) | -| persistence.shared.medium | string | `nil` | Set the medium to "Memory" to mount a tmpfs (RAM-backed filesystem) instead of the storage medium that backs the node. | -| persistence.shared.sizeLimit | string | `nil` | If the `SizeMemoryBackedVolumes` feature gate is enabled, you can specify a size for memory backed volumes. | -| podAnnotations | object | `{}` | Set annotations on the pod | -| podLabels | object | `{}` | Set labels on the pod | -| podSecurityContext | object | `{}` | Configure the Security Context for the Pod | -| priorityClassName | string | `nil` | Custom priority class for different treatment by the scheduler | -| probes | object | See below | [[ref]](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) | -| probes.liveness | object | See below | Liveness probe configuration | -| probes.liveness.custom | bool | `false` | Set this to `true` if you wish to specify your own livenessProbe | -| probes.liveness.enabled | bool | `true` | Enable the liveness probe | -| probes.liveness.spec | object | See below | The spec field contains the values for the default livenessProbe. If you selected `custom: true`, this field holds the definition of the livenessProbe. | -| probes.liveness.type | string | "TCP" | sets the probe type when not using a custom probe | -| probes.readiness | object | See below | Redainess probe configuration | -| probes.readiness.custom | bool | `false` | Set this to `true` if you wish to specify your own readinessProbe | -| probes.readiness.enabled | bool | `true` | Enable the readiness probe | -| probes.readiness.spec | object | See below | The spec field contains the values for the default readinessProbe. If you selected `custom: true`, this field holds the definition of the readinessProbe. | -| probes.readiness.type | string | "TCP" | sets the probe type when not using a custom probe | -| probes.startup | object | See below | Startup probe configuration | -| probes.startup.custom | bool | `false` | Set this to `true` if you wish to specify your own startupProbe | -| probes.startup.enabled | bool | `true` | Enable the startup probe | -| probes.startup.spec | object | See below | The spec field contains the values for the default startupProbe. If you selected `custom: true`, this field holds the definition of the startupProbe. | -| 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. | +| persistence.config.type | string | `"persistentVolumeClaim"` | Sets the persistence type Valid options are persistentVolumeClaim, emptyDir, hostPath, secret, configMap or custom | | route | object | See below | Configure the gateway routes for the chart here. Additional routes can be added by adding a dictionary key similar to the 'main' route. [[ref]](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io%2fv1alpha2) | | route.main.annotations | object | `{}` | Provide additional annotations which may be required. | | route.main.enabled | bool | `false` | Enables or disables the route | @@ -198,36 +162,35 @@ N/A | route.main.labels | object | `{}` | Provide additional labels which may be required. | | route.main.nameOverride | string | `nil` | Override the name suffix that is used for this route. | | route.main.parentRefs | list | `[{"group":"gateway.networking.k8s.io","kind":"Gateway","name":null,"namespace":null,"sectionName":null}]` | Configure the resource the route attaches to. | -| route.main.rules | list | `[{"backendRefs":[{"group":"","kind":"Service","name":null,"namespace":null,"port":null,"weight":1}],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Configure rules for routing. Defaults to the primary service. | -| route.main.rules[0].backendRefs | list | `[{"group":"","kind":"Service","name":null,"namespace":null,"port":null,"weight":1}]` | Configure backends where matching requests should be sent. | -| runtimeClassName | string | `nil` | Allow specifying a runtimeClassName other than the default one (ie: nvidia) | -| schedulerName | string | `nil` | Allows specifying a custom scheduler name | +| route.main.rules | list | `[{"backendRefs":[{"group":"","kind":"Service","name":"main","namespace":null,"port":null,"weight":1}],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Configure rules for routing. Defaults to the primary service. | +| route.main.rules[0].backendRefs | list | `[{"group":"","kind":"Service","name":"main","namespace":null,"port":null,"weight":1}]` | Configure backends where matching requests should be sent. | | 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 | | 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.controller | string | `"main"` | Configure which controller this service should target | | service.main.enabled | bool | `true` | Enables or disables the service | | service.main.externalTrafficPolicy | string | `nil` | [[ref](https://kubernetes.io/docs/tutorials/services/source-ip/)] | +| service.main.extraSelectorLabels | object | `{}` | Allow adding additional match labels | | service.main.ipFamilies | list | `[]` | The ip families that should be used. Options: IPv4, IPv6 | | service.main.ipFamilyPolicy | string | `nil` | Specify the ip policy. Options: SingleStack, PreferDualStack, RequireDualStack | | service.main.labels | object | `{}` | Provide additional labels which may be required. | | service.main.nameOverride | string | `nil` | Override the name suffix that is used for this service | | service.main.ports | object | See below | Configure the Service port information here. Additional ports can be added by adding a dictionary key similar to the 'http' service. | | service.main.ports.http.enabled | bool | `true` | Enables or disables the port | -| service.main.ports.http.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.port | string | `nil` | The port number | | service.main.ports.http.primary | bool | `true` | Make this the primary port (used in probes, notes, etc...) If there is more than 1 service, make sure that only 1 port is marked as primary. | -| service.main.ports.http.protocol | string | `"HTTP"` | Port protocol. Support values are `HTTP`, `HTTPS`, `TCP` and `UDP`. HTTPS and HTTPS spawn a TCP service and get used for internal URL and name generation | +| service.main.ports.http.protocol | string | `"HTTP"` | Port protocol. Support values are `HTTP`, `HTTPS`, `TCP` and `UDP`. HTTP and HTTPS spawn a TCP service and get used for internal URL and name generation | | service.main.ports.http.targetPort | string | `nil` | Specify a service targetPort if you wish to differ the service port from the application port. If `targetPort` is specified, this port number is used in the container definition instead of the `port` value. Therefore named ports are not supported for this field. | -| service.main.primary | bool | `true` | Make this the primary service (used in probes, notes, etc...). If there is more than 1 service, make sure that only 1 service is marked as primary. | +| service.main.primary | bool | `true` | Make this the primary service for this controller (used in probes, notes, etc...). If there is more than 1 service targeting the controller, make sure that only 1 service is marked as primary. | | service.main.type | string | `"ClusterIP"` | Set the service type | | serviceAccount.annotations | object | `{}` | Annotations to add to the service account | | serviceAccount.create | bool | `false` | Specifies whether a service account should be created | +| serviceAccount.labels | object | `{}` | Labels to add to the service account | | 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. | @@ -237,13 +200,6 @@ N/A | 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 | `"{{ include \"bjw-s.common.lib.chart.names.fullname\" $ }}"` | Configures the target Service for the serviceMonitor. Helm templates can be used. | -| sidecars | object | `{}` | Specify any sidecar containers here as dictionary items. Each sidecar container should have its own key. The dictionary item key will determine the order. Helm templates can be used. | -| termination.gracePeriodSeconds | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)] | -| termination.messagePath | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] | -| termination.messagePolicy | string | `nil` | [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] | -| tolerations | list | `[]` | Specify taint tolerations [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) | -| topologySpreadConstraints | list | `[]` | Defines topologySpreadConstraint rules. [[ref]](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) | -| volumeClaimTemplates | list | `[]` | Used in conjunction with `controller.type: statefulset` to create individual disks for each instance. | ## Support diff --git a/charts/library/common/templates/addons/code-server/_addon.tpl b/charts/library/common/templates/addons/code-server/_addon.tpl deleted file mode 100644 index 6a4e5ab9..00000000 --- a/charts/library/common/templates/addons/code-server/_addon.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{{/* -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 sidecars */}} - {{- $container := include "bjw-s.common.addon.codeserver.container" . | fromYaml -}} - {{- if $container -}} - {{- $_ := set .Values.sidecars "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 */}} - {{- if .Values.addons.codeserver.service.enabled -}} - {{- $serviceValues := .Values.addons.codeserver.service -}} - {{- $_ := set $serviceValues "nameOverride" "addon-codeserver" -}} - {{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}} - {{- include "bjw-s.common.class.service" $ -}} - {{- $_ := unset $.ObjectValues "service" -}} - {{- end -}} - - {{/* Add the code-server ingress */}} - {{- $svcName := printf "%v-addon-codeserver" (include "bjw-s.common.lib.chart.names.fullname" .) -}} - {{- $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 -}} diff --git a/charts/library/common/templates/addons/code-server/_container.tpl b/charts/library/common/templates/addons/code-server/_container.tpl deleted file mode 100644 index e906a157..00000000 --- a/charts/library/common/templates/addons/code-server/_container.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{{/* -The code-server sidecar container to be inserted. -*/}} -{{- define "bjw-s.common.addon.codeserver.container" -}} -{{- if lt (len .Values.addons.codeserver.volumeMounts) 1 }} -{{- fail "At least 1 volumeMount is required for codeserver container" }} -{{- end -}} -name: codeserver -image: "{{ .Values.addons.codeserver.image.repository }}:{{ .Values.addons.codeserver.image.tag }}" -imagePullPolicy: {{ .Values.addons.codeserver.pullPolicy }} -{{- with .Values.addons.codeserver.securityContext }} -securityContext: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.addons.codeserver.env }} -env: -{{- range $k, $v := . }} - - name: {{ $k }} - value: {{ $v | quote }} -{{- end }} -{{- end }} -ports: -- name: codeserver - containerPort: {{ .Values.addons.codeserver.service.ports.codeserver.port }} - protocol: TCP -args: -{{- range .Values.addons.codeserver.args }} -- {{ . | quote }} -{{- end }} -- "--port" -- "{{ .Values.addons.codeserver.service.ports.codeserver.port }}" -- {{ .Values.addons.codeserver.workingDir | default (first .Values.addons.codeserver.volumeMounts).mountPath }} -volumeMounts: -{{- with .Values.addons.codeserver.volumeMounts }} - {{- toYaml . | nindent 2 }} -{{- end }} -{{- if or .Values.addons.codeserver.git.deployKey .Values.addons.codeserver.git.deployKeyBase64 .Values.addons.codeserver.git.deployKeySecret }} - - name: deploykey - mountPath: /root/.ssh/id_rsa - subPath: id_rsa -{{- end }} -{{- with .Values.addons.codeserver.resources }} -resources: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- end -}} diff --git a/charts/library/common/templates/addons/code-server/_secret.tpl b/charts/library/common/templates/addons/code-server/_secret.tpl deleted file mode 100644 index 74333d5e..00000000 --- a/charts/library/common/templates/addons/code-server/_secret.tpl +++ /dev/null @@ -1,10 +0,0 @@ -{{/* -The deployKey secret to be included. -*/}} -{{- define "bjw-s.common.addon.codeserver.deployKeySecret" -}} - {{- $deployKeyValue := .Values.addons.codeserver.git.deployKey -}} - {{- if .Values.addons.codeserver.git.deployKeyBase64 -}} - {{- $deployKeyValue = .Values.addons.codeserver.git.deployKeyBase64 | b64dec -}} - {{- end -}} -id_rsa: {{ $deployKeyValue | quote }} -{{- end -}} diff --git a/charts/library/common/templates/addons/code-server/_volume.tpl b/charts/library/common/templates/addons/code-server/_volume.tpl deleted file mode 100644 index 240f6714..00000000 --- a/charts/library/common/templates/addons/code-server/_volume.tpl +++ /dev/null @@ -1,15 +0,0 @@ -{{/* -The volume (referencing git deploykey) to be inserted into additionalVolumes. -*/}} -{{- define "bjw-s.common.addon.codeserver.deployKeyVolumeSpec" -}} -secret: - {{- if .Values.addons.codeserver.git.deployKeySecret }} - secretName: {{ .Values.addons.codeserver.git.deployKeySecret }} - {{- else }} - secretName: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-codeserver-deploykey - {{- end }} - defaultMode: {{ "0400" | toDecimal }} - items: - - key: id_rsa - path: id_rsa -{{- end -}} diff --git a/charts/library/common/templates/addons/netshoot/_addon.tpl b/charts/library/common/templates/addons/netshoot/_addon.tpl deleted file mode 100644 index 599f6d8d..00000000 --- a/charts/library/common/templates/addons/netshoot/_addon.tpl +++ /dev/null @@ -1,13 +0,0 @@ -{{/* -Template to render netshoot addon -It will include / inject the required templates based on the given values. -*/}} -{{- define "bjw-s.common.addon.netshoot" -}} -{{- if .Values.addons.netshoot.enabled -}} - {{/* Append the netshoot container to the sidecars */}} - {{- $container := include "bjw-s.common.addon.netshoot.container" . | fromYaml -}} - {{- if $container -}} - {{- $_ := set .Values.sidecars "addon-netshoot" $container -}} - {{- end -}} -{{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/addons/netshoot/_container.tpl b/charts/library/common/templates/addons/netshoot/_container.tpl deleted file mode 100644 index 91f0513b..00000000 --- a/charts/library/common/templates/addons/netshoot/_container.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{{/* -The netshoot sidecar container to be inserted. -*/}} -{{- define "bjw-s.common.addon.netshoot.container" -}} -name: netshoot -image: "{{ .Values.addons.netshoot.image.repository }}:{{ .Values.addons.netshoot.image.tag }}" -imagePullPolicy: {{ .Values.addons.netshoot.pullPolicy }} -{{- with .Values.addons.netshoot.securityContext }} -securityContext: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.addons.netshoot.env }} -env: -{{- range $k, $v := . }} - - name: {{ $k }} - value: {{ $v | quote }} -{{- end }} -{{- end }} -command: - - /bin/sh - - -c - - sleep infinity -{{- with .Values.addons.netshoot.resources }} -resources: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- end -}} diff --git a/charts/library/common/templates/addons/vpn/_addon.tpl b/charts/library/common/templates/addons/vpn/_addon.tpl deleted file mode 100644 index d7a5c0df..00000000 --- a/charts/library/common/templates/addons/vpn/_addon.tpl +++ /dev/null @@ -1,45 +0,0 @@ -{{/* -Template to render VPN addon -It will include / inject the required templates based on the given values. -*/}} -{{- define "bjw-s.common.addon.vpn" -}} -{{- if .Values.addons.vpn.enabled -}} - {{- if eq "gluetun" .Values.addons.vpn.type -}} - {{- include "bjw-s.common.addon.gluetun" . }} - {{- end -}} - - {{/* Include the configmap if not empty */}} - {{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down }} - {{- $configmap := include "bjw-s.common.addon.vpn.configmap" . -}} - {{- if $configmap -}} - {{- $_ := set .Values.configMaps "addon-vpn" (dict "enabled" true "data" ($configmap | fromYaml)) -}} - {{- end -}} - {{- end -}} - - {{/* Include the secret if not empty */}} - {{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) }} - {{- $secret := include "bjw-s.common.addon.vpn.secret" . -}} - {{- if $secret -}} - {{- $_ := set .Values.secrets "addon-vpn-config" (dict "enabled" true "stringData" ($secret | fromYaml)) -}} - {{- end -}} - {{- end -}} - - {{/* Append the vpn scripts volume to the volumes */}} - {{- $scriptVolume := include "bjw-s.common.addon.vpn.scriptsVolumeSpec" . | fromYaml -}} - {{- if $scriptVolume -}} - {{- $_ := set .Values.persistence "vpnscript" (dict "enabled" true "mountPath" "-" "type" "custom" "volumeSpec" $scriptVolume) -}} - {{- end -}} - - {{/* Append the vpn config volume to the volumes */}} - {{- $configVolume := include "bjw-s.common.addon.vpn.configVolumeSpec" . | fromYaml }} - {{ if $configVolume -}} - {{- $_ := set .Values.persistence "vpnconfig" (dict "enabled" true "mountPath" "-" "type" "custom" "volumeSpec" $configVolume) -}} - {{- end -}} - - {{/* Include the networkpolicy if not empty */}} - {{- $networkpolicy := include "bjw-s.common.addon.vpn.networkpolicy" . -}} - {{- if $networkpolicy -}} - {{- $networkpolicy | nindent 0 -}} - {{- end -}} -{{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/addons/vpn/_configmap.tpl b/charts/library/common/templates/addons/vpn/_configmap.tpl deleted file mode 100644 index 697edf91..00000000 --- a/charts/library/common/templates/addons/vpn/_configmap.tpl +++ /dev/null @@ -1,14 +0,0 @@ -{{/* -The VPN config and scripts to be included. -*/}} -{{- define "bjw-s.common.addon.vpn.configmap" -}} -{{- with .Values.addons.vpn.scripts.up }} -up.sh: |- - {{- . | nindent 2}} -{{- end }} - -{{- with .Values.addons.vpn.scripts.down }} -down.sh: |- - {{- . | nindent 2}} -{{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/addons/vpn/_networkpolicy.tpl b/charts/library/common/templates/addons/vpn/_networkpolicy.tpl deleted file mode 100644 index e2cf55c4..00000000 --- a/charts/library/common/templates/addons/vpn/_networkpolicy.tpl +++ /dev/null @@ -1,29 +0,0 @@ -{{/* -Blueprint for the NetworkPolicy object that can be included in the addon. -*/}} -{{- define "bjw-s.common.addon.vpn.networkpolicy" -}} -{{- if .Values.addons.vpn.networkPolicy.enabled }} ---- -kind: NetworkPolicy -apiVersion: networking.k8s.io/v1 -metadata: - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }} - {{- with (merge (.Values.addons.vpn.networkPolicy.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} - labels: {{- toYaml . | nindent 4 }} - {{- end }} - {{- with (merge (.Values.addons.vpn.networkPolicy.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - annotations: {{- toYaml . | nindent 4 }} - {{- end }} -spec: - podSelector: - {{- with (merge .Values.addons.vpn.networkPolicy.podSelectorLabels (include "bjw-s.common.lib.metadata.selectorLabels" . | fromYaml)) }} - matchLabels: {{- toYaml . | nindent 6 }} - {{- end }} - policyTypes: - - Egress - egress: - {{- with .Values.addons.vpn.networkPolicy.egress }} - {{- . | toYaml | nindent 4 }} - {{- end -}} -{{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/addons/vpn/_secret.tpl b/charts/library/common/templates/addons/vpn/_secret.tpl deleted file mode 100644 index 5735e856..00000000 --- a/charts/library/common/templates/addons/vpn/_secret.tpl +++ /dev/null @@ -1,9 +0,0 @@ -{{/* -The OpenVPN config secret to be included. -*/}} -{{- define "bjw-s.common.addon.vpn.secret" -}} -{{- if and .Values.addons.vpn.configFile (not .Values.addons.vpn.configFileSecret) -}} -vpnConfigfile: |- - {{- .Values.addons.vpn.configFile | nindent 2 }} -{{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/addons/vpn/_volume.tpl b/charts/library/common/templates/addons/vpn/_volume.tpl deleted file mode 100644 index a9746155..00000000 --- a/charts/library/common/templates/addons/vpn/_volume.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{{/* -The volume (referencing VPN scripts) to be inserted into additionalVolumes. -*/}} -{{- define "bjw-s.common.addon.vpn.scriptsVolumeSpec" -}} -{{- if or .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down -}} -configMap: - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-vpn - items: - {{- if .Values.addons.vpn.scripts.up }} - - key: up.sh - path: up.sh - mode: 0777 - {{- end }} - {{- if .Values.addons.vpn.scripts.down }} - - key: down.sh - path: down.sh - mode: 0777 - {{- end }} -{{- end -}} -{{- end -}} - -{{/* -The volume (referencing VPN config) to be inserted into additionalVolumes. -*/}} -{{- define "bjw-s.common.addon.vpn.configVolumeSpec" -}} -{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret -}} -secret: - {{- if .Values.addons.vpn.configFileSecret }} - secretName: {{ .Values.addons.vpn.configFileSecret }} - {{- else }} - secretName: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-addon-vpn-config - {{- end }} - items: - - key: vpnConfigfile - path: vpnConfigfile -{{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/addons/vpn/gluetun/_addon.tpl b/charts/library/common/templates/addons/vpn/gluetun/_addon.tpl deleted file mode 100644 index 0c344dc1..00000000 --- a/charts/library/common/templates/addons/vpn/gluetun/_addon.tpl +++ /dev/null @@ -1,11 +0,0 @@ -{{/* -Template to render gluetun addon. It will add the container to the list of additionalContainers. -*/}} -*/}} -{{- define "bjw-s.common.addon.gluetun" -}} - {{/* Append the gluetun container to the sidecars */}} - {{- $container := fromYaml (include "bjw-s.common.addon.gluetun.container" .) -}} - {{- if $container -}} - {{- $_ := set .Values.sidecars "addon-gluetun" $container -}} - {{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/addons/vpn/gluetun/_container.tpl b/charts/library/common/templates/addons/vpn/gluetun/_container.tpl deleted file mode 100644 index 1369ae2c..00000000 --- a/charts/library/common/templates/addons/vpn/gluetun/_container.tpl +++ /dev/null @@ -1,57 +0,0 @@ -{{/* -The gluetun sidecar container to be inserted. -*/}} -{{- define "bjw-s.common.addon.gluetun.container" -}} -name: gluetun -image: "{{ .Values.addons.vpn.gluetun.image.repository }}:{{ .Values.addons.vpn.gluetun.image.tag }}" -imagePullPolicy: {{ .Values.addons.vpn.gluetun.pullPolicy }} -{{- with .Values.addons.vpn.securityContext }} -securityContext: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- with .Values.addons.vpn.env }} -env: - {{- . | toYaml | nindent 2 }} -{{- end }} -{{- with .Values.addons.vpn.envFrom }} -envFrom: - {{- . | toYaml | nindent 2 }} -{{- end }} -{{- with .Values.addons.vpn.args }} -args: - {{- . | toYaml | nindent 2 }} -{{- end }} -{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret .Values.addons.vpn.scripts.up .Values.addons.vpn.scripts.down .Values.addons.vpn.additionalVolumeMounts .Values.persistence.shared.enabled }} -volumeMounts: -{{- if or .Values.addons.vpn.configFile .Values.addons.vpn.configFileSecret }} - - name: vpnconfig - mountPath: /gluetun/config.conf - subPath: vpnConfigfile -{{- end }} -{{- if .Values.addons.vpn.scripts.up }} - - name: vpnscript - mountPath: /gluetun/scripts/up.sh - subPath: up.sh -{{- end }} -{{- if .Values.addons.vpn.scripts.down }} - - name: vpnscript - mountPath: /gluetun/scripts/down.sh - subPath: down.sh -{{- end }} -{{- if .Values.persistence.shared.enabled }} - - mountPath: {{ .Values.persistence.shared.mountPath }} - name: shared -{{- end }} -{{- with .Values.addons.vpn.additionalVolumeMounts }} - {{- toYaml . | nindent 2 }} -{{- end }} -{{- end }} -{{- with .Values.addons.vpn.livenessProbe }} -livenessProbe: - {{- toYaml . | nindent 2 }} -{{- end -}} -{{- with .Values.addons.vpn.resources }} -resources: - {{- toYaml . | nindent 2 }} -{{- end }} -{{- end -}} diff --git a/charts/library/common/templates/classes/_configmap.tpl b/charts/library/common/templates/classes/_configmap.tpl index 21262808..3aa492e6 100644 --- a/charts/library/common/templates/classes/_configmap.tpl +++ b/charts/library/common/templates/classes/_configmap.tpl @@ -2,33 +2,31 @@ This template serves as a blueprint for all configMap objects that are created within the common library. */}} -{{- define "bjw-s.common.class.configmap" -}} - {{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}} - {{- $configMapName := $fullName -}} - {{- $values := .Values.configmap -}} +{{- define "bjw-s.common.class.configMap" -}} + {{- $rootContext := .rootContext -}} + {{- $configMapObject := .object -}} - {{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.configmap -}} - {{- $values = . -}} - {{- end -}} - {{ end -}} - - {{- if and (hasKey $values "nameOverride") $values.nameOverride -}} - {{- $configMapName = printf "%v-%v" $configMapName $values.nameOverride -}} - {{- end }} + {{- $labels := merge + ($configMapObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($configMapObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- apiVersion: v1 kind: ConfigMap metadata: - name: {{ $configMapName }} - {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} - labels: {{- toYaml . | nindent 4 }} + name: {{ $configMapObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - annotations: {{- toYaml . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} data: -{{- with $values.data }} - {{- tpl (toYaml .) $ | nindent 2 }} -{{- end }} + {{- with $configMapObject.data }} + {{- tpl (toYaml .) $rootContext | nindent 2 }} + {{- end }} {{- end -}} diff --git a/charts/library/common/templates/classes/_cronjob.tpl b/charts/library/common/templates/classes/_cronjob.tpl index 087ae510..16974d11 100644 --- a/charts/library/common/templates/classes/_cronjob.tpl +++ b/charts/library/common/templates/classes/_cronjob.tpl @@ -3,45 +3,48 @@ This template serves as a blueprint for Cronjob objects that are created using the common library. */}} {{- define "bjw-s.common.class.cronjob" -}} - {{- $restartPolicy := default "Never" .Values.controller.restartPolicy -}} - {{- if and (ne $restartPolicy "Never") (ne $restartPolicy "OnFailure") -}} - {{- fail (printf "Not a valid restartPolicy for CronJob (%s)" $restartPolicy) -}} - {{- end -}} - {{- $_ := set .Values.controller "restartPolicy" $restartPolicy -}} + {{- $rootContext := .rootContext -}} + {{- $cronjobObject := .object -}} + + {{- $labels := merge + (dict "app.kubernetes.io/component" $cronjobObject.identifier) + ($cronjobObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($cronjobObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- apiVersion: batch/v1 kind: CronJob metadata: - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }} - {{- with include "bjw-s.common.lib.controller.metadata.labels" . }} - labels: {{- . | nindent 4 }} + name: {{ $cronjobObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with include "bjw-s.common.lib.controller.metadata.annotations" . }} - annotations: {{- . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} spec: - concurrencyPolicy: "{{ .Values.controller.cronjob.concurrencyPolicy }}" - startingDeadlineSeconds: {{ .Values.controller.cronjob.startingDeadlineSeconds }} - schedule: "{{ .Values.controller.cronjob.schedule }}" - successfulJobsHistoryLimit: {{ .Values.controller.cronjob.successfulJobsHistory }} - failedJobsHistoryLimit: {{ .Values.controller.cronjob.failedJobsHistory }} + concurrencyPolicy: "{{ $cronjobObject.cronjob.concurrencyPolicy }}" + startingDeadlineSeconds: {{ $cronjobObject.cronjob.startingDeadlineSeconds }} + schedule: "{{ $cronjobObject.cronjob.schedule }}" + successfulJobsHistoryLimit: {{ $cronjobObject.cronjob.successfulJobsHistory }} + failedJobsHistoryLimit: {{ $cronjobObject.cronjob.failedJobsHistory }} jobTemplate: spec: - {{- with .Values.controller.cronjob.ttlSecondsAfterFinished }} + {{- with $cronjobObject.cronjob.ttlSecondsAfterFinished }} ttlSecondsAfterFinished: {{ . }} {{- end }} - backoffLimit: {{ .Values.controller.cronjob.backoffLimit }} + backoffLimit: {{ $cronjobObject.cronjob.backoffLimit }} template: metadata: - {{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }} - annotations: - {{- . | nindent 12 }} + {{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $cronjobObject)) }} + annotations: {{ . | nindent 12 }} + {{- end -}} + {{- with (include "bjw-s.common.lib.pod.metadata.labels" (dict "rootContext" $rootContext "controllerObject" $cronjobObject)) }} + labels: {{ . | nindent 12 }} {{- end }} - labels: - {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 12 }} - {{- with .Values.podLabels }} - {{- toYaml . | nindent 12 }} - {{- end }} - spec: - {{- include "bjw-s.common.lib.controller.pod" . | nindent 10 }} + spec: {{ include "bjw-s.common.lib.pod.spec" (dict "rootContext" $rootContext "controllerObject" $cronjobObject) | nindent 10 }} {{- end -}} diff --git a/charts/library/common/templates/classes/_daemonset.tpl b/charts/library/common/templates/classes/_daemonset.tpl index 71827f48..cdb26fb8 100644 --- a/charts/library/common/templates/classes/_daemonset.tpl +++ b/charts/library/common/templates/classes/_daemonset.tpl @@ -3,33 +3,38 @@ This template serves as the blueprint for the DaemonSet objects that are created within the common library. */}} {{- define "bjw-s.common.class.daemonset" -}} + {{- $rootContext := .rootContext -}} + {{- $daemonsetObject := .object -}} + + {{- $labels := merge + (dict "app.kubernetes.io/component" $daemonsetObject.identifier) + ($daemonsetObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($daemonsetObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- 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 }} + name: {{ $daemonsetObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with include "bjw-s.common.lib.controller.metadata.annotations" . }} - annotations: {{- . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} spec: - revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} + revisionHistoryLimit: {{ $daemonsetObject.revisionHistoryLimit }} selector: matchLabels: - {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: {{ $daemonsetObject.identifier }} + {{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | 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 }} + annotations: {{ include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $daemonsetObject) | nindent 8 }} + labels: {{ include "bjw-s.common.lib.pod.metadata.labels" (dict "rootContext" $rootContext "controllerObject" $daemonsetObject) | nindent 8 }} + spec: {{ include "bjw-s.common.lib.pod.spec" (dict "rootContext" $rootContext "controllerObject" $daemonsetObject) | nindent 6 }} {{- end }} diff --git a/charts/library/common/templates/classes/_deployment.tpl b/charts/library/common/templates/classes/_deployment.tpl index 3407b940..ee0a829c 100644 --- a/charts/library/common/templates/classes/_deployment.tpl +++ b/charts/library/common/templates/classes/_deployment.tpl @@ -3,30 +3,38 @@ This template serves as a blueprint for Deployment objects that are created using the common library. */}} {{- 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 -}} + {{- $rootContext := .rootContext -}} + {{- $deploymentObject := .object -}} + + {{- $labels := merge + (dict "app.kubernetes.io/component" $deploymentObject.identifier) + ($deploymentObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($deploymentObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }} - {{- with include "bjw-s.common.lib.controller.metadata.labels" . }} - labels: {{- . | nindent 4 }} + name: {{ $deploymentObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with include "bjw-s.common.lib.controller.metadata.annotations" . }} - annotations: {{- . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} spec: - revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} - {{- if not (eq .Values.controller.replicas nil) }} - replicas: {{ .Values.controller.replicas }} + revisionHistoryLimit: {{ $deploymentObject.revisionHistoryLimit }} + {{- if not (eq $deploymentObject.replicas nil) }} + replicas: {{ $deploymentObject.replicas }} {{- end }} strategy: - type: {{ $strategy }} - {{- with .Values.controller.rollingUpdate }} - {{- if and (eq $strategy "RollingUpdate") (or .surge .unavailable) }} + type: {{ $deploymentObject.strategy }} + {{- with $deploymentObject.rollingUpdate }} + {{- if and (eq $deploymentObject.strategy "RollingUpdate") (or .surge .unavailable) }} rollingUpdate: {{- with .unavailable }} maxUnavailable: {{ . }} @@ -38,18 +46,15 @@ spec: {{- end }} selector: matchLabels: - {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: {{ $deploymentObject.identifier }} + {{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }} template: metadata: - {{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }} - annotations: - {{- . | nindent 8 }} + {{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $deploymentObject)) }} + annotations: {{ . | nindent 8 }} + {{- end -}} + {{- with (include "bjw-s.common.lib.pod.metadata.labels" (dict "rootContext" $rootContext "controllerObject" $deploymentObject)) }} + labels: {{ . | 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 }} + spec: {{ include "bjw-s.common.lib.pod.spec" (dict "rootContext" $rootContext "controllerObject" $deploymentObject) | nindent 6 }} {{- end -}} diff --git a/charts/library/common/templates/classes/_ingress.tpl b/charts/library/common/templates/classes/_ingress.tpl index 07ed995f..c32d02c2 100644 --- a/charts/library/common/templates/classes/_ingress.tpl +++ b/charts/library/common/templates/classes/_ingress.tpl @@ -2,74 +2,65 @@ This template serves as a blueprint for all Ingress objects that are created within the common library. */}} + {{- define "bjw-s.common.class.ingress" -}} - {{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}} - {{- $ingressName := $fullName -}} - {{- $values := .Values.ingress -}} + {{- $rootContext := .rootContext -}} + {{- $ingressObject := .object -}} - {{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.ingress -}} - {{- $values = . -}} - {{- end -}} - {{ end -}} - - {{- if and (hasKey $values "nameOverride") $values.nameOverride -}} - {{- $ingressName = printf "%v-%v" $ingressName $values.nameOverride -}} - {{- end -}} - - {{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}} - {{- $defaultServiceName := $fullName -}} - {{- if and (hasKey $primaryService "nameOverride") $primaryService.nameOverride -}} - {{- $defaultServiceName = printf "%v-%v" $defaultServiceName $primaryService.nameOverride -}} - {{- end -}} - {{- $defaultServicePort := get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $primaryService)) -}} + {{- $labels := merge + ($ingressObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($ingressObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: {{ $ingressName }} - {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} - labels: {{- toYaml . | nindent 4 }} + name: {{ $ingressObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - annotations: {{- toYaml . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} spec: - {{- if $values.ingressClassName }} - ingressClassName: {{ $values.ingressClassName }} + {{- if $ingressObject.className }} + ingressClassName: {{ $ingressObject.className }} {{- end }} - {{- if $values.tls }} + {{- if $ingressObject.tls }} tls: - {{- range $values.tls }} + {{- range $ingressObject.tls }} - hosts: {{- range .hosts }} - - {{ tpl . $ | quote }} + - {{ tpl . $rootContext | quote }} {{- end }} - {{- $secretName := tpl (default "" .secretName) $ }} + {{- $secretName := tpl (default "" .secretName) $rootContext }} {{- if $secretName }} secretName: {{ $secretName | quote}} {{- end }} {{- end }} {{- end }} rules: - {{- range $values.hosts }} - - host: {{ tpl .host $ | quote }} + {{- range $ingressObject.hosts }} + - host: {{ tpl .host $rootContext | quote }} http: paths: {{- range .paths }} - {{- $service := $defaultServiceName -}} - {{- $port := $defaultServicePort.port -}} - {{- if .service -}} - {{- $service = default $service .service.name -}} - {{- $port = default $port .service.port -}} - {{- end }} - - path: {{ tpl .path $ | quote }} + - path: {{ tpl .path $rootContext | quote }} pathType: {{ default "Prefix" .pathType }} backend: service: - name: {{ $service }} + {{ $service := include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .service.name) | fromYaml -}} + {{ $servicePrimaryPort := dict -}} + {{ if $service -}} + {{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}} + {{ end -}} + name: {{ default .service.name $service.name }} port: - number: {{ $port }} + number: {{ default .service.port $servicePrimaryPort.port }} {{- end }} {{- end }} {{- end }} diff --git a/charts/library/common/templates/classes/_pvc.tpl b/charts/library/common/templates/classes/_pvc.tpl index 4e30ba09..6759bc8a 100644 --- a/charts/library/common/templates/classes/_pvc.tpl +++ b/charts/library/common/templates/classes/_pvc.tpl @@ -3,43 +3,45 @@ This template serves as a blueprint for all PersistentVolumeClaim objects that a within the common library. */}} {{- define "bjw-s.common.class.pvc" -}} -{{- $values := .Values.persistence -}} -{{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.persistence -}} - {{- $values = . -}} + {{- $rootContext := .rootContext -}} + {{- $pvcObject := .object -}} + + {{- $labels := merge + ($pvcObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($pvcObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} + {{- if $pvcObject.retain }} + {{- $annotations = merge + (dict "helm.sh/resource-policy" "keep") + $annotations + -}} {{- end -}} -{{ end -}} -{{- $pvcName := include "bjw-s.common.lib.chart.names.fullname" . -}} -{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} - {{- if not (eq $values.nameOverride "-") -}} - {{- $pvcName = printf "%v-%v" $pvcName $values.nameOverride -}} - {{ end -}} -{{ end }} + --- kind: PersistentVolumeClaim apiVersion: v1 metadata: - name: {{ $pvcName }} - {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} - labels: {{- toYaml . | nindent 4 }} + name: {{ $pvcObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} + {{- end }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} - annotations: - {{- if $values.retain }} - "helm.sh/resource-policy": keep - {{- end }} - {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - {{- toYaml . | nindent 4 }} - {{- end }} spec: accessModes: - - {{ required (printf "accessMode is required for PVC %v" $pvcName) $values.accessMode | quote }} + - {{ required (printf "accessMode is required for PVC %v" $pvcObject.name) $pvcObject.accessMode | quote }} resources: requests: - storage: {{ required (printf "size is required for PVC %v" $pvcName) $values.size | quote }} - {{- if $values.storageClass }} - storageClassName: {{ if (eq "-" $values.storageClass) }}""{{- else }}{{ $values.storageClass | quote }}{{- end }} + storage: {{ required (printf "size is required for PVC %v" $pvcObject.name) $pvcObject.size | quote }} + {{- if $pvcObject.storageClass }} + storageClassName: {{ if (eq "-" $pvcObject.storageClass) }}""{{- else }}{{ $pvcObject.storageClass | quote }}{{- end }} {{- end }} - {{- if $values.volumeName }} - volumeName: {{ $values.volumeName | quote }} + {{- if $pvcObject.volumeName }} + volumeName: {{ $pvcObject.volumeName | quote }} {{- end }} {{- end -}} diff --git a/charts/library/common/templates/classes/_route.tpl b/charts/library/common/templates/classes/_route.tpl index b5c0a8a8..4ccc541c 100644 --- a/charts/library/common/templates/classes/_route.tpl +++ b/charts/library/common/templates/classes/_route.tpl @@ -3,24 +3,18 @@ This template serves as a blueprint for all Route objects that are created within the common library. */}} {{- define "bjw-s.common.class.route" -}} -{{- $values := .Values.route -}} -{{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.route -}} - {{- $values = . -}} - {{- end -}} -{{ end -}} + {{- $rootContext := .rootContext -}} + {{- $routeObject := .object -}} -{{- $fullName := include "bjw-s.common.lib.chart.names.fullname" . -}} -{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} - {{- $fullName = printf "%v-%v" $fullName $values.nameOverride -}} -{{ end -}} -{{- $routeKind := $values.kind | default "HTTPRoute" -}} -{{- $primaryService := get .Values.service (include "bjw-s.common.lib.service.primary" .) -}} -{{- $defaultServiceName := $fullName -}} -{{- if and (hasKey $primaryService "nameOverride") $primaryService.nameOverride -}} - {{- $defaultServiceName = printf "%v-%v" $defaultServiceName $primaryService.nameOverride -}} -{{- end -}} -{{- $defaultServicePort := get $primaryService.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $primaryService)) -}} + {{- $routeKind := $routeObject.kind | default "HTTPRoute" -}} + {{- $labels := merge + ($routeObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($routeObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- apiVersion: gateway.networking.k8s.io/v1alpha2 {{- if and (ne $routeKind "GRPCRoute") (ne $routeKind "HTTPRoute") (ne $routeKind "TCPRoute") (ne $routeKind "TLSRoute") (ne $routeKind "UDPRoute") }} @@ -28,39 +22,44 @@ apiVersion: gateway.networking.k8s.io/v1alpha2 {{- end }} kind: {{ $routeKind }} metadata: - name: {{ $fullName }} - {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} - labels: {{- toYaml . | nindent 4 }} + name: {{ $routeObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - annotations: {{- toYaml . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} spec: parentRefs: - {{- range $values.parentRefs }} + {{- range $routeObject.parentRefs }} - group: {{ default "gateway.networking.k8s.io" .group }} kind: {{ default "Gateway" .kind }} - name: {{ required (printf "parentRef name is required for %v %v" $routeKind $fullName) .name }} - namespace: {{ required (printf "parentRef namespace is required for %v %v" $routeKind $fullName) .namespace }} + name: {{ required (printf "parentRef name is required for %v %v" $routeKind $routeObject.name) .name }} + namespace: {{ required (printf "parentRef namespace is required for %v %v" $routeKind $routeObject.name) .namespace }} {{- if .sectionName }} sectionName: {{ .sectionName | quote }} {{- end }} {{- end }} - {{- if and (ne $routeKind "TCPRoute") (ne $routeKind "UDPRoute") $values.hostnames }} + {{- if and (ne $routeKind "TCPRoute") (ne $routeKind "UDPRoute") $routeObject.hostnames }} hostnames: - {{- with $values.hostnames }} + {{- with $routeObject.hostnames }} {{- toYaml . | nindent 4 }} {{- end }} {{- end }} rules: - {{- range $values.rules }} + {{- range $routeObject.rules }} - backendRefs: {{- range .backendRefs }} + {{ $service := include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .name) | fromYaml -}} + {{ $servicePrimaryPort := dict -}} + {{ if $service -}} + {{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}} + {{- end }} - group: {{ default "" .group | quote}} kind: {{ default "Service" .kind }} - name: {{ default $defaultServiceName .name }} - namespace: {{ default $.Release.Namespace .namespace }} - port: {{ default $defaultServicePort.port .port }} + name: {{ default .name $service.name }} + namespace: {{ default $rootContext.Release.Namespace .namespace }} + port: {{ default .port $servicePrimaryPort.port }} weight: {{ default 1 .weight }} {{- end }} {{- if (eq $routeKind "HTTPRoute") }} diff --git a/charts/library/common/templates/classes/_secret.tpl b/charts/library/common/templates/classes/_secret.tpl index 29f59046..a46fe534 100644 --- a/charts/library/common/templates/classes/_secret.tpl +++ b/charts/library/common/templates/classes/_secret.tpl @@ -3,35 +3,37 @@ 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 -}} + {{- $rootContext := .rootContext -}} + {{- $secretObject := .object -}} - {{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.secret -}} - {{- $values = . -}} - {{- end -}} - {{ end -}} + {{- $labels := merge + ($secretObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($secretObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} - {{- if and (hasKey $values "nameOverride") $values.nameOverride -}} - {{- $secretName = printf "%v-%v" $secretName $values.nameOverride -}} - {{- end }} + {{- $stringData := "" -}} + {{- with $secretObject.stringData -}} + {{- $stringData = (toYaml $secretObject.stringData) | trim -}} + {{- end -}} --- apiVersion: v1 kind: Secret -{{- with $values.type }} +{{- with $secretObject.type }} type: {{ . }} {{- end }} metadata: - name: {{ $secretName }} - {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} - labels: {{- toYaml . | nindent 4 }} + name: {{ $secretObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - annotations: {{- toYaml . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} -{{- with $values.stringData }} -stringData: - {{- tpl (toYaml .) $ | nindent 2 }} +{{- with $stringData }} +stringData: {{- tpl $stringData $rootContext | nindent 2 }} {{- end }} {{- end -}} diff --git a/charts/library/common/templates/classes/_service.tpl b/charts/library/common/templates/classes/_service.tpl index d53184a9..de5d98e7 100644 --- a/charts/library/common/templates/classes/_service.tpl +++ b/charts/library/common/templates/classes/_service.tpl @@ -3,83 +3,80 @@ This template serves as a blueprint for all Service objects that are created within the common library. */}} {{- define "bjw-s.common.class.service" -}} -{{- $values := .Values.service -}} -{{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.service -}} - {{- $values = . -}} - {{- end -}} -{{ end -}} + {{- $rootContext := .rootContext -}} + {{- $serviceObject := .object -}} -{{- $serviceName := include "bjw-s.common.lib.chart.names.fullname" . -}} -{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} - {{- $serviceName = printf "%v-%v" $serviceName $values.nameOverride -}} -{{ end -}} -{{- $svcType := $values.type | default "" -}} -{{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "serviceName" $serviceName "values" $values) | fromYaml }} -{{- $primaryPort := get $values.ports (include "bjw-s.common.lib.service.primaryPort" (dict "values" $values)) }} + {{- $svcType := $serviceObject.type | default "" -}} + {{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "rootContext" $rootContext "serviceObject" $serviceObject) | fromYaml }} + {{- $labels := merge + (dict "app.kubernetes.io/service" $serviceObject.name) + ($serviceObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($serviceObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- apiVersion: v1 kind: Service metadata: - name: {{ $serviceName }} - labels: - app.kubernetes.io/service: {{ $serviceName }} - {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} - {{- toYaml . | nindent 4 }} - {{- end }} - annotations: - {{- if eq ( $primaryPort.protocol | default "" ) "HTTPS" }} - traefik.ingress.kubernetes.io/service.serversscheme: https + name: {{ $serviceObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - {{ toYaml . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} spec: {{- if (or (eq $svcType "ClusterIP") (empty $svcType)) }} type: ClusterIP - {{- if $values.clusterIP }} - clusterIP: {{ $values.clusterIP }} + {{- if $serviceObject.clusterIP }} + clusterIP: {{ $serviceObject.clusterIP }} {{end}} {{- else if eq $svcType "LoadBalancer" }} type: {{ $svcType }} - {{- if $values.loadBalancerIP }} - loadBalancerIP: {{ $values.loadBalancerIP }} + {{- if $serviceObject.loadBalancerIP }} + loadBalancerIP: {{ $serviceObject.loadBalancerIP }} {{- end }} - {{- if $values.loadBalancerSourceRanges }} + {{- if $serviceObject.loadBalancerSourceRanges }} loadBalancerSourceRanges: - {{ toYaml $values.loadBalancerSourceRanges | nindent 4 }} + {{ toYaml $serviceObject.loadBalancerSourceRanges | nindent 4 }} {{- end -}} {{- else }} type: {{ $svcType }} {{- end }} - {{- if $values.externalTrafficPolicy }} - externalTrafficPolicy: {{ $values.externalTrafficPolicy }} + {{- if $serviceObject.externalTrafficPolicy }} + externalTrafficPolicy: {{ $serviceObject.externalTrafficPolicy }} {{- end }} - {{- if $values.sessionAffinity }} - sessionAffinity: {{ $values.sessionAffinity }} - {{- if $values.sessionAffinityConfig }} + {{- if hasKey $serviceObject "allocateLoadBalancerNodePorts" }} + allocateLoadBalancerNodePorts: {{ $serviceObject.allocateLoadBalancerNodePorts }} + {{- end }} + {{- if $serviceObject.sessionAffinity }} + sessionAffinity: {{ $serviceObject.sessionAffinity }} + {{- if $serviceObject.sessionAffinityConfig }} sessionAffinityConfig: - {{ toYaml $values.sessionAffinityConfig | nindent 4 }} + {{ toYaml $serviceObject.sessionAffinityConfig | nindent 4 }} {{- end -}} {{- end }} - {{- with $values.externalIPs }} + {{- with $serviceObject.externalIPs }} externalIPs: {{- toYaml . | nindent 4 }} {{- end }} - {{- if $values.publishNotReadyAddresses }} - publishNotReadyAddresses: {{ $values.publishNotReadyAddresses }} + {{- if $serviceObject.publishNotReadyAddresses }} + publishNotReadyAddresses: {{ $serviceObject.publishNotReadyAddresses }} {{- end }} - {{- if $values.ipFamilyPolicy }} - ipFamilyPolicy: {{ $values.ipFamilyPolicy }} + {{- if $serviceObject.ipFamilyPolicy }} + ipFamilyPolicy: {{ $serviceObject.ipFamilyPolicy }} {{- end }} - {{- with $values.ipFamilies }} + {{- with $serviceObject.ipFamilies }} ipFamilies: {{ toYaml . | nindent 4 }} {{- end }} ports: {{- range $name, $port := $enabledPorts }} - port: {{ $port.port }} - targetPort: {{ $port.targetPort | default $name }} + targetPort: {{ $port.targetPort | default $port.port }} {{- if $port.protocol }} {{- if or ( eq $port.protocol "HTTP" ) ( eq $port.protocol "HTTPS" ) ( eq $port.protocol "TCP" ) }} protocol: TCP @@ -94,7 +91,11 @@ spec: nodePort: {{ $port.nodePort }} {{ end }} {{- end -}} - {{- with (merge ($values.extraSelectorLabels | default dict) (include "bjw-s.common.lib.metadata.selectorLabels" . | fromYaml)) }} + {{- with (merge + ($serviceObject.extraSelectorLabels | default dict) + (dict "app.kubernetes.io/component" $serviceObject.controller) + (include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | fromYaml) + ) }} selector: {{- toYaml . | nindent 4 }} {{- end }} {{- end }} diff --git a/charts/library/common/templates/classes/_serviceAccount.tpl b/charts/library/common/templates/classes/_serviceAccount.tpl index 7f806857..2b109ad0 100644 --- a/charts/library/common/templates/classes/_serviceAccount.tpl +++ b/charts/library/common/templates/classes/_serviceAccount.tpl @@ -3,17 +3,28 @@ This template serves as a blueprint for ServiceAccount objects that are created using the common library. */}} {{- define "bjw-s.common.class.serviceAccount" -}} + {{- $rootContext := .rootContext -}} + {{- $serviceAccountObject := .object -}} + + {{- $labels := merge + ($serviceAccountObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($serviceAccountObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "bjw-s.common.lib.chart.names.serviceAccountName" . }} - {{- with include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml }} - labels: {{- toYaml . | nindent 4 }} + name: {{ $serviceAccountObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with (merge (.Values.serviceAccount.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - annotations: {{- toYaml . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} secrets: - - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }}-sa-token + - name: {{ include "bjw-s.common.lib.chart.names.fullname" $rootContext }}-sa-token {{- end -}} diff --git a/charts/library/common/templates/classes/_serviceMonitor.tpl b/charts/library/common/templates/classes/_serviceMonitor.tpl index 0611000e..ee7238d4 100644 --- a/charts/library/common/templates/classes/_serviceMonitor.tpl +++ b/charts/library/common/templates/classes/_serviceMonitor.tpl @@ -1,34 +1,33 @@ {{- define "bjw-s.common.class.serviceMonitor" -}} -{{- $values := dict -}} -{{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.serviceMonitor -}} - {{- $values = . -}} - {{- end -}} -{{ end -}} - -{{- $serviceMonitorName := include "bjw-s.common.lib.chart.names.fullname" . -}} -{{- if and (hasKey $values "nameOverride") $values.nameOverride -}} - {{- $serviceMonitorName = printf "%v-%v" $serviceMonitorName $values.nameOverride -}} -{{ end -}} + {{- $rootContext := .rootContext -}} + {{- $serviceMonitorObject := .object -}} + {{- $labels := merge + ($serviceMonitorObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($serviceMonitorObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: - name: {{ $serviceMonitorName }} - {{- with (merge ($values.labels | default dict) (include "bjw-s.common.lib.metadata.allLabels" $ | fromYaml)) }} - labels: {{- toYaml . | nindent 4 }} + name: {{ $serviceMonitorObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with (merge ($values.annotations | default dict) (include "bjw-s.common.lib.metadata.globalAnnotations" $ | fromYaml)) }} - annotations: {{- toYaml . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} spec: selector: - {{- if $values.selector -}} - {{- tpl ($values.selector | toYaml) $ | nindent 4}} + {{- if $serviceMonitorObject.selector -}} + {{- tpl ($serviceMonitorObject.selector | toYaml) $rootContext | nindent 4}} {{- else }} matchLabels: - app.kubernetes.io/service: {{ tpl $values.serviceName $ }} - {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }} + app.kubernetes.io/service: {{ tpl $serviceMonitorObject.serviceName $rootContext }} + {{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }} {{- end }} - endpoints: {{- toYaml (required (printf "endpoints are required for serviceMonitor %v" $serviceMonitorName) $values.endpoints) | nindent 4 }} + endpoints: {{- toYaml $serviceMonitorObject.endpoints | nindent 4 }} {{- end }} diff --git a/charts/library/common/templates/classes/_statefulset.tpl b/charts/library/common/templates/classes/_statefulset.tpl index a9ede417..66adcf8d 100644 --- a/charts/library/common/templates/classes/_statefulset.tpl +++ b/charts/library/common/templates/classes/_statefulset.tpl @@ -3,66 +3,54 @@ This template serves as the blueprint for the StatefulSet objects that are creat 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 -}} + {{- $rootContext := .rootContext -}} + {{- $statefulsetObject := .object -}} + + {{- $labels := merge + (dict "app.kubernetes.io/component" $statefulsetObject.identifier) + ($statefulsetObject.labels | default dict) + (include "bjw-s.common.lib.metadata.allLabels" $rootContext | fromYaml) + -}} + {{- $annotations := merge + ($statefulsetObject.annotations | default dict) + (include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml) + -}} --- 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 }} + name: {{ $statefulsetObject.name }} + {{- with $labels }} + labels: {{- toYaml . | nindent 4 -}} {{- end }} - {{- with include "bjw-s.common.lib.controller.metadata.annotations" . }} - annotations: {{- . | nindent 4 }} + {{- with $annotations }} + annotations: {{- toYaml . | nindent 4 -}} {{- end }} spec: - revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }} - replicas: {{ .Values.controller.replicas }} - podManagementPolicy: {{ default "OrderedReady" .Values.controller.podManagementPolicy }} + revisionHistoryLimit: {{ $statefulsetObject.revisionHistoryLimit }} + replicas: {{ $statefulsetObject.replicas }} + podManagementPolicy: {{ default "OrderedReady" $statefulsetObject.statefulset.podManagementPolicy }} updateStrategy: - type: {{ $strategy }} - {{- if and (eq $strategy "RollingUpdate") .Values.controller.rollingUpdate.partition }} + type: {{ $statefulsetObject.strategy }} + {{- if and (eq $statefulsetObject.strategy "RollingUpdate") $statefulsetObject.rollingUpdate.partition }} rollingUpdate: - partition: {{ .Values.controller.rollingUpdate.partition }} + partition: {{ $statefulsetObject.rollingUpdate.partition }} {{- end }} selector: matchLabels: - {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }} - serviceName: {{ include "bjw-s.common.lib.chart.names.fullname" . }} + app.kubernetes.io/component: {{ $statefulsetObject.identifier }} + {{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }} + serviceName: {{ include "bjw-s.common.lib.chart.names.fullname" $rootContext }} template: metadata: - {{- with include ("bjw-s.common.lib.metadata.podAnnotations") . }} - annotations: - {{- . | nindent 8 }} + {{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $statefulsetObject)) }} + annotations: {{ . | nindent 8 }} + {{- end -}} + {{- with (include "bjw-s.common.lib.pod.metadata.labels" (dict "rootContext" $rootContext "controllerObject" $statefulsetObject)) }} + labels: {{ . | 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 }} + spec: {{ include "bjw-s.common.lib.pod.spec" (dict "rootContext" $rootContext "controllerObject" $statefulsetObject) | nindent 6 }} + {{- with (include "bjw-s.common.lib.statefulset.volumeclaimtemplates" (dict "rootContext" $rootContext "statefulsetObject" $statefulsetObject)) }} + volumeClaimTemplates: {{ . | nindent 4 }} + {{- end }} {{- end }} diff --git a/charts/library/common/templates/lib/chart/_names.tpl b/charts/library/common/templates/lib/chart/_names.tpl index 38451ce8..15725e51 100644 --- a/charts/library/common/templates/lib/chart/_names.tpl +++ b/charts/library/common/templates/lib/chart/_names.tpl @@ -1,10 +1,9 @@ {{/* Expand the name of the chart */}} {{- define "bjw-s.common.lib.chart.names.name" -}} - {{- $globalNameOverride := "" -}} - {{- if hasKey .Values "global" -}} - {{- $globalNameOverride = (default $globalNameOverride .Values.global.nameOverride) -}} - {{- end -}} - {{- default .Chart.Name (default .Values.nameOverride $globalNameOverride) | trunc 63 | trimSuffix "-" -}} + {{- $globalNameOverride := get .Values.global "nameOverride" -}} + {{- $nameOverride := get .Values "nameOverride" -}} + {{- $name := $globalNameOverride | default $nameOverride | default .Chart.Name -}} + {{- $name | toString | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* @@ -14,12 +13,11 @@ If release name contains chart name it will be used as a full name. */}} {{- define "bjw-s.common.lib.chart.names.fullname" -}} {{- $name := include "bjw-s.common.lib.chart.names.name" . -}} - {{- $globalFullNameOverride := "" -}} - {{- if hasKey .Values "global" -}} - {{- $globalFullNameOverride = (default $globalFullNameOverride .Values.global.fullnameOverride) -}} - {{- end -}} - {{- if or .Values.fullnameOverride $globalFullNameOverride -}} - {{- $name = default .Values.fullnameOverride $globalFullNameOverride -}} + {{- $globalFullNameOverride := get .Values.global "fullnameOverride" -}} + {{- $fullNameOverride := get .Values "fullnameOverride" -}} + + {{- if or $fullNameOverride $globalFullNameOverride -}} + {{- $name = ($globalFullNameOverride | default $fullNameOverride) -}} {{- else -}} {{- if contains $name .Release.Name -}} {{- $name = .Release.Name -}} @@ -27,19 +25,11 @@ If release name contains chart name it will be used as a full name. {{- $name = printf "%s-%s" .Release.Name $name -}} {{- end -}} {{- end -}} - {{- trunc 63 $name | trimSuffix "-" -}} + + {{- $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* Create chart name and version as used by the chart label */}} {{- define "bjw-s.common.lib.chart.names.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} - -{{/* Create the name of the ServiceAccount to use */}} -{{- define "bjw-s.common.lib.chart.names.serviceAccountName" -}} - {{- if .Values.serviceAccount.create -}} - {{- default (include "bjw-s.common.lib.chart.names.fullname" .) .Values.serviceAccount.name -}} - {{- else -}} - {{- default "default" .Values.serviceAccount.name -}} - {{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/configMap/_validate.tpl b/charts/library/common/templates/lib/configMap/_validate.tpl new file mode 100644 index 00000000..c61c7044 --- /dev/null +++ b/charts/library/common/templates/lib/configMap/_validate.tpl @@ -0,0 +1,7 @@ +{{/* +Validate configMap values +*/}} +{{- define "bjw-s.common.lib.configMap.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $configMapValues := .object -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/configMap/_valuesToObject.tpl b/charts/library/common/templates/lib/configMap/_valuesToObject.tpl new file mode 100644 index 00000000..1cad8833 --- /dev/null +++ b/charts/library/common/templates/lib/configMap/_valuesToObject.tpl @@ -0,0 +1,24 @@ +{{/* +Convert configMap values to an object +*/}} +{{- define "bjw-s.common.lib.configMap.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the configMap name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.nameOverride -}} + {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} + {{- else -}} + {{- if ne $identifier "main" -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} + {{- end -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the configMap object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/_containerImage.tpl b/charts/library/common/templates/lib/container/_containerImage.tpl deleted file mode 100644 index dd134634..00000000 --- a/charts/library/common/templates/lib/container/_containerImage.tpl +++ /dev/null @@ -1,15 +0,0 @@ -{{/* -Image used by the main container. -*/}} -{{- define "bjw-s.common.lib.container.image" -}} - {{- $imageRepo := .Values.image.repository -}} - {{- $imageTag := default .Chart.AppVersion .Values.image.tag -}} - - {{- if kindIs "float64" .Values.image.tag -}} - {{- $imageTag = .Values.image.tag | toString -}} - {{- end -}} - - {{- if and $imageRepo $imageTag -}} - {{- printf "%s:%s" $imageRepo $imageTag -}} - {{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/container/_env_vars.tpl b/charts/library/common/templates/lib/container/_env_vars.tpl deleted file mode 100644 index f4b4cf2c..00000000 --- a/charts/library/common/templates/lib/container/_env_vars.tpl +++ /dev/null @@ -1,43 +0,0 @@ -{{/* -Environment variables used by containers. -*/}} -{{- define "bjw-s.common.lib.container.envVars" -}} - {{- $values := .Values.env -}} - {{- if hasKey . "ObjectValues" -}} - {{- with .ObjectValues.envVars -}} - {{- $values = . -}} - {{- end -}} - {{- end -}} - - {{- with $values -}} - {{- $result := list -}} - {{- range $k, $v := . -}} - {{- $name := $k -}} - {{- $value := $v -}} - {{- if kindIs "int" $name -}} - {{- $name = required "environment variables as a list of maps require a name field" $value.name -}} - {{- end -}} - - {{- if kindIs "map" $value -}} - {{- if hasKey $value "value" -}} - {{- $envValue := $value.value | toString -}} - {{- $result = append $result (dict "name" $name "value" (tpl $envValue $)) -}} - {{- else if hasKey $value "valueFrom" -}} - {{- $result = append $result (dict "name" $name "valueFrom" $value.valueFrom) -}} - {{- else -}} - {{- $result = append $result (dict "name" $name "valueFrom" $value) -}} - {{- end -}} - {{- end -}} - {{- if not (kindIs "map" $value) -}} - {{- if kindIs "string" $value -}} - {{- $result = append $result (dict "name" $name "value" (tpl $value $)) -}} - {{- else if or (kindIs "float64" $value) (kindIs "bool" $value) -}} - {{- $result = append $result (dict "name" $name "value" ($value | toString)) -}} - {{- else -}} - {{- $result = append $result (dict "name" $name "value" $value) -}} - {{- end -}} - {{- end -}} - {{- end -}} - {{- toYaml (dict "env" $result) | nindent 0 -}} - {{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/container/_ports.tpl b/charts/library/common/templates/lib/container/_ports.tpl deleted file mode 100644 index 69cdec61..00000000 --- a/charts/library/common/templates/lib/container/_ports.tpl +++ /dev/null @@ -1,41 +0,0 @@ -{{/* -Ports included by the controller. -*/}} -{{- define "bjw-s.common.lib.container.ports" -}} - {{- $ports := list -}} - {{- range $servicename, $service := .Values.service -}} - {{- $serviceEnabled := true -}} - {{- if hasKey $service "enabled" -}} - {{- $serviceEnabled = $service.enabled -}} - {{- end -}} - {{- if $serviceEnabled -}} - {{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "serviceName" $servicename "values" $service) | fromYaml }} - {{- range $portname, $port := ($enabledPorts | default dict) -}} - {{- $_ := set $port "name" $portname -}} - {{- $ports = mustAppend $ports $port -}} - {{- end -}} - {{- end -}} - {{- end -}} - -{{/* export/render the list of ports */}} -{{- if $ports -}} -{{- range $_ := $ports }} -{{- if default true .enabled | }} -- name: {{ .name }} - {{- if and .targetPort (kindIs "string" .targetPort) }} - {{- fail (printf "Our charts do not support named ports for targetPort. (port name %s, targetPort %s)" .name .targetPort) }} - {{- end }} - containerPort: {{ .targetPort | default .port }} - {{- if .protocol }} - {{- if or ( eq .protocol "HTTP" ) ( eq .protocol "HTTPS" ) ( eq .protocol "TCP" ) }} - protocol: TCP - {{- else }} - protocol: {{ .protocol }} - {{- end }} - {{- else }} - protocol: TCP - {{- end }} -{{- end}} -{{- end -}} -{{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/container/_probes.tpl b/charts/library/common/templates/lib/container/_probes.tpl deleted file mode 100644 index 5e5d9c6a..00000000 --- a/charts/library/common/templates/lib/container/_probes.tpl +++ /dev/null @@ -1,67 +0,0 @@ -{{/* -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 -}} - {{- $probeOutput := "" -}} - {{- if $probe.custom -}} - {{- if $probe.spec -}} - {{- $probeOutput = $probe.spec | toYaml -}} - {{- end -}} - {{- else -}} - {{- if $primaryPort -}} - {{- $probeType := "" -}} - {{- if eq $probe.type "AUTO" -}} - {{- $probeType = $primaryPort.protocol -}} - {{- else -}} - {{- $probeType = $probe.type | default "TCP" -}} - {{- end -}} - - {{- $probeDefinition := dict - "initialDelaySeconds" $probe.spec.initialDelaySeconds - "failureThreshold" $probe.spec.failureThreshold - "timeoutSeconds" $probe.spec.timeoutSeconds - "periodSeconds" $probe.spec.periodSeconds - -}} - - {{- $probeHeader := "" -}} - {{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}} - {{- $probeHeader = "httpGet" -}} - - {{- $_ := set $probeDefinition $probeHeader ( - dict - "path" $probe.path - "scheme" $probeType - ) - -}} - {{- else }} - {{- $probeHeader = "tcpSocket" -}} - {{- $_ := set $probeDefinition $probeHeader dict -}} - {{- end -}} - - {{- if $probe.port }} - {{- $_ := set (index $probeDefinition $probeHeader) "port" (tpl ( $probe.port | toString ) $) -}} - {{- else if $primaryPort.targetPort }} - {{- $_ := set (index $probeDefinition $probeHeader) "port" $primaryPort.targetPort -}} - {{- else }} - {{- $_ := set (index $probeDefinition $probeHeader) "port" ($primaryPort.port | toString | atoi ) -}} - {{- end }} - - {{- $probeOutput = $probeDefinition | toYaml | trim -}} - {{- end -}} - {{- end -}} - - {{- if $probeOutput -}} - {{- printf "%sProbe:" $probeName | nindent 0 -}} - {{- $probeOutput | nindent 2 -}} - {{- end -}} - {{- end -}} - {{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/container/_spec.tpl b/charts/library/common/templates/lib/container/_spec.tpl new file mode 100644 index 00000000..acf746bf --- /dev/null +++ b/charts/library/common/templates/lib/container/_spec.tpl @@ -0,0 +1,51 @@ +{{- /* +The container definition included in the Pod. +*/ -}} +{{- define "bjw-s.common.lib.container.spec" -}} + {{- $rootContext := .rootContext -}} + {{- $controllerObject := .controllerObject -}} + {{- $containerObject := .containerObject -}} + {{- $ctx := dict "rootContext" $rootContext "controllerObject" $controllerObject "containerObject" $containerObject -}} + +name: {{ include "bjw-s.common.lib.container.field.name" (dict "ctx" $ctx) | trim }} +image: {{ include "bjw-s.common.lib.container.field.image" (dict "ctx" $ctx) | trim }} + {{- with $containerObject.image.pullPolicy }} +imagePullPolicy: {{ . | trim }} + {{- end -}} + {{- with (include "bjw-s.common.lib.container.field.command" (dict "ctx" $ctx) | trim) }} +command: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with (include "bjw-s.common.lib.container.field.args" (dict "ctx" $ctx) | trim) }} +args: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with $containerObject.securityContext }} +securityContext: {{ toYaml . | trim | nindent 2 }} + {{- end -}} + {{- with $containerObject.lifecycle }} +lifecycle: {{ toYaml . | trim | nindent 2 }} + {{- end -}} + {{- with $containerObject.terminationMessagePath }} +terminationMessagePath: {{ . | trim }} + {{- end -}} + {{- with $containerObject.terminationMessagePolicy }} +terminationMessagePolicy: {{ . | trim }} + {{- end -}} + {{- with (include "bjw-s.common.lib.container.field.env" (dict "ctx" $ctx) | trim) }} +env: {{ . | trim | nindent 2 }} + {{- end -}} +{{- with $containerObject.envFrom }} +envFrom: {{ toYaml . | trim | nindent 2 }} + {{- end -}} + {{- with $containerObject.ports }} +ports: {{ toYaml . | trim | nindent 2 }} + {{- end -}} + {{- with (include "bjw-s.common.lib.container.field.probes" (dict "ctx" $ctx) | trim) }} + {{- . | trim | nindent 0 -}} + {{- end -}} + {{- with $containerObject.resources }} +resources: {{ toYaml . | trim | nindent 2 }} + {{- end -}} + {{- with (include "bjw-s.common.lib.container.field.volumeMounts" (dict "ctx" $ctx) | trim) }} +volumeMounts: {{ . | trim | nindent 2 }} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/_validate.tpl b/charts/library/common/templates/lib/container/_validate.tpl new file mode 100644 index 00000000..c8cbbf27 --- /dev/null +++ b/charts/library/common/templates/lib/container/_validate.tpl @@ -0,0 +1,11 @@ +{{/* +Validate container values +*/}} +{{- define "bjw-s.common.lib.container.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $containerValues := .object -}} + + {{- if eq (dig "image" "repository" "" $containerValues) "" -}} + {{- fail (printf "No image repository specified for container. (controller: %s, container: %s)" $containerValues.controller $containerValues.identifier) }} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/_valuesToObject.tpl b/charts/library/common/templates/lib/container/_valuesToObject.tpl new file mode 100644 index 00000000..e13104de --- /dev/null +++ b/charts/library/common/templates/lib/container/_valuesToObject.tpl @@ -0,0 +1,13 @@ +{{/* +Convert container values to an object +*/}} +{{- define "bjw-s.common.lib.container.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the container object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/_volumemounts.tpl b/charts/library/common/templates/lib/container/_volumemounts_old.tpl similarity index 98% rename from charts/library/common/templates/lib/container/_volumemounts.tpl rename to charts/library/common/templates/lib/container/_volumemounts_old.tpl index 63d45229..4e60be2a 100644 --- a/charts/library/common/templates/lib/container/_volumemounts.tpl +++ b/charts/library/common/templates/lib/container/_volumemounts_old.tpl @@ -1,3 +1,5 @@ + {{- /* TODO: Remove this file */ -}} + {{/* Volumes included by the controller */}} {{- define "bjw-s.common.lib.container.volumeMounts" -}} {{- range $persistenceIndex, $persistenceItem := .Values.persistence }} diff --git a/charts/library/common/templates/lib/container/fields/_args.tpl b/charts/library/common/templates/lib/container/fields/_args.tpl new file mode 100644 index 00000000..172e444e --- /dev/null +++ b/charts/library/common/templates/lib/container/fields/_args.tpl @@ -0,0 +1,26 @@ +{{/* +Args used by the container. +*/}} +{{- define "bjw-s.common.lib.container.field.args" -}} + {{- $ctx := .ctx -}} + {{- $containerObject := $ctx.containerObject -}} + + {{- /* 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 -}} + {{- end -}} + {{- end -}} + + {{- if not (empty $args) -}} + {{- $args | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/fields/_command.tpl b/charts/library/common/templates/lib/container/fields/_command.tpl new file mode 100644 index 00000000..67e3b65b --- /dev/null +++ b/charts/library/common/templates/lib/container/fields/_command.tpl @@ -0,0 +1,26 @@ +{{/* +Command used by the container. +*/}} +{{- define "bjw-s.common.lib.container.field.command" -}} + {{- $ctx := .ctx -}} + {{- $containerObject := $ctx.containerObject -}} + + {{- /* 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 -}} + {{- end -}} + {{- end -}} + + {{- if not (empty $command) -}} + {{- $command | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/fields/_env.tpl b/charts/library/common/templates/lib/container/fields/_env.tpl new file mode 100644 index 00000000..4660e4be --- /dev/null +++ b/charts/library/common/templates/lib/container/fields/_env.tpl @@ -0,0 +1,45 @@ +{{/* +Env field used by the container. +*/}} +{{- define "bjw-s.common.lib.container.field.env" -}} + {{- $ctx := .ctx -}} + {{- $rootContext := $ctx.rootContext -}} + {{- $containerObject := $ctx.containerObject -}} + + {{- /* Default to empty list */ -}} + {{- $env := list -}} + + {{- /* See if an override is desired */ -}} + {{- if not (empty (get $containerObject "env")) -}} + {{- with $containerObject.env -}} + {{- range $name, $value := . -}} + {{- if kindIs "int" $name -}} + {{- $name = required "environment variables as a list of maps require a name field" $value.name -}} + {{- end -}} + + {{- if kindIs "map" $value -}} + {{- if hasKey $value "value" -}} + {{- $envValue := $value.value | toString -}} + {{- $env = append $env (dict "name" $name "value" (tpl $envValue $rootContext)) -}} + {{- else if hasKey $value "valueFrom" -}} + {{- $env = append $env (dict "name" $name "valueFrom" $value.valueFrom) -}} + {{- else -}} + {{- $env = append $env (dict "name" $name "valueFrom" $value) -}} + {{- end -}} + {{- else -}} + {{- if kindIs "string" $value -}} + {{- $env = append $env (dict "name" $name "value" (tpl $value $rootContext)) -}} + {{- else if or (kindIs "float64" $value) (kindIs "bool" $value) -}} + {{- $env = append $env (dict "name" $name "value" ($value | toString)) -}} + {{- else -}} + {{- $env = append $env (dict "name" $name "value" $value) -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- if not (empty $env) -}} + {{- $env | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/fields/_image.tpl b/charts/library/common/templates/lib/container/fields/_image.tpl new file mode 100644 index 00000000..0dc989b5 --- /dev/null +++ b/charts/library/common/templates/lib/container/fields/_image.tpl @@ -0,0 +1,19 @@ +{{/* +Image used by the container. +*/}} +{{- define "bjw-s.common.lib.container.field.image" -}} + {{- $ctx := .ctx -}} + {{- $rootContext := $ctx.rootContext -}} + {{- $containerObject := $ctx.containerObject -}} + + {{- $imageRepo := $containerObject.image.repository -}} + {{- $imageTag := default $rootContext.Chart.AppVersion $containerObject.image.tag -}} + + {{- if kindIs "float64" $imageTag -}} + {{- $imageTag = $imageTag | toString -}} + {{- end -}} + + {{- if and $imageRepo $imageTag -}} + {{- printf "%s:%s" $imageRepo $imageTag -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/fields/_name.tpl b/charts/library/common/templates/lib/container/fields/_name.tpl new file mode 100644 index 00000000..7695f39b --- /dev/null +++ b/charts/library/common/templates/lib/container/fields/_name.tpl @@ -0,0 +1,24 @@ +{{/* +Name used by the container. +*/}} +{{- define "bjw-s.common.lib.container.field.name" -}} + {{- $ctx := .ctx -}} + {{- $rootContext := $ctx.rootContext -}} + {{- $containerObject := $ctx.containerObject -}} + + {{- /* Default to container identifier */ -}} + {{- $name := $containerObject.identifier -}} + + {{- /* See if an override is desired */ -}} + {{- if hasKey $containerObject "nameOverride" -}} + {{- $option := get $containerObject "nameOverride" -}} + {{- if not (empty $option) -}} + {{- $name = $option -}} + {{- end -}} + {{- end -}} + + {{- /* Parse any templates */ -}} + {{- $name = tpl $name $rootContext -}} + + {{- $name | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/fields/_probes.tpl b/charts/library/common/templates/lib/container/fields/_probes.tpl new file mode 100644 index 00000000..327b6cac --- /dev/null +++ b/charts/library/common/templates/lib/container/fields/_probes.tpl @@ -0,0 +1,79 @@ +{{/* +Probes used by the container. +*/}} +{{- define "bjw-s.common.lib.container.field.probes" -}} + {{- $ctx := .ctx -}} + {{- $rootContext := $ctx.rootContext -}} + {{- $controllerObject := $ctx.controllerObject -}} + {{- $containerObject := $ctx.containerObject -}} + + {{- /* Default to empty dict */ -}} + {{- $enabledProbes := dict -}} + + {{- range $probeName, $probeValues := $containerObject.probes -}} + {{- /* Disable probe by default, but allow override */ -}} + {{- $probeEnabled := false -}} + {{- if hasKey $probeValues "enabled" -}} + {{- $probeEnabled = $probeValues.enabled -}} + {{- end -}} + + {{- if $probeEnabled -}} + {{- $probeDefinition := dict -}} + + {{- if $probeValues.custom -}} + {{- $parsedProbeSpec := tpl ($probeValues.spec | toYaml) $rootContext -}} + {{- $probeDefinition = $parsedProbeSpec | fromYaml -}} + {{- else -}} + {{- $primaryService := include "bjw-s.common.lib.service.primaryForController" (dict "rootContext" $rootContext "controllerIdentifier" $controllerObject.identifier) | fromYaml -}} + {{- $primaryServiceDefaultPort := dict -}} + {{- if $primaryService -}} + {{- $primaryServiceDefaultPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $primaryService) | fromYaml -}} + {{- end -}} + {{- if $primaryServiceDefaultPort -}} + {{- $probeType := "" -}} + {{- if eq $probeValues.type "AUTO" -}} + {{- $probeType = $primaryServiceDefaultPort.protocol -}} + {{- else -}} + {{- $probeType = $probeValues.type | default "TCP" -}} + {{- end -}} + + {{- $_ := set $probeDefinition "initialDelaySeconds" $probeValues.spec.initialDelaySeconds -}} + {{- $_ := set $probeDefinition "failureThreshold" $probeValues.spec.failureThreshold -}} + {{- $_ := set $probeDefinition "timeoutSeconds" $probeValues.spec.timeoutSeconds -}} + {{- $_ := set $probeDefinition "periodSeconds" $probeValues.spec.periodSeconds -}} + + {{- $probeHeader := "" -}} + {{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}} + {{- $probeHeader = "httpGet" -}} + + {{- $_ := set $probeDefinition $probeHeader ( + dict + "path" $probeValues.path + "scheme" $probeType + ) + -}} + {{- else }} + {{- $probeHeader = "tcpSocket" -}} + {{- $_ := set $probeDefinition $probeHeader dict -}} + {{- end -}} + + {{- if $probeValues.port -}} + {{- $_ := set (index $probeDefinition $probeHeader) "port" (tpl ( $probeValues.port | toString ) $rootContext) -}} + {{- else if $primaryServiceDefaultPort.targetPort -}} + {{- $_ := set (index $probeDefinition $probeHeader) "port" $primaryServiceDefaultPort.targetPort -}} + {{- else -}} + {{- $_ := set (index $probeDefinition $probeHeader) "port" ($primaryServiceDefaultPort.port | toString | atoi ) -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- if $probeDefinition -}} + {{- $_ := set $enabledProbes (printf "%sProbe" $probeName) $probeDefinition -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- with $enabledProbes -}} + {{- . | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/container/fields/_volumeMounts.tpl b/charts/library/common/templates/lib/container/fields/_volumeMounts.tpl new file mode 100644 index 00000000..44e70254 --- /dev/null +++ b/charts/library/common/templates/lib/container/fields/_volumeMounts.tpl @@ -0,0 +1,77 @@ +{{/* +volumeMounts used by the container. +*/}} +{{- define "bjw-s.common.lib.container.field.volumeMounts" -}} + {{- $ctx := .ctx -}} + {{- $rootContext := $ctx.rootContext -}} + {{- $controllerObject := $ctx.controllerObject -}} + {{- $containerObject := $ctx.containerObject -}} + + {{- /* Default to empty dict */ -}} + {{- $persistenceItemsToProcess := dict -}} + {{- $enabledVolumeMounts := list -}} + + {{- range $identifier, $persistenceValues := $rootContext.Values.persistence -}} + {{- /* Enable persistence item by default, but allow override */ -}} + {{- $persistenceEnabled := true -}} + {{- if hasKey $persistenceValues "enabled" -}} + {{- $persistenceEnabled = $persistenceValues.enabled -}} + {{- end -}} + + {{- if $persistenceEnabled -}} + {{- /* Set some default values */ -}} + + {{- /* Set the default mountPath to / */ -}} + {{- $mountPath := (printf "/%v" $identifier) -}} + {{- if eq "hostPath" (default "pvc" $persistenceValues.type) -}} + {{- $mountPath = $persistenceValues.hostPath -}} + {{- end -}} + + {{- /* Process configured mounts */ -}} + {{- if or .globalMounts .advancedMounts -}} + {{- $mounts := list -}} + {{- if hasKey . "globalMounts" -}} + {{- $mounts = .globalMounts -}} + {{- else if hasKey . "advancedMounts" -}} + {{- $mounts = dig $controllerObject.identifier $containerObject.identifier list .advancedMounts -}} + {{- end -}} + + {{- range $mounts -}} + {{- $volumeMount := dict -}} + {{- $_ := set $volumeMount "name" $identifier -}} + + {{- /* Use the specified mountPath if provided */ -}} + {{- with .path -}} + {{- $mountPath = . -}} + {{- end -}} + {{- $_ := set $volumeMount "mountPath" $mountPath -}} + + {{- /* Use the specified subPath if provided */ -}} + {{- with .subPath -}} + {{- $subPath := . -}} + {{- $_ := set $volumeMount "subPath" $subPath -}} + {{- end -}} + + {{- /* Use the specified readOnly setting if provided */ -}} + {{- with .readOnly -}} + {{- $readOnly := . -}} + {{- $_ := set $volumeMount "readOnly" $readOnly -}} + {{- end -}} + + {{- $enabledVolumeMounts = append $enabledVolumeMounts $volumeMount -}} + {{- end -}} + + {{- /* Mount to default path if no mounts are configured */ -}} + {{- else -}} + {{- $volumeMount := dict -}} + {{- $_ := set $volumeMount "name" $identifier -}} + {{- $_ := set $volumeMount "mountPath" $mountPath -}} + {{- $enabledVolumeMounts = append $enabledVolumeMounts $volumeMount -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- with $enabledVolumeMounts -}} + {{- . | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/controller/_enabled_containers.tpl b/charts/library/common/templates/lib/controller/_enabled_containers.tpl new file mode 100644 index 00000000..9835c006 --- /dev/null +++ b/charts/library/common/templates/lib/controller/_enabled_containers.tpl @@ -0,0 +1,24 @@ +{{/* +Return the enabled containers for a controller. +*/}} +{{- define "bjw-s.common.lib.controller.enabledContainers" -}} + {{- $rootContext := .rootContext -}} + {{- $controllerObject := .controllerObject -}} + + {{- $enabledContainers := dict -}} + {{- range $name, $container := $controllerObject.containers -}} + {{- if kindIs "map" $container -}} + {{- /* Enable container by default, but allow override */ -}} + {{- $containerEnabled := true -}} + {{- if hasKey $container "enabled" -}} + {{- $containerEnabled = $container.enabled -}} + {{- end -}} + + {{- if $containerEnabled -}} + {{- $_ := set $enabledContainers $name . -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- $enabledContainers | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/controller/_mainContainer.tpl b/charts/library/common/templates/lib/controller/_mainContainer.tpl deleted file mode 100644 index 567ee609..00000000 --- a/charts/library/common/templates/lib/controller/_mainContainer.tpl +++ /dev/null @@ -1,58 +0,0 @@ -{{- /* The main container included in the controller */ -}} -{{- define "bjw-s.common.lib.controller.mainContainer" -}} -- name: {{ include "bjw-s.common.lib.chart.names.fullname" . }} - image: {{ include "bjw-s.common.lib.container.image" . }} - imagePullPolicy: {{ .Values.image.pullPolicy }} - {{- with .Values.command }} - command: - {{- if kindIs "string" . }} - - {{ . | quote }} - {{- else }} - {{ toYaml . | nindent 4 }} - {{- end }} - {{- end }} - {{- with .Values.args }} - args: - {{- if kindIs "string" . }} - - {{ . | quote }} - {{- else }} - {{ toYaml . | nindent 4 }} - {{- end }} - {{- end }} - {{- with .Values.securityContext }} - securityContext: - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.lifecycle }} - lifecycle: - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with .Values.termination.messagePath }} - terminationMessagePath: {{ . }} - {{- end }} - {{- with .Values.termination.messagePolicy }} - terminationMessagePolicy: {{ . }} - {{- end }} - - {{- with .Values.env }} - env: - {{- get (fromYaml (include "bjw-s.common.lib.container.envVars" $)) "env" | toYaml | nindent 4 -}} - {{- end }} - {{- with .Values.envFrom }} - envFrom: - {{- toYaml . | nindent 4 }} - {{- end }} - {{- with (include "bjw-s.common.lib.container.ports" . | trim) }} - ports: - {{- nindent 4 . }} - {{- end }} - {{- with (include "bjw-s.common.lib.container.volumeMounts" . | trim) }} - volumeMounts: - {{- nindent 4 . }} - {{- end }} - {{- include "bjw-s.common.lib.container.probes" . | trim | nindent 2 }} - {{- with .Values.resources }} - resources: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end -}} diff --git a/charts/library/common/templates/lib/controller/_pod.tpl b/charts/library/common/templates/lib/controller/_pod.tpl deleted file mode 100644 index 333ab4ad..00000000 --- a/charts/library/common/templates/lib/controller/_pod.tpl +++ /dev/null @@ -1,114 +0,0 @@ -{{- /* -The pod definition included in the controller. -*/ -}} -{{- define "bjw-s.common.lib.controller.pod" -}} - {{- with .Values.imagePullSecrets }} -imagePullSecrets: - {{- toYaml . | nindent 2 }} - {{- end }} -serviceAccountName: {{ include "bjw-s.common.lib.chart.names.serviceAccountName" . }} -automountServiceAccountToken: {{ .Values.automountServiceAccountToken }} - {{- with .Values.podSecurityContext }} -securityContext: - {{- toYaml . | nindent 2 }} - {{- end }} - {{- with .Values.priorityClassName }} -priorityClassName: {{ . }} - {{- end }} - {{- with .Values.runtimeClassName }} -runtimeClassName: {{ . }} - {{- end }} - {{- with .Values.schedulerName }} -schedulerName: {{ . }} - {{- end }} - {{- with .Values.hostIPC }} -hostIPC: {{ . }} - {{- end }} - {{- with .Values.hostNetwork }} -hostNetwork: {{ . }} - {{- end }} - {{- with .Values.hostPID }} -hostPID: {{ . }} - {{- end }} - {{- with .Values.hostname }} -hostname: {{ . }} - {{- end }} - {{- if .Values.dnsPolicy }} -dnsPolicy: {{ .Values.dnsPolicy }} - {{- else if .Values.hostNetwork }} -dnsPolicy: ClusterFirstWithHostNet - {{- else }} -dnsPolicy: ClusterFirst - {{- end }} - {{- with .Values.dnsConfig }} -dnsConfig: - {{- toYaml . | nindent 2 }} - {{- end }} -enableServiceLinks: {{ .Values.enableServiceLinks }} - {{- with .Values.termination.gracePeriodSeconds }} -terminationGracePeriodSeconds: {{ . }} - {{- end }} - {{- if .Values.initContainers }} -initContainers: - {{- $initContainers := list }} - {{- range $index, $key := (keys .Values.initContainers | uniq | sortAlpha) }} - {{- $container := get $.Values.initContainers $key }} - {{- if not $container.name -}} - {{- $_ := set $container "name" $key }} - {{- end }} - {{- if $container.env -}} - {{- $_ := set $ "ObjectValues" (dict "envVars" $container.env) -}} - {{- $newEnv := fromYaml (include "bjw-s.common.lib.container.envVars" $) -}} - {{- $_ := unset $.ObjectValues "envVars" -}} - {{- $_ := set $container "env" $newEnv.env }} - {{- end }} - {{- $initContainers = append $initContainers $container }} - {{- end }} - {{- tpl (toYaml $initContainers) $ | nindent 2 }} - {{- end }} -containers: - {{- include "bjw-s.common.lib.controller.mainContainer" . | nindent 2 }} - {{- with (merge .Values.sidecars .Values.additionalContainers) }} - {{- $sidecarContainers := list }} - {{- range $name, $container := . }} - {{- if not $container.name -}} - {{- $_ := set $container "name" $name }} - {{- end }} - {{- if $container.env -}} - {{- $_ := set $ "ObjectValues" (dict "envVars" $container.env) -}} - {{- $newEnv := fromYaml (include "bjw-s.common.lib.container.envVars" $) -}} - {{- $_ := set $container "env" $newEnv.env }} - {{- $_ := unset $.ObjectValues "envVars" -}} - {{- end }} - {{- $sidecarContainers = append $sidecarContainers $container }} - {{- end }} - {{- tpl (toYaml $sidecarContainers) $ | nindent 2 }} - {{- end }} - {{- with (include "bjw-s.common.lib.controller.volumes" . | trim) }} -volumes: - {{- nindent 2 . }} - {{- end }} - {{- with .Values.hostAliases }} -hostAliases: - {{- toYaml . | nindent 2 }} - {{- end }} - {{- with .Values.nodeSelector }} -nodeSelector: - {{- toYaml . | nindent 2 }} - {{- end }} - {{- with .Values.affinity }} -affinity: - {{- toYaml . | nindent 2 }} - {{- end }} - {{- with .Values.topologySpreadConstraints }} -topologySpreadConstraints: - {{- toYaml . | nindent 2 }} - {{- end }} - {{- with .Values.tolerations }} -tolerations: - {{- toYaml . | nindent 2 }} - {{- end }} - {{- with .Values.controller.restartPolicy }} -restartPolicy: {{ . }} - {{- end }} -{{- end -}} diff --git a/charts/library/common/templates/lib/controller/_validate.tpl b/charts/library/common/templates/lib/controller/_validate.tpl new file mode 100644 index 00000000..df13e9e6 --- /dev/null +++ b/charts/library/common/templates/lib/controller/_validate.tpl @@ -0,0 +1,18 @@ +{{/* +Validate controller values +*/}} +{{- define "bjw-s.common.lib.controller.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $controllerValues := .object -}} + + {{- $allowedControllerTypes := list "deployment" "daemonset" "statefulset" "cronjob" -}} + {{- if not (has $controllerValues.type $allowedControllerTypes) -}} + {{- fail (printf "Not a valid controller.type (%s)" $controllerValues.type) -}} + {{- end -}} + + {{- $enabledContainers := include "bjw-s.common.lib.controller.enabledContainers" (dict "rootContext" $rootContext "controllerObject" $controllerValues) | fromYaml }} + {{- /* Validate at least one container is enabled */ -}} + {{- if not $enabledContainers -}} + {{- fail (printf "No containers enabled for controller (%s)" $controllerValues.identifier) -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/controller/_valuesToObject.tpl b/charts/library/common/templates/lib/controller/_valuesToObject.tpl new file mode 100644 index 00000000..4ff19f4e --- /dev/null +++ b/charts/library/common/templates/lib/controller/_valuesToObject.tpl @@ -0,0 +1,36 @@ +{{/* +Convert controller values to an object +*/}} +{{- define "bjw-s.common.lib.controller.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the controller name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.nameOverride -}} + {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} + {{- else -}} + {{- if ne $identifier "main" -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} + {{- end -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Set the default Pod options for the controller */ -}} + {{- range $index, $key := keys $rootContext.Values.defaultPodOptions -}} + {{- if not (hasKey $objectValues "pod") -}} + {{- $_ := set $objectValues "pod" dict -}} + {{- end -}} + + {{- $defaultValue := get $rootContext.Values.defaultPodOptions $key -}} + {{- if not (hasKey $objectValues.pod $key) -}} + {{- $_ := set $objectValues.pod $key $defaultValue -}} + {{- end -}} + {{- end -}} + + {{- /* Return the controller object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/controller/_volumes.tpl b/charts/library/common/templates/lib/controller/_volumes.tpl deleted file mode 100644 index fa985cdd..00000000 --- a/charts/library/common/templates/lib/controller/_volumes.tpl +++ /dev/null @@ -1,68 +0,0 @@ -{{/* -Volumes included by the controller. -*/}} -{{- define "bjw-s.common.lib.controller.volumes" -}} -{{- range $index, $persistence := .Values.persistence }} -{{- if $persistence.enabled }} -- name: {{ $index }} - {{- if eq (default "pvc" $persistence.type) "pvc" }} - {{- $pvcName := (include "bjw-s.common.lib.chart.names.fullname" $) -}} - {{- if $persistence.existingClaim }} - {{- /* Always prefer an existingClaim if that is set */}} - {{- $pvcName = $persistence.existingClaim -}} - {{- else -}} - {{- /* Otherwise refer to the PVC name */}} - {{- if $persistence.nameOverride -}} - {{- if not (eq $persistence.nameOverride "-") -}} - {{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $) $persistence.nameOverride) -}} - {{- end -}} - {{- else -}} - {{- $pvcName = (printf "%s-%s" (include "bjw-s.common.lib.chart.names.fullname" $) $index) -}} - {{- end -}} - {{- end }} - persistentVolumeClaim: - claimName: {{ $pvcName }} - {{- else if or (eq $persistence.type "configMap") (eq $persistence.type "secret") }} - {{- $objectName := (required (printf "name not set for persistence item %s" $index) $persistence.name) }} - {{- $objectName = tpl $objectName $ }} - {{- if eq $persistence.type "configMap" }} - configMap: - name: {{ $objectName }} - {{- else }} - secret: - secretName: {{ $objectName }} - {{- end }} - {{- with $persistence.defaultMode }} - defaultMode: {{ . }} - {{- end }} - {{- with $persistence.items }} - items: - {{- toYaml . | nindent 6 }} - {{- end }} - {{- else if eq $persistence.type "emptyDir" }} - {{- $emptyDir := dict -}} - {{- with $persistence.medium -}} - {{- $_ := set $emptyDir "medium" . -}} - {{- end -}} - {{- with $persistence.sizeLimit -}} - {{- $_ := set $emptyDir "sizeLimit" . -}} - {{- end }} - emptyDir: {{- $emptyDir | toYaml | nindent 4 }} - {{- else if eq $persistence.type "hostPath" }} - hostPath: - path: {{ required "hostPath not set" $persistence.hostPath }} - {{- with $persistence.hostPathType }} - type: {{ . }} - {{- end }} - {{- else if eq $persistence.type "nfs" }} - nfs: - server: {{ required "server not set" $persistence.server }} - path: {{ required "path not set" $persistence.path }} - {{- else if eq $persistence.type "custom" }} - {{- toYaml $persistence.volumeSpec | nindent 2 }} - {{- else }} - {{- fail (printf "Not a valid persistence.type (%s)" $persistence.type) }} - {{- end }} -{{- end }} -{{- end }} -{{- end }} diff --git a/charts/library/common/templates/lib/cronjob/_validate.tpl b/charts/library/common/templates/lib/cronjob/_validate.tpl new file mode 100644 index 00000000..37cb7b20 --- /dev/null +++ b/charts/library/common/templates/lib/cronjob/_validate.tpl @@ -0,0 +1,11 @@ +{{/* +Validate CronJob values +*/}} +{{- define "bjw-s.common.lib.cronjob.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $cronjobValues := .object -}} + + {{- if and (ne $cronjobValues.pod.restartPolicy "Never") (ne $cronjobValues.pod.restartPolicy "OnFailure") -}} + {{- fail (printf "Not a valid restartPolicy type for CronJob. (controller: %s, restartPolicy: %s)" $cronjobValues.identifier $cronjobValues.pod.restartPolicy) }} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/cronjob/_valuesToObject.tpl b/charts/library/common/templates/lib/cronjob/_valuesToObject.tpl new file mode 100644 index 00000000..5657be59 --- /dev/null +++ b/charts/library/common/templates/lib/cronjob/_valuesToObject.tpl @@ -0,0 +1,18 @@ +{{/* +Convert Cronjob values to an object +*/}} +{{- define "bjw-s.common.lib.cronjob.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- if not (hasKey $objectValues "pod") -}} + {{- $_ := set $objectValues "pod" dict -}} + {{- end -}} + + {{- $restartPolicy := default "Never" $objectValues.pod.restartPolicy -}} + {{- $_ := set $objectValues.pod "restartPolicy" $restartPolicy -}} + + {{- /* Return the CronJob object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/daemonset/_validate.tpl b/charts/library/common/templates/lib/daemonset/_validate.tpl new file mode 100644 index 00000000..25a7408c --- /dev/null +++ b/charts/library/common/templates/lib/daemonset/_validate.tpl @@ -0,0 +1,7 @@ +{{/* +Validate DaemonSet values +*/}} +{{- define "bjw-s.common.lib.daemonset.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $daemonsetValues := .object -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/daemonset/_valuesToObject.tpl b/charts/library/common/templates/lib/daemonset/_valuesToObject.tpl new file mode 100644 index 00000000..4593255b --- /dev/null +++ b/charts/library/common/templates/lib/daemonset/_valuesToObject.tpl @@ -0,0 +1,11 @@ +{{/* +Convert DaemonSet values to an object +*/}} +{{- define "bjw-s.common.lib.daemonset.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Return the DaemonSet object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/deployment/_validate.tpl b/charts/library/common/templates/lib/deployment/_validate.tpl new file mode 100644 index 00000000..c3210079 --- /dev/null +++ b/charts/library/common/templates/lib/deployment/_validate.tpl @@ -0,0 +1,11 @@ +{{/* +Validate Deployment values +*/}} +{{- define "bjw-s.common.lib.deployment.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $deploymentValues := .object -}} + + {{- if and (ne $deploymentValues.strategy "Recreate") (ne $deploymentValues.strategy "RollingUpdate") -}} + {{- fail (printf "Not a valid strategy type for Deployment. (controller: %s, strategy: %s)" $deploymentValues.identifier $deploymentValues.strategy) }} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/deployment/_valuesToObject.tpl b/charts/library/common/templates/lib/deployment/_valuesToObject.tpl new file mode 100644 index 00000000..7e7ad9ae --- /dev/null +++ b/charts/library/common/templates/lib/deployment/_valuesToObject.tpl @@ -0,0 +1,14 @@ +{{/* +Convert Deployment values to an object +*/}} +{{- define "bjw-s.common.lib.deployment.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- $strategy := default "Recreate" $objectValues.strategy -}} + {{- $_ := set $objectValues "strategy" $strategy -}} + + {{- /* Return the Deployment object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/ingress/_primary.tpl b/charts/library/common/templates/lib/ingress/_primary.tpl index 9f58d38b..5198d09a 100644 --- a/charts/library/common/templates/lib/ingress/_primary.tpl +++ b/charts/library/common/templates/lib/ingress/_primary.tpl @@ -1,4 +1,4 @@ -{{/* Return the name of the primary ingress object */}} +{{/* Return the name of the primary Ingress object */}} {{- define "bjw-s.common.lib.ingress.primary" -}} {{- $enabledIngresses := dict -}} {{- range $name, $ingress := .Values.ingress -}} diff --git a/charts/library/common/templates/lib/ingress/_validate.tpl b/charts/library/common/templates/lib/ingress/_validate.tpl new file mode 100644 index 00000000..1dd463dc --- /dev/null +++ b/charts/library/common/templates/lib/ingress/_validate.tpl @@ -0,0 +1,15 @@ +{{/* +Validate Ingress values +*/}} +{{- define "bjw-s.common.lib.ingress.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $ingressValues := .object -}} + + {{- range $ingressValues.hosts -}} + {{- range .paths -}} + {{- if or (eq (dig "service" "name" "" .) "") (not .service.name) -}} + {{- fail (printf "No service name configured. (ingress: %s, path: %s)" $ingressValues.identifier .path) -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/ingress/_valuesToObject.tpl b/charts/library/common/templates/lib/ingress/_valuesToObject.tpl new file mode 100644 index 00000000..c9195cad --- /dev/null +++ b/charts/library/common/templates/lib/ingress/_valuesToObject.tpl @@ -0,0 +1,24 @@ +{{/* +Convert ingress values to an object +*/}} +{{- define "bjw-s.common.lib.ingress.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the ingress name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.nameOverride -}} + {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} + {{- else -}} + {{- if ne $identifier "main" -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} + {{- end -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the ingress object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/metadata/_podAnnotations.tpl b/charts/library/common/templates/lib/metadata/_podAnnotations.tpl deleted file mode 100644 index a456c5cc..00000000 --- a/charts/library/common/templates/lib/metadata/_podAnnotations.tpl +++ /dev/null @@ -1,26 +0,0 @@ -{{/* Determine the Pod annotations used in the controller */}} -{{- define "bjw-s.common.lib.metadata.podAnnotations" -}} - {{- if .Values.podAnnotations -}} - {{- tpl (toYaml .Values.podAnnotations) . | nindent 0 -}} - {{- end -}} - - {{- $configMapsFound := dict -}} - {{- range $name, $configmap := .Values.configMaps -}} - {{- if $configmap.enabled -}} - {{- $_ := set $configMapsFound $name (toYaml $configmap.data | sha256sum) -}} - {{- end -}} - {{- end -}} - {{- if $configMapsFound -}} - {{- printf "checksum/config: %v" (toYaml $configMapsFound | sha256sum) | nindent 0 -}} - {{- end -}} - - {{- $secretsFound := dict -}} - {{- range $name, $secret := .Values.secrets -}} - {{- if $secret.enabled -}} - {{- $_ := set $secretsFound $name (toYaml $secret.data | sha256sum) -}} - {{- end -}} - {{- end -}} - {{- if $secretsFound -}} - {{- printf "checksum/secrets: %v" (toYaml $secretsFound | sha256sum) | nindent 0 -}} - {{- end -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/pod/_getOption.tpl b/charts/library/common/templates/lib/pod/_getOption.tpl new file mode 100644 index 00000000..c436ee32 --- /dev/null +++ b/charts/library/common/templates/lib/pod/_getOption.tpl @@ -0,0 +1,34 @@ +{{- /* +Returns the value for the specified field +*/ -}} +{{- define "bjw-s.common.lib.pod.getOption" -}} + {{- $rootContext := .ctx.rootContext -}} + {{- $controllerObject := .ctx.controllerObject -}} + {{- $option := .option -}} + + {{- $value := "" -}} + + {{- /* Set to the default if it is set */ -}} + {{- $defaultOption := get $rootContext.Values.defaultPodOptions $option -}} + {{- if kindIs "bool" $defaultOption -}} + {{- $value = $defaultOption -}} + {{- else if not (empty $defaultOption) -}} + {{- $value = $defaultOption -}} + {{- end -}} + + {{- /* See if a pod-specific override is needed */ -}} + {{- if hasKey $controllerObject "pod" -}} + {{- $podOption := get $controllerObject.pod $option -}} + {{- if kindIs "bool" $podOption -}} + {{- $value = $podOption -}} + {{- else if not (empty $podOption) -}} + {{- $value = $podOption -}} + {{- end -}} + {{- end -}} + + {{- if kindIs "bool" $value -}} + {{- $value | toYaml -}} + {{- else if not (empty $value) -}} + {{- $value | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pod/_spec.tpl b/charts/library/common/templates/lib/pod/_spec.tpl new file mode 100644 index 00000000..48b293eb --- /dev/null +++ b/charts/library/common/templates/lib/pod/_spec.tpl @@ -0,0 +1,67 @@ +{{- /* +The pod definition included in the controller. +*/ -}} +{{- define "bjw-s.common.lib.pod.spec" -}} + {{- $rootContext := .rootContext -}} + {{- $controllerObject := .controllerObject -}} + {{- $ctx := dict "rootContext" $rootContext "controllerObject" $controllerObject -}} + +enableServiceLinks: {{ $controllerObject.pod.enableServiceLinks }} +serviceAccountName: {{ include "bjw-s.common.lib.pod.field.serviceAccountName" (dict "ctx" $ctx) | trim }} +automountServiceAccountToken: {{ $controllerObject.pod.automountServiceAccountToken }} + {{- with ($controllerObject.pod.priorityClassName) }} +priorityClassName: {{ . | trim }} + {{- end -}} + {{- with ($controllerObject.pod.runtimeClassName) }} +runtimeClassName: {{ . | trim }} + {{- end -}} + {{- with ($controllerObject.pod.schedulerName) }} +schedulerName: {{ . | trim }} + {{- end -}} + {{- with ($controllerObject.pod.securityContext) }} +securityContext: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with ($controllerObject.pod.hostname) }} +hostname: {{ . | trim }} + {{- end }} +hostIPC: {{ $controllerObject.pod.hostIPC }} +hostNetwork: {{ $controllerObject.pod.hostNetwork }} +hostPID: {{ $controllerObject.pod.hostPID }} +dnsPolicy: {{ include "bjw-s.common.lib.pod.field.dnsPolicy" (dict "ctx" $ctx) | trim }} + {{- with $controllerObject.pod.dnsConfig }} +dnsConfig: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with $controllerObject.pod.hostAliases }} +hostAliases: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with $controllerObject.pod.imagePullSecrets }} +imagePullSecrets: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with $controllerObject.pod.terminationGracePeriodSeconds }} +terminationGracePeriodSeconds: {{ . | trim }} + {{- end -}} + {{- with $controllerObject.pod.restartPolicy }} +restartPolicy: {{ . | trim }} + {{- end -}} + {{- with $controllerObject.pod.nodeSelector }} +nodeSelector: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with $controllerObject.pod.affinity }} +affinity: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with $controllerObject.pod.topologySpreadConstraints }} +topologySpreadConstraints: {{ . | trim | nindent 2 }} + {{- end -}} + {{- with $controllerObject.pod.tolerations }} +tolerations: {{ . | trim | nindent 2 }} + {{- end }} + {{- with (include "bjw-s.common.lib.pod.field.initContainers" (dict "ctx" $ctx) | trim) }} +initContainers: {{ . | nindent 2 }} + {{- end -}} + {{- with (include "bjw-s.common.lib.pod.field.containers" (dict "ctx" $ctx) | trim) }} +containers: {{ . | nindent 2 }} + {{- end -}} + {{- with (include "bjw-s.common.lib.pod.field.volumes" (dict "ctx" $ctx) | trim) }} +volumes: {{ . | nindent 2 }} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pod/fields/_containers.tpl b/charts/library/common/templates/lib/pod/fields/_containers.tpl new file mode 100644 index 00000000..07b13408 --- /dev/null +++ b/charts/library/common/templates/lib/pod/fields/_containers.tpl @@ -0,0 +1,28 @@ +{{- /* +Returns the value for containers +*/ -}} +{{- define "bjw-s.common.lib.pod.field.containers" -}} + {{- $rootContext := .ctx.rootContext -}} + {{- $controllerObject := .ctx.controllerObject -}} + + {{- /* Default to empty list */ -}} + {{- $containers := list -}} + + {{- /* Fetch configured containers for this controller */ -}} + {{- $enabledContainers := include "bjw-s.common.lib.controller.enabledContainers" (dict "rootContext" $rootContext "controllerObject" $controllerObject) | fromYaml }} + {{- range $key, $containerValues := $enabledContainers -}} + {{- /* Create object from the container values */ -}} + {{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $ "id" $key "values" $containerValues)) | fromYaml -}} + + {{- /* Perform validations on the Container before rendering */ -}} + {{- include "bjw-s.common.lib.container.validate" (dict "rootContext" $ "object" $containerObject) -}} + + {{- /* Generate the Container spec */ -}} + {{- $renderedContainer := include "bjw-s.common.lib.container.spec" (dict "rootContext" $rootContext "controllerObject" $controllerObject "containerObject" $containerObject) | fromYaml -}} + {{- $containers = append $containers $renderedContainer -}} + {{- end -}} + + {{- if not (empty $containers) -}} + {{- $containers | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pod/fields/_dnsPolicy.tpl b/charts/library/common/templates/lib/pod/fields/_dnsPolicy.tpl new file mode 100644 index 00000000..e82636d0 --- /dev/null +++ b/charts/library/common/templates/lib/pod/fields/_dnsPolicy.tpl @@ -0,0 +1,25 @@ +{{- /* +Returns the value for dnsPolicy +*/ -}} +{{- define "bjw-s.common.lib.pod.field.dnsPolicy" -}} + {{- $ctx := .ctx -}} + {{- $controllerObject := $ctx.controllerObject -}} + + {{- /* Default to "ClusterFirst" */ -}} + {{- $dnsPolicy := "ClusterFirst" -}} + + {{- /* Get hostNetwork value "" */ -}} + {{- $hostNetwork:= get $controllerObject.pod "hostNetwork" -}} + {{- if $hostNetwork -}} + {{- $dnsPolicy = "ClusterFirstWithHostNet" -}} + {{- end -}} + + {{- /* See if an override is desired */ -}} + {{- $override := get $controllerObject.pod "dnsPolicy" -}} + + {{- if not (empty $override) -}} + {{- $dnsPolicy = $override -}} + {{- end -}} + + {{- $dnsPolicy -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pod/fields/_initContainers.tpl b/charts/library/common/templates/lib/pod/fields/_initContainers.tpl new file mode 100644 index 00000000..01cbb6d5 --- /dev/null +++ b/charts/library/common/templates/lib/pod/fields/_initContainers.tpl @@ -0,0 +1,27 @@ +{{- /* +Returns the value for initContainers +*/ -}} +{{- define "bjw-s.common.lib.pod.field.initContainers" -}} + {{- $rootContext := .ctx.rootContext -}} + {{- $controllerObject := .ctx.controllerObject -}} + + {{- /* Default to empty list */ -}} + {{- $containers := list -}} + + {{- /* Fetch configured containers for this controller */ -}} + {{- range $key, $containerValues := $controllerObject.initContainers -}} + {{- /* Create object from the container values */ -}} + {{- $containerObject := (include "bjw-s.common.lib.container.valuesToObject" (dict "rootContext" $ "id" $key "values" $containerValues)) | fromYaml -}} + + {{- /* Perform validations on the Container before rendering */ -}} + {{- include "bjw-s.common.lib.container.validate" (dict "rootContext" $ "object" $containerObject) -}} + + {{- /* Generate the Container spec */ -}} + {{- $renderedContainer := include "bjw-s.common.lib.container.spec" (dict "rootContext" $rootContext "containerObject" $containerObject) | fromYaml -}} + {{- $containers = append $containers $renderedContainer -}} + {{- end -}} + + {{- if not (empty $containers) -}} + {{- $containers | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pod/fields/_serviceAccountName.tpl b/charts/library/common/templates/lib/pod/fields/_serviceAccountName.tpl new file mode 100644 index 00000000..1ec57286 --- /dev/null +++ b/charts/library/common/templates/lib/pod/fields/_serviceAccountName.tpl @@ -0,0 +1,18 @@ +{{- /* +Returns the value for serviceAccountName +*/ -}} +{{- define "bjw-s.common.lib.pod.field.serviceAccountName" -}} + {{- $rootContext := .ctx.rootContext -}} + + {{- /* Default to "default" */ -}} + {{- $name := "default" -}} + + {{- /* See if an override is needed */ -}} + {{- if $rootContext.Values.serviceAccount.create -}} + {{- $serviceAccountValues := (mustDeepCopy $rootContext.Values.serviceAccount) -}} + {{- $serviceAccountObject := (include "bjw-s.common.lib.serviceAccount.valuesToObject" (dict "rootContext" $rootContext "id" "default" "values" $serviceAccountValues)) | fromYaml -}} + {{- $name = $serviceAccountObject.name -}} + {{- end -}} + + {{- $name -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pod/fields/_volumes.tpl b/charts/library/common/templates/lib/pod/fields/_volumes.tpl new file mode 100644 index 00000000..6616dde8 --- /dev/null +++ b/charts/library/common/templates/lib/pod/fields/_volumes.tpl @@ -0,0 +1,118 @@ +{{- /* +Returns the value for volumes +*/ -}} +{{- define "bjw-s.common.lib.pod.field.volumes" -}} + {{- $rootContext := .ctx.rootContext -}} + {{- $controllerObject := .ctx.controllerObject -}} + + {{- /* Default to empty list */ -}} + {{- $persistenceItemsToProcess := dict -}} + {{- $volumes := list -}} + + {{- /* Loop over persistence values */ -}} + {{- range $identifier, $persistenceValues := $rootContext.Values.persistence -}} + {{- /* Enable persistence item by default, but allow override */ -}} + {{- $persistenceEnabled := true -}} + {{- if hasKey $persistenceValues "enabled" -}} + {{- $persistenceEnabled = $persistenceValues.enabled -}} + {{- end -}} + + {{- if $persistenceEnabled -}} + {{- $advancedMounts := dig "advancedMounts" $controllerObject.identifier list $persistenceValues -}} + {{- if $advancedMounts -}} + {{- $_ := set $persistenceItemsToProcess $identifier $persistenceValues -}} + {{- else -}} + {{- $_ := set $persistenceItemsToProcess $identifier $persistenceValues -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- /* Loop over persistence items */ -}} + {{- range $identifier, $persistenceValues := $persistenceItemsToProcess -}} + {{- $volume := dict "name" $identifier -}} + + {{- /* PVC persistence type */ -}} + {{- if eq (default "persistentVolumeClaim" $persistenceValues.type) "persistentVolumeClaim" -}} + {{- $pvcName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + {{- if $persistenceValues.existingClaim -}} + {{- /* Always prefer an existingClaim if that is set */ -}} + {{- $pvcName = $persistenceValues.existingClaim -}} + {{- else -}} + {{- /* Otherwise refer to the PVC name */ -}} + {{- if $persistenceValues.nameOverride -}} + {{- if not (eq $persistenceValues.nameOverride "-") -}} + {{- $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) -}} + {{- end -}} + {{- end -}} + {{- $_ := set $volume "persistentVolumeClaim" (dict "claimName" $pvcName) -}} + + {{- /* configMap persistence type */ -}} + {{- else if eq $persistenceValues.type "configMap" -}} + {{- $objectName := (required (printf "name not set for persistence item %s" $identifier) $persistenceValues.name) -}} + {{- $objectName = tpl $objectName $rootContext -}} + {{- $_ := set $volume "configMap" dict -}} + {{- $_ := set $volume.configMap "name" $objectName -}} + {{- with $persistenceValues.defaultMode -}} + {{- $_ := set $volume.configMap "defaultMode" . -}} + {{- end -}} + {{- with $persistenceValues.items -}} + {{- $_ := set $volume.configMap "items" . -}} + {{- end -}} + + {{- /* Secret persistence type */ -}} + {{- else if eq $persistenceValues.type "secret" -}} + {{- $objectName := (required (printf "name not set for persistence item %s" $identifier) $persistenceValues.name) -}} + {{- $objectName = tpl $objectName $rootContext -}} + {{- $_ := set $volume "secret" dict -}} + {{- $_ := set $volume.secret "secretName" $objectName -}} + {{- with $persistenceValues.defaultMode -}} + {{- $_ := set $volume.secret "defaultMode" . -}} + {{- end -}} + {{- with $persistenceValues.items -}} + {{- $_ := set $volume.secret "items" . -}} + {{- end -}} + + {{- /* emptyDir persistence type */ -}} + {{- else if eq $persistenceValues.type "emptyDir" -}} + {{- $_ := set $volume "emptyDir" dict -}} + {{- with $persistenceValues.medium -}} + {{- $_ := set $volume.emptyDir "medium" . -}} + {{- end -}} + {{- with $persistenceValues.sizeLimit -}} + {{- $_ := set $volume.emptyDir "sizeLimit" . -}} + {{- end -}} + + {{- /* hostPath persistence type */ -}} + {{- else if eq $persistenceValues.type "hostPath" -}} + {{- $_ := set $volume "hostPath" dict -}} + {{- $_ := set $volume.hostPath "path" (required "hostPath not set" $persistenceValues.hostPath) -}} + {{- with $persistenceValues.hostPathType }} + {{- $_ := set $volume.hostPath "type" . -}} + {{- end -}} + + {{- /* hostPath persistence type */ -}} + {{- else if eq $persistenceValues.type "nfs" -}} + {{- $_ := set $volume "nfs" dict -}} + {{- $_ := set $volume.nfs "server" (required "server not set" $persistenceValues.server) -}} + {{- $_ := set $volume.nfs "path" (required "path not set" $persistenceValues.path) -}} + + {{- /* custom persistence type */ -}} + {{- else if eq $persistenceValues.type "custom" -}} + {{- $volume = $persistenceValues.volumeSpec -}} + {{- $_ := set $volume "name" $identifier -}} + + {{- /* Fail otherwise */ -}} + {{- else -}} + {{- fail (printf "Not a valid persistence.type (%s)" $persistenceValues.type) -}} + {{- end -}} + + {{- $volumes = append $volumes $volume -}} + {{- end -}} + + {{- if not (empty $volumes) -}} + {{- $volumes | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pod/metadata/_annotations.tpl b/charts/library/common/templates/lib/pod/metadata/_annotations.tpl new file mode 100644 index 00000000..86e6d25f --- /dev/null +++ b/charts/library/common/templates/lib/pod/metadata/_annotations.tpl @@ -0,0 +1,56 @@ +{{- /* +Returns the value for annotations +*/ -}} +{{- define "bjw-s.common.lib.pod.metadata.annotations" -}} + {{- $rootContext := .rootContext -}} + {{- $controllerObject := .controllerObject -}} + + {{- /* Default annotations */ -}} + {{- $annotations := dict -}} + + {{- /* Set to the default if it is set */ -}} + {{- $defaultOption := get $rootContext.Values.defaultPodOptions "annotations" -}} + {{- if not (empty $defaultOption) -}} + {{- $annotations = merge $defaultOption $annotations -}} + {{- end -}} + + {{- /* See if a pod-specific override is set */ -}} + {{- if hasKey $controllerObject "pod" -}} + {{- $podOption := get $controllerObject.pod "annotations" -}} + {{- if not (empty $podOption) -}} + {{- $annotations = merge $podOption $annotations -}} + {{- end -}} + {{- end -}} + + {{- /* Add configMaps checksum */ -}} + {{- $configMapsFound := dict -}} + {{- range $name, $configmap := $rootContext.Values.configMaps -}} + {{- if $configmap.enabled -}} + {{- $_ := set $configMapsFound $name (toYaml $configmap.data | sha256sum) -}} + {{- end -}} + {{- end -}} + {{- if $configMapsFound -}} + {{- $annotations = merge + (dict "checksum/configMaps" (toYaml $configMapsFound | sha256sum)) + $annotations + -}} + {{- end -}} + + {{- /* Add Secrets checksum */ -}} + {{- $secretsFound := dict -}} + {{- range $name, $secret := $rootContext.Values.secrets -}} + {{- if $secret.enabled -}} + {{- $_ := set $secretsFound $name (toYaml $secret.stringData | sha256sum) -}} + {{- end -}} + {{- end -}} + {{- if $secretsFound -}} + {{- $annotations = merge + (dict "checksum/secrets" (toYaml $secretsFound | sha256sum)) + $annotations + -}} + {{- end -}} + + {{- if not (empty $annotations) -}} + {{- $annotations | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pod/metadata/_labels.tpl b/charts/library/common/templates/lib/pod/metadata/_labels.tpl new file mode 100644 index 00000000..82a1731b --- /dev/null +++ b/charts/library/common/templates/lib/pod/metadata/_labels.tpl @@ -0,0 +1,36 @@ +{{- /* +Returns the value for labels +*/ -}} +{{- define "bjw-s.common.lib.pod.metadata.labels" -}} + {{- $rootContext := .rootContext -}} + {{- $controllerObject := .controllerObject -}} + + {{- /* Default labels */ -}} + {{- $labels := merge + (dict "app.kubernetes.io/component" $controllerObject.identifier) + -}} + + {{- /* Fetch the Pod selectorLabels */ -}} + {{- $selectorLabels := include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | fromYaml -}} + {{- if not (empty $selectorLabels) -}} + {{- $labels = merge $selectorLabels $labels -}} + {{- end -}} + + {{- /* Set to the default if it is set */ -}} + {{- $defaultOption := get $rootContext.Values.defaultPodOptions "labels" -}} + {{- if not (empty $defaultOption) -}} + {{- $labels = merge $defaultOption $labels -}} + {{- end -}} + + {{- /* See if a pod-specific override is set */ -}} + {{- if hasKey $controllerObject "pod" -}} + {{- $podOption := get $controllerObject.pod "labels" -}} + {{- if not (empty $podOption) -}} + {{- $labels = merge $podOption $labels -}} + {{- end -}} + {{- end -}} + + {{- if not (empty $labels) -}} + {{- $labels | toYaml -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pvc/_validate.tpl b/charts/library/common/templates/lib/pvc/_validate.tpl new file mode 100644 index 00000000..23110faf --- /dev/null +++ b/charts/library/common/templates/lib/pvc/_validate.tpl @@ -0,0 +1,7 @@ +{{/* +Validate PVC values +*/}} +{{- define "bjw-s.common.lib.pvc.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $pvcObject := .object -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/pvc/_valuesToObject.tpl b/charts/library/common/templates/lib/pvc/_valuesToObject.tpl new file mode 100644 index 00000000..99878382 --- /dev/null +++ b/charts/library/common/templates/lib/pvc/_valuesToObject.tpl @@ -0,0 +1,24 @@ +{{/* +Convert PVC values to an object +*/}} +{{- define "bjw-s.common.lib.pvc.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the PVC name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.nameOverride -}} + {{- if ne $objectValues.nameOverride "-" -}} + {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} + {{- end -}} + {{- else -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the PVC object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/routes/_validate.tpl b/charts/library/common/templates/lib/routes/_validate.tpl new file mode 100644 index 00000000..5b89d856 --- /dev/null +++ b/charts/library/common/templates/lib/routes/_validate.tpl @@ -0,0 +1,7 @@ +{{/* +Validate Route values +*/}} +{{- define "bjw-s.common.lib.route.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $routeValues := .object -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/routes/_valuesToObject.tpl b/charts/library/common/templates/lib/routes/_valuesToObject.tpl new file mode 100644 index 00000000..1b436631 --- /dev/null +++ b/charts/library/common/templates/lib/routes/_valuesToObject.tpl @@ -0,0 +1,24 @@ +{{/* +Convert Route values to an object +*/}} +{{- define "bjw-s.common.lib.route.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the Route name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.nameOverride -}} + {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} + {{- else -}} + {{- if ne $identifier (include "bjw-s.common.lib.route.primary" $rootContext) -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} + {{- end -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the Route object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/secret/_validate.tpl b/charts/library/common/templates/lib/secret/_validate.tpl new file mode 100644 index 00000000..82603992 --- /dev/null +++ b/charts/library/common/templates/lib/secret/_validate.tpl @@ -0,0 +1,7 @@ +{{/* +Validate Secret values +*/}} +{{- define "bjw-s.common.lib.secret.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $secretValues := .object -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/secret/_valuesToObject.tpl b/charts/library/common/templates/lib/secret/_valuesToObject.tpl new file mode 100644 index 00000000..59f89d17 --- /dev/null +++ b/charts/library/common/templates/lib/secret/_valuesToObject.tpl @@ -0,0 +1,24 @@ +{{/* +Convert Secret values to an object +*/}} +{{- define "bjw-s.common.lib.secret.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the Secret name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.nameOverride -}} + {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} + {{- else -}} + {{- if ne $identifier "main" -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} + {{- end -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the Secret object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/service/_enabled_ports.tpl b/charts/library/common/templates/lib/service/_enabled_ports.tpl index d72b5b85..6de6c1b0 100644 --- a/charts/library/common/templates/lib/service/_enabled_ports.tpl +++ b/charts/library/common/templates/lib/service/_enabled_ports.tpl @@ -2,9 +2,12 @@ Return the enabled ports for a given Service object. */}} {{- define "bjw-s.common.lib.service.enabledPorts" -}} + {{- $rootContext := .rootContext -}} + {{- $serviceObject := .serviceObject -}} + {{- $enabledPorts := dict -}} - {{- range $name, $port := .values.ports -}} + {{- range $name, $port := $serviceObject.ports -}} {{- if kindIs "map" $port -}} {{- $portEnabled := true -}} {{- if hasKey $port "enabled" -}} diff --git a/charts/library/common/templates/lib/service/_enabled_services.tpl b/charts/library/common/templates/lib/service/_enabled_services.tpl index c5d14627..74b4ea90 100644 --- a/charts/library/common/templates/lib/service/_enabled_services.tpl +++ b/charts/library/common/templates/lib/service/_enabled_services.tpl @@ -2,17 +2,22 @@ Return the enabled services. */}} {{- define "bjw-s.common.lib.service.enabledServices" -}} + {{- $rootContext := .rootContext -}} {{- $enabledServices := dict -}} - {{- range $name, $service := .Values.service -}} + + {{- range $name, $service := $rootContext.Values.service -}} {{- if kindIs "map" $service -}} + {{- /* Enable Service by default, but allow override */ -}} {{- $serviceEnabled := true -}} {{- if hasKey $service "enabled" -}} {{- $serviceEnabled = $service.enabled -}} {{- end -}} + {{- if $serviceEnabled -}} {{- $_ := set $enabledServices $name . -}} {{- end -}} {{- end -}} {{- end -}} + {{- $enabledServices | toYaml -}} {{- end -}} diff --git a/charts/library/common/templates/lib/service/_getByIdentifier.tpl b/charts/library/common/templates/lib/service/_getByIdentifier.tpl new file mode 100644 index 00000000..c8335125 --- /dev/null +++ b/charts/library/common/templates/lib/service/_getByIdentifier.tpl @@ -0,0 +1,13 @@ +{{/* +Return a service Object by its Identifier. +*/}} +{{- define "bjw-s.common.lib.service.getByIdentifier" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + + {{- range $name, $serviceValues := $rootContext.Values.service -}} + {{- if eq $name $identifier -}} + {{- include "bjw-s.common.lib.service.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $serviceValues) -}} + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/service/_primary.tpl b/charts/library/common/templates/lib/service/_primary.tpl deleted file mode 100644 index da168ee3..00000000 --- a/charts/library/common/templates/lib/service/_primary.tpl +++ /dev/null @@ -1,18 +0,0 @@ -{{/* -Return the primary service object -*/}} -{{- define "bjw-s.common.lib.service.primary" -}} - {{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" $ | fromYaml ) }} - - {{- $result := "" -}} - {{- range $name, $service := $enabledServices -}} - {{- if and (hasKey $service "primary") $service.primary -}} - {{- $result = $name -}} - {{- end -}} - {{- end -}} - - {{- if not $result -}} - {{- $result = keys $enabledServices | first -}} - {{- end -}} - {{- $result -}} -{{- end -}} diff --git a/charts/library/common/templates/lib/service/_primaryForController.tpl b/charts/library/common/templates/lib/service/_primaryForController.tpl new file mode 100644 index 00000000..ebc07067 --- /dev/null +++ b/charts/library/common/templates/lib/service/_primaryForController.tpl @@ -0,0 +1,30 @@ +{{/* +Return the primary service object for a controller +*/}} +{{- define "bjw-s.common.lib.service.primaryForController" -}} + {{- $rootContext := .rootContext -}} + {{- $controllerIdentifier := .controllerIdentifier -}} + + {{- $identifier := "" -}} + {{- $result := dict -}} + + {{- /* Loop over all enabled services */ -}} + {{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }} + {{- if $enabledServices -}} + {{- range $name, $service := $enabledServices -}} + {{- /* Determine the Service that has been marked as primary */ -}} + {{- if and (hasKey $service "primary") $service.primary -}} + {{- $identifier = $name -}} + {{- $result = $service -}} + {{- end -}} + {{- end -}} + + {{- /* Return the first Service if none has been explicitly marked as primary */ -}} + {{- if not $result -}} + {{- $identifier = keys $enabledServices | first -}} + {{- $result = get $enabledServices $identifier -}} + {{- end -}} + + {{- include "bjw-s.common.lib.service.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $result) -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/service/_primary_port.tpl b/charts/library/common/templates/lib/service/_primary_port.tpl index 0cb7aeee..d921be1a 100644 --- a/charts/library/common/templates/lib/service/_primary_port.tpl +++ b/charts/library/common/templates/lib/service/_primary_port.tpl @@ -2,17 +2,24 @@ Return the primary port for a given Service object. */}} {{- define "bjw-s.common.lib.service.primaryPort" -}} - {{- $enabledPorts := (include "bjw-s.common.lib.service.enabledPorts" . | fromYaml) }} - + {{- $rootContext := .rootContext -}} + {{- $serviceObject := .serviceObject -}} {{- $result := "" -}} + + {{- /* Loop over all enabled ports */ -}} + {{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "rootContext" $rootContext "serviceObject" $serviceObject) | fromYaml }} {{- range $name, $port := $enabledPorts -}} + {{- /* Determine the port that has been marked as primary */ -}} {{- if and (hasKey $port "primary") $port.primary -}} - {{- $result = $name -}} + {{- $result = $port -}} {{- end -}} {{- end -}} + {{- /* Return the first port if none has been explicitly marked as primary */ -}} {{- if not $result -}} - {{- $result = keys $enabledPorts | first -}} + {{- $firstPortKey := keys $enabledPorts | first -}} + {{- $result = get $enabledPorts $firstPortKey -}} {{- end -}} - {{- $result -}} + + {{- $result | toYaml -}} {{- end -}} diff --git a/charts/library/common/templates/lib/service/_validate.tpl b/charts/library/common/templates/lib/service/_validate.tpl new file mode 100644 index 00000000..2072c8bd --- /dev/null +++ b/charts/library/common/templates/lib/service/_validate.tpl @@ -0,0 +1,37 @@ +{{/* +Validate Service values +*/}} +{{- define "bjw-s.common.lib.service.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $serviceObject := .object -}} + + {{- if empty (get $serviceObject "controller") -}} + {{- fail (printf "controller is required for Service. (service: %s)" $serviceObject.identifier) -}} + {{- end -}} + + {{- /* Validate Service type */ -}} + {{- $validServiceTypes := (list "ClusterIP" "LoadBalancer" "NodePort" "ExternalName" "ExternalIP") -}} + {{- if and $serviceObject.type (not (mustHas $serviceObject.type $validServiceTypes)) -}} + {{- fail ( + printf "invalid service type \"%s\" for Service with key \"%s\". Allowed values are [%s]" + $serviceObject.type + $serviceObject.identifier + (join ", " $validServiceTypes) + ) -}} + {{- end -}} + + {{- if ne $serviceObject.type "ExternalName" -}} + {{- $enabledPorts := include "bjw-s.common.lib.service.enabledPorts" (dict "rootContext" $rootContext "serviceObject" $serviceObject) | fromYaml }} + {{- /* Validate at least one port is enabled */ -}} + {{- if not $enabledPorts -}} + {{- fail (printf "no ports are enabled for Service with key \"%s\"" $serviceObject.identifier) -}} + {{- end -}} + + {{- range $name, $port := $enabledPorts -}} + {{- /* Validate a port number is configured */ -}} + {{- if not $port.port -}} + {{- fail (printf "no port number is configured for port \"%s\" under Service with key \"%s\"" $name $serviceObject.identifier) -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/service/_valuesToObject.tpl b/charts/library/common/templates/lib/service/_valuesToObject.tpl new file mode 100644 index 00000000..2b1417cb --- /dev/null +++ b/charts/library/common/templates/lib/service/_valuesToObject.tpl @@ -0,0 +1,24 @@ +{{/* +Convert Service values to an object +*/}} +{{- define "bjw-s.common.lib.service.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the Service name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.nameOverride -}} + {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} + {{- else -}} + {{- if not $objectValues.primary -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} + {{- end -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the Service object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/serviceAccount/_validate.tpl b/charts/library/common/templates/lib/serviceAccount/_validate.tpl new file mode 100644 index 00000000..8eeb3746 --- /dev/null +++ b/charts/library/common/templates/lib/serviceAccount/_validate.tpl @@ -0,0 +1,7 @@ +{{/* +Validate ServiceAccount values +*/}} +{{- define "bjw-s.common.lib.serviceAccount.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $serviceAccountValues := .object -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/serviceAccount/_valuesToObject.tpl b/charts/library/common/templates/lib/serviceAccount/_valuesToObject.tpl new file mode 100644 index 00000000..cf6e37ca --- /dev/null +++ b/charts/library/common/templates/lib/serviceAccount/_valuesToObject.tpl @@ -0,0 +1,20 @@ +{{/* +Convert Secret values to an object +*/}} +{{- define "bjw-s.common.lib.serviceAccount.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the serviceAccount name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.name -}} + {{- $objectName = $objectValues.name -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the serviceAccount object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/serviceMonitor/_validate.tpl b/charts/library/common/templates/lib/serviceMonitor/_validate.tpl new file mode 100644 index 00000000..c63527a1 --- /dev/null +++ b/charts/library/common/templates/lib/serviceMonitor/_validate.tpl @@ -0,0 +1,11 @@ +{{/* +Validate serviceMonitor values +*/}} +{{- define "bjw-s.common.lib.serviceMonitor.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $serviceMonitorObject := .object -}} + + {{- if not $serviceMonitorObject.endpoints -}} + {{- fail (printf "endpoints are required for serviceMonitor with key \"%v\"" $serviceMonitorObject.identifier) -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/serviceMonitor/_valuesToObject.tpl b/charts/library/common/templates/lib/serviceMonitor/_valuesToObject.tpl new file mode 100644 index 00000000..febce01d --- /dev/null +++ b/charts/library/common/templates/lib/serviceMonitor/_valuesToObject.tpl @@ -0,0 +1,24 @@ +{{/* +Convert ServiceMonitor values to an object +*/}} +{{- define "bjw-s.common.lib.serviceMonitor.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- /* Determine and inject the ServiceMonitor name */ -}} + {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} + + {{- if $objectValues.nameOverride -}} + {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} + {{- else -}} + {{- if ne $identifier "main" -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} + {{- end -}} + {{- end -}} + {{- $_ := set $objectValues "name" $objectName -}} + {{- $_ := set $objectValues "identifier" $identifier -}} + + {{- /* Return the ServiceMonitor object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/statefulset/_validate.tpl b/charts/library/common/templates/lib/statefulset/_validate.tpl new file mode 100644 index 00000000..1bfcac73 --- /dev/null +++ b/charts/library/common/templates/lib/statefulset/_validate.tpl @@ -0,0 +1,23 @@ +{{/* +Validate StatefulSet values +*/}} +{{- define "bjw-s.common.lib.statefulset.validate" -}} + {{- $rootContext := .rootContext -}} + {{- $statefulsetValues := .object -}} + + {{- if and (ne $statefulsetValues.strategy "OnDelete") (ne $statefulsetValues.strategy "RollingUpdate") -}} + {{- fail (printf "Not a valid strategy type for StatefulSet. (controller: %s, strategy: %s)" $statefulsetValues.identifier $statefulsetValues.strategy) -}} + {{- end -}} + + {{- if not (empty (dig "statefulset" "volumeClaimTemplates" "" $statefulsetValues)) -}} + {{- range $index, $volumeClaimTemplate := $statefulsetValues.statefulset.volumeClaimTemplates -}} + {{- if empty (get . "size") -}} + {{- fail (printf "size is required for volumeClaimTemplate. (controller: %s, volumeClaimTemplate: %s)" $statefulsetValues.identifier $volumeClaimTemplate.name) -}} + {{- end -}} + + {{- if empty (get . "accessMode") -}} + {{- fail (printf "accessMode is required for volumeClaimTemplate. (controller: %s, volumeClaimTemplate: %s)" $statefulsetValues.identifier $volumeClaimTemplate.name) -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/statefulset/_valuesToObject.tpl b/charts/library/common/templates/lib/statefulset/_valuesToObject.tpl new file mode 100644 index 00000000..687f4ed8 --- /dev/null +++ b/charts/library/common/templates/lib/statefulset/_valuesToObject.tpl @@ -0,0 +1,14 @@ +{{/* +Convert StatefulSet values to an object +*/}} +{{- define "bjw-s.common.lib.statefulset.valuesToObject" -}} + {{- $rootContext := .rootContext -}} + {{- $identifier := .id -}} + {{- $objectValues := .values -}} + + {{- $strategy := default "RollingUpdate" $objectValues.strategy -}} + {{- $_ := set $objectValues "strategy" $strategy -}} + + {{- /* Return the StatefulSet object */ -}} + {{- $objectValues | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/statefulset/_volumeClaimTemplates.tpl b/charts/library/common/templates/lib/statefulset/_volumeClaimTemplates.tpl new file mode 100644 index 00000000..2d641431 --- /dev/null +++ b/charts/library/common/templates/lib/statefulset/_volumeClaimTemplates.tpl @@ -0,0 +1,45 @@ +{{/* +Basic VolumeClaimTemplate template +*/}} +{{- define "bjw-s.common.lib.statefulset.volumeclaimtemplate" -}} + {{- $rootContext := .rootContext -}} + {{- $values := .values -}} + +metadata: + name: {{ $values.name }} + {{- with ($values.labels | default dict) }} + labels: {{- toYaml . | nindent 10 }} + {{- end }} + {{- with ($values.annotations | default dict) }} + annotations: {{- toYaml . | nindent 10 }} + {{- end }} +spec: + accessModes: + - {{ $values.accessMode | quote }} + resources: + requests: + storage: {{ $values.size | quote }} + {{- if $values.storageClass }} + storageClassName: {{ if (eq "-" $values.storageClass) }}""{{- else }}{{ $values.storageClass | quote }}{{- end }} + {{- end }} +{{- end -}} + +{{/* +VolumeClaimTemplates for StatefulSet +*/}} +{{- define "bjw-s.common.lib.statefulset.volumeclaimtemplates" -}} + {{- $rootContext := .rootContext -}} + {{- $statefulsetObject := .statefulsetObject -}} + + {{- /* Default to empty list */ -}} + {{- $volumeClaimTemplates := list -}} + + {{- range $index, $volumeClaimTemplate := $statefulsetObject.statefulset.volumeClaimTemplates }} + {{- $vct := include "bjw-s.common.lib.statefulset.volumeclaimtemplate" (dict "rootContext" $rootContext "values" $volumeClaimTemplate) -}} + {{- $volumeClaimTemplates = append $volumeClaimTemplates ($vct | fromYaml) -}} + {{- end -}} + + {{- if not (empty $volumeClaimTemplates) -}} + {{ $volumeClaimTemplates | toYaml }} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/loader/_generate.tpl b/charts/library/common/templates/loader/_generate.tpl index 0c0fa214..e5ffaa1d 100644 --- a/charts/library/common/templates/loader/_generate.tpl +++ b/charts/library/common/templates/loader/_generate.tpl @@ -2,29 +2,14 @@ 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 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.pvcs" . | nindent 0 -}} {{- include "bjw-s.common.render.serviceAccount" . | nindent 0 -}} - {{- include "bjw-s.common.render.controller" . | nindent 0 -}} + {{- include "bjw-s.common.render.controllers" . | nindent 0 -}} {{- include "bjw-s.common.render.services" . | nindent 0 -}} {{- include "bjw-s.common.render.ingresses" . | nindent 0 -}} {{- include "bjw-s.common.render.serviceMonitors" . | nindent 0 -}} {{- include "bjw-s.common.render.routes" . | nindent 0 -}} - {{- include "bjw-s.common.render.configmaps" . | nindent 0 -}} + {{- include "bjw-s.common.render.configMaps" . | nindent 0 -}} {{- include "bjw-s.common.render.secrets" . | nindent 0 -}} {{- end -}} diff --git a/charts/library/common/templates/render/_configmaps.tpl b/charts/library/common/templates/render/_configmaps.tpl index f6965dc7..7d69205d 100644 --- a/charts/library/common/templates/render/_configmaps.tpl +++ b/charts/library/common/templates/render/_configmaps.tpl @@ -1,19 +1,26 @@ {{/* Renders the configMap objects required by the chart. */}} -{{- define "bjw-s.common.render.configmaps" -}} +{{- define "bjw-s.common.render.configMaps" -}} {{- /* Generate named configMaps as required */ -}} - {{- range $name, $configmap := .Values.configMaps -}} - {{- if $configmap.enabled -}} - {{- $configmapValues := $configmap -}} + {{- range $key, $configMap := .Values.configMaps }} + {{- /* Enable configMap by default, but allow override */ -}} + {{- $configMapEnabled := true -}} + {{- if hasKey $configMap "enabled" -}} + {{- $configMapEnabled = $configMap.enabled -}} + {{- end -}} - {{- /* set the default nameOverride to the configMap name */ -}} - {{- if not $configmapValues.nameOverride -}} - {{- $_ := set $configmapValues "nameOverride" $name -}} - {{ end -}} + {{- if $configMapEnabled -}} + {{- $configMapValues := (mustDeepCopy $configMap) -}} - {{- $_ := set $ "ObjectValues" (dict "configmap" $configmapValues) -}} - {{- include "bjw-s.common.class.configmap" $ | nindent 0 -}} + {{- /* Create object from the raw configMap values */ -}} + {{- $configMapObject := (include "bjw-s.common.lib.configMap.valuesToObject" (dict "rootContext" $ "id" $key "values" $configMapValues)) | fromYaml -}} + + {{- /* Perform validations on the configMap before rendering */ -}} + {{- include "bjw-s.common.lib.configMap.validate" (dict "rootContext" $ "object" $configMapObject) -}} + + {{/* Include the configMap class */}} + {{- include "bjw-s.common.class.configMap" (dict "rootContext" $ "object" $configMapObject) | nindent 0 -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/render/_controller.tpl b/charts/library/common/templates/render/_controller.tpl deleted file mode 100644 index ff8513ff..00000000 --- a/charts/library/common/templates/render/_controller.tpl +++ /dev/null @@ -1,18 +0,0 @@ -{{/* -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 "cronjob" -}} - {{- include "bjw-s.common.class.cronjob" . | 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 -}} diff --git a/charts/library/common/templates/render/_controllers.tpl b/charts/library/common/templates/render/_controllers.tpl new file mode 100644 index 00000000..a4703478 --- /dev/null +++ b/charts/library/common/templates/render/_controllers.tpl @@ -0,0 +1,41 @@ +{{/* +Renders the controller objects required by the chart. +*/}} +{{- define "bjw-s.common.render.controllers" -}} + {{- /* Generate named controller objects as required */ -}} + {{- range $key, $controller := .Values.controllers -}} + {{- /* Enable controller by default, but allow override */ -}} + {{- $controllerEnabled := true -}} + {{- if hasKey $controller "enabled" -}} + {{- $controllerEnabled = $controller.enabled -}} + {{- end -}} + + {{- if $controllerEnabled -}} + {{- $controllerValues := $controller -}} + + {{- /* Create object from the raw controller values */ -}} + {{- $controllerObject := (include "bjw-s.common.lib.controller.valuesToObject" (dict "rootContext" $ "id" $key "values" $controllerValues)) | fromYaml -}} + + {{- /* Perform validations on the controller before rendering */ -}} + {{- include "bjw-s.common.lib.controller.validate" (dict "rootContext" $ "object" $controllerObject) -}} + + {{- if eq $controllerObject.type "deployment" -}} + {{- $deploymentObject := (include "bjw-s.common.lib.deployment.valuesToObject" (dict "rootContext" $ "id" $key "values" $controllerObject)) | fromYaml -}} + {{- include "bjw-s.common.lib.deployment.validate" (dict "rootContext" $ "object" $deploymentObject) -}} + {{- include "bjw-s.common.class.deployment" (dict "rootContext" $ "object" $deploymentObject) | nindent 0 -}} + {{- else if eq $controllerObject.type "cronjob" -}} + {{- $cronjobObject := (include "bjw-s.common.lib.cronjob.valuesToObject" (dict "rootContext" $ "id" $key "values" $controllerObject)) | fromYaml -}} + {{- include "bjw-s.common.lib.cronjob.validate" (dict "rootContext" $ "object" $cronjobObject) -}} + {{- include "bjw-s.common.class.cronjob" (dict "rootContext" $ "object" $cronjobObject) | nindent 0 -}} + {{- else if eq $controllerObject.type "daemonset" -}} + {{- $daemonsetObject := (include "bjw-s.common.lib.daemonset.valuesToObject" (dict "rootContext" $ "id" $key "values" $controllerObject)) | fromYaml -}} + {{- include "bjw-s.common.lib.daemonset.validate" (dict "rootContext" $ "object" $daemonsetObject) -}} + {{- include "bjw-s.common.class.daemonset" (dict "rootContext" $ "object" $daemonsetObject) | nindent 0 -}} + {{- else if eq $controllerObject.type "statefulset" -}} + {{- $statefulsetObject := (include "bjw-s.common.lib.statefulset.valuesToObject" (dict "rootContext" $ "id" $key "values" $controllerObject)) | fromYaml -}} + {{- include "bjw-s.common.lib.statefulset.validate" (dict "rootContext" $ "object" $statefulsetObject) -}} + {{- include "bjw-s.common.class.statefulset" (dict "rootContext" $ "object" $statefulsetObject) | nindent 0 -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- end -}} diff --git a/charts/library/common/templates/render/_ingresses.tpl b/charts/library/common/templates/render/_ingresses.tpl index 6a7551b1..c0cbc24a 100644 --- a/charts/library/common/templates/render/_ingresses.tpl +++ b/charts/library/common/templates/render/_ingresses.tpl @@ -2,18 +2,25 @@ 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 -}} + {{- /* Generate named Ingresses as required */ -}} + {{- range $key, $ingress := .Values.ingress }} + {{- /* Enable Ingress by default, but allow override */ -}} + {{- $ingressEnabled := true -}} + {{- if hasKey $ingress "enabled" -}} + {{- $ingressEnabled = $ingress.enabled -}} + {{- end -}} - {{/* set defaults */}} - {{- if and (not $ingressValues.nameOverride) (ne $name (include "bjw-s.common.lib.ingress.primary" $)) -}} - {{- $_ := set $ingressValues "nameOverride" $name -}} - {{- end -}} + {{- if $ingressEnabled -}} + {{- $ingressValues := (mustDeepCopy $ingress) -}} - {{- $_ := set $ "ObjectValues" (dict "ingress" $ingressValues) -}} - {{- include "bjw-s.common.class.ingress" $ | nindent 0 -}} + {{- /* Create object from the raw ingress values */ -}} + {{- $ingressObject := (include "bjw-s.common.lib.ingress.valuesToObject" (dict "rootContext" $ "id" $key "values" $ingressValues)) | fromYaml -}} + + {{- /* Perform validations on the ingress before rendering */ -}} + {{- include "bjw-s.common.lib.ingress.validate" (dict "rootContext" $ "object" $ingressObject) -}} + + {{/* Include the ingress class */}} + {{- include "bjw-s.common.class.ingress" (dict "rootContext" $ "object" $ingressObject) | nindent 0 -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/render/_pvcs.tpl b/charts/library/common/templates/render/_pvcs.tpl index 29ec5c83..f69947a8 100644 --- a/charts/library/common/templates/render/_pvcs.tpl +++ b/charts/library/common/templates/render/_pvcs.tpl @@ -3,14 +3,18 @@ Renders the Persistent Volume Claim objects required by the chart. */}} {{- define "bjw-s.common.render.pvcs" -}} {{- /* Generate pvc as required */ -}} - {{- range $index, $PVC := .Values.persistence -}} - {{- if and $PVC.enabled (eq (default "pvc" $PVC.type) "pvc") (not $PVC.existingClaim) -}} - {{- $persistenceValues := $PVC -}} - {{- if not $persistenceValues.nameOverride -}} - {{- $_ := set $persistenceValues "nameOverride" $index -}} - {{- end -}} - {{- $_ := set $ "ObjectValues" (dict "persistence" $persistenceValues) -}} - {{- include "bjw-s.common.class.pvc" $ | nindent 0 -}} + {{- range $key, $pvc := .Values.persistence -}} + {{- if and $pvc.enabled (eq (default "persistentVolumeClaim" $pvc.type) "persistentVolumeClaim") (not $pvc.existingClaim) -}} + {{- $pvcValues := (mustDeepCopy $pvc) -}} + + {{- /* Create object from the raw PVC values */ -}} + {{- $pvcObject := (include "bjw-s.common.lib.pvc.valuesToObject" (dict "rootContext" $ "id" $key "values" $pvcValues)) | fromYaml -}} + + {{- /* Perform validations on the PVC before rendering */ -}} + {{- include "bjw-s.common.lib.pvc.validate" (dict "rootContext" $ "object" $pvcValues) -}} + + {{- /* Include the PVC class */ -}} + {{- include "bjw-s.common.class.pvc" (dict "rootContext" $ "object" $pvcValues) | nindent 0 -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/render/_routes.tpl b/charts/library/common/templates/render/_routes.tpl index cb388ebd..12e89caa 100644 --- a/charts/library/common/templates/render/_routes.tpl +++ b/charts/library/common/templates/render/_routes.tpl @@ -1,18 +1,24 @@ {{/* Renders the Route objects required by the chart */}} {{- define "bjw-s.common.render.routes" -}} {{- /* Generate named routes as required */ -}} - {{- range $name, $route := .Values.route }} - {{- if $route.enabled -}} - {{- $routeValues := $route -}} + {{- range $key, $route := .Values.route }} + {{- /* Enable Route by default, but allow override */ -}} + {{- $routeEnabled := true -}} + {{- if hasKey $route "enabled" -}} + {{- $routeEnabled = $route.enabled -}} + {{- end -}} - {{/* set defaults */}} - {{- if and (not $routeValues.nameOverride) (ne $name (include "bjw-s.common.lib.route.primary" $)) -}} - {{- $_ := set $routeValues "nameOverride" $name -}} - {{- end -}} + {{- if $routeEnabled -}} + {{- $routeValues := (mustDeepCopy $route) -}} - {{- $_ := set $ "ObjectValues" (dict "route" $routeValues) -}} - {{- include "bjw-s.common.class.route" $ | nindent 0 -}} - {{- $_ := unset $.ObjectValues "route" -}} + {{- /* Create object from the raw Route values */ -}} + {{- $routeObject := (include "bjw-s.common.lib.route.valuesToObject" (dict "rootContext" $ "id" $key "values" $routeValues)) | fromYaml -}} + + {{- /* Perform validations on the Route before rendering */ -}} + {{- include "bjw-s.common.lib.route.validate" (dict "rootContext" $ "object" $routeObject) -}} + + {{- /* Include the Route class */ -}} + {{- include "bjw-s.common.class.route" (dict "rootContext" $ "object" $routeObject) | nindent 0 -}} {{- end }} {{- end }} {{- end }} diff --git a/charts/library/common/templates/render/_secrets.tpl b/charts/library/common/templates/render/_secrets.tpl index 16d5121b..feaaed2d 100644 --- a/charts/library/common/templates/render/_secrets.tpl +++ b/charts/library/common/templates/render/_secrets.tpl @@ -3,17 +3,24 @@ 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 -}} + {{- range $key, $secret := .Values.secrets }} + {{- /* Enable Secret by default, but allow override */ -}} + {{- $secretEnabled := true -}} + {{- if hasKey $secret "enabled" -}} + {{- $secretEnabled = $secret.enabled -}} + {{- end -}} - {{- /* set the default nameOverride to the Secret name */ -}} - {{- if not $secretValues.nameOverride -}} - {{- $_ := set $secretValues "nameOverride" $name -}} - {{ end -}} + {{- if $secretEnabled -}} + {{- $secretValues := (mustDeepCopy $secret) -}} - {{- $_ := set $ "ObjectValues" (dict "secret" $secretValues) -}} - {{- include "bjw-s.common.class.secret" $ | nindent 0 -}} + {{- /* Create object from the raw Secret values */ -}} + {{- $secretObject := (include "bjw-s.common.lib.secret.valuesToObject" (dict "rootContext" $ "id" $key "values" $secretValues)) | fromYaml -}} + + {{- /* Perform validations on the Secret before rendering */ -}} + {{- include "bjw-s.common.lib.secret.validate" (dict "rootContext" $ "object" $secretObject) -}} + + {{/* Include the Secret class */}} + {{- include "bjw-s.common.class.secret" (dict "rootContext" $ "object" $secretObject) | nindent 0 -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/render/_serviceMonitors.tpl b/charts/library/common/templates/render/_serviceMonitors.tpl index eec3c5d9..ab8c1ff2 100644 --- a/charts/library/common/templates/render/_serviceMonitors.tpl +++ b/charts/library/common/templates/render/_serviceMonitors.tpl @@ -2,19 +2,25 @@ 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 -}} + {{- /* Generate named serviceMonitors as required */ -}} + {{- range $key, $serviceMonitor := .Values.serviceMonitor -}} + {{- /* Enable ServiceMonitor by default, but allow override */ -}} + {{- $serviceMonitorEnabled := true -}} + {{- if hasKey $serviceMonitor "enabled" -}} + {{- $serviceMonitorEnabled = $serviceMonitor.enabled -}} + {{- end -}} - {{- if and (not $serviceMonitorValues.nameOverride) (ne $name "main") -}} - {{- $_ := set $serviceMonitorValues "nameOverride" $name -}} - {{- end -}} + {{- if $serviceMonitorEnabled -}} + {{- $serviceMonitorValues := (mustDeepCopy $serviceMonitor) -}} + + {{- /* Create object from the raw ServiceMonitor values */ -}} + {{- $serviceMonitorObject := (include "bjw-s.common.lib.serviceMonitor.valuesToObject" (dict "rootContext" $ "id" $key "values" $serviceMonitorValues)) | fromYaml -}} + + {{- /* Perform validations on the serviceMonitor before rendering */ -}} + {{- include "bjw-s.common.lib.serviceMonitor.validate" (dict "rootContext" $ "object" $serviceMonitorObject) -}} {{/* Include the serviceMonitor class */}} - {{- $_ := set $ "ObjectValues" (dict "serviceMonitor" $serviceMonitorValues) -}} - {{- include "bjw-s.common.class.serviceMonitor" $ | nindent 0 -}} - {{- $_ := unset $.ObjectValues "serviceMonitor" -}} + {{- include "bjw-s.common.class.serviceMonitor" (dict "rootContext" $ "object" $serviceMonitorObject) | nindent 0 -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/render/_serviceaccount.tpl b/charts/library/common/templates/render/_serviceaccount.tpl index f26a8404..ad6f49a6 100644 --- a/charts/library/common/templates/render/_serviceaccount.tpl +++ b/charts/library/common/templates/render/_serviceaccount.tpl @@ -3,11 +3,18 @@ Renders the serviceAccount object required by the chart. */}} {{- define "bjw-s.common.render.serviceAccount" -}} {{- if .Values.serviceAccount.create -}} + {{- $serviceAccountValues := (mustDeepCopy .Values.serviceAccount) -}} + + {{- /* Create object from the raw ServiceAccount values */ -}} + {{- $serviceAccountObject := (include "bjw-s.common.lib.serviceAccount.valuesToObject" (dict "rootContext" $ "id" "default" "values" $serviceAccountValues)) | fromYaml -}} + + {{- /* Perform validations on the ServiceAccount before rendering */ -}} + {{- include "bjw-s.common.lib.serviceAccount.validate" (dict "rootContext" $ "object" $serviceAccountObject) -}} + + {{/* Include the serviceAccount class */}} + {{- include "bjw-s.common.class.serviceAccount" (dict "rootContext" $ "object" $serviceAccountObject) | nindent 0 -}} {{- /* Create a service account secret */ -}} - {{- $serviceAccountName := include "bjw-s.common.lib.chart.names.serviceAccountName" . -}} - {{- $_ := set .Values.secrets "sa-token" (dict "enabled" true "annotations" (dict "kubernetes.io/service-account.name" $serviceAccountName) "type" "kubernetes.io/service-account-token") -}} - - {{- include "bjw-s.common.class.serviceAccount" $ | nindent 0 -}} + {{- $_ := set .Values.secrets "sa-token" (dict "enabled" true "annotations" (dict "kubernetes.io/service-account.name" $serviceAccountObject.name) "type" "kubernetes.io/service-account-token") -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/render/_services.tpl b/charts/library/common/templates/render/_services.tpl index 46e18f27..cf6f6ee8 100644 --- a/charts/library/common/templates/render/_services.tpl +++ b/charts/library/common/templates/render/_services.tpl @@ -2,24 +2,18 @@ Renders the Service objects required by the chart. */}} {{- define "bjw-s.common.render.services" -}} - {{- /* Generate named services as required */ -}} - {{- range $name, $service := .Values.service -}} - {{- $serviceEnabled := true -}} - {{- if hasKey $service "enabled" -}} - {{- $serviceEnabled = $service.enabled -}} - {{- end -}} - {{- if $serviceEnabled -}} - {{- $serviceValues := $service -}} + {{- /* Generate named Services as required */ -}} + {{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $) | fromYaml ) -}} + {{- range $key, $svc := $enabledServices -}} + {{- $serviceValues := (mustDeepCopy $svc) -}} - {{/* 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 -}} + {{- /* Create object from the raw Service values */ -}} + {{- $serviceObject := (include "bjw-s.common.lib.service.valuesToObject" (dict "rootContext" $ "id" $key "values" $serviceValues)) | fromYaml -}} - {{/* Include the Service class */}} - {{- $_ := set $ "ObjectValues" (dict "service" $serviceValues) -}} - {{- include "bjw-s.common.class.service" $ | nindent 0 -}} - {{- $_ := unset $.ObjectValues "service" -}} - {{- end -}} + {{- /* Perform validations on the Service before rendering */ -}} + {{- include "bjw-s.common.lib.service.validate" (dict "rootContext" $ "object" $serviceObject) -}} + + {{- /* Include the Service class */ -}} + {{- include "bjw-s.common.class.service" (dict "rootContext" $ "object" $serviceObject) | nindent 0 -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/values/_init.tpl b/charts/library/common/templates/values/_init.tpl index c9caa665..e9a7af8f 100644 --- a/charts/library/common/templates/values/_init.tpl +++ b/charts/library/common/templates/values/_init.tpl @@ -5,7 +5,6 @@ Merge the local chart values and the common chart defaults {{- if .Values.common -}} {{- $defaultValues := deepCopy .Values.common -}} {{- $userValues := deepCopy (omit .Values "common") -}} - {{- $_ := set $defaultValues "additionalContainers" dict -}} {{- $mergedValues := mustMergeOverwrite $defaultValues $userValues -}} {{- $_ := set . "Values" (deepCopy $mergedValues) -}} {{- end -}} diff --git a/charts/library/common/values.yaml b/charts/library/common/values.yaml index 8458b45b..7686d095 100644 --- a/charts/library/common/values.yaml +++ b/charts/library/common/values.yaml @@ -9,78 +9,309 @@ global: # -- Set additional global annotations. Helm templates can be used. annotations: {} -controller: - # -- enable the controller. - enabled: true - # -- Set the controller type. - # Valid options are deployment, daemonset, statefulset or cronjob - type: deployment - # -- Set annotations on the deployment/statefulset/daemonset/cronjob +# -- Set default options for all controllers / pods here +# Each of these options can be overridden on a Pod level +defaultPodOptions: + # -- Defines affinity constraint rules. + # [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) + affinity: {} + + # -- Set annotations on the Pod. Pod-specific values will be merged with this. annotations: {} - # -- Set labels on the deployment/statefulset/daemonset/cronjob + + # -- Specifies whether a service account token should be automatically mounted. + automountServiceAccountToken: true + + # -- Configuring the ndots option may resolve nslookup issues on some Kubernetes setups. + dnsConfig: + {} + # options: + # - name: ndots + # value: "1" + + # -- Defaults to "ClusterFirst" if hostNetwork is false + # and "ClusterFirstWithHostNet" if hostNetwork is true. + dnsPolicy: # ClusterFirst + + # -- Enable/disable the generation of environment variables for services. + # [[ref]](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service) + enableServiceLinks: true + + # -- Allows specifying explicit hostname setting + hostname: + + # -- Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. + # [[ref]](https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/) + hostAliases: [] + # - ip: "192.168.1.100" + # hostnames: + # - "example.com" + # - "www.example.com" + + # -- Use the host's ipc namespace + hostIPC: false + + # -- When using hostNetwork make sure you set dnsPolicy to `ClusterFirstWithHostNet` + hostNetwork: false + + # -- Use the host's pid namespace + hostPID: false + + # -- Set image pull secrets + imagePullSecrets: [] + + # -- Set labels on the Pod. Pod-specific values will be merged with this. labels: {} - # -- Number of desired pods. When using a HorizontalPodAutoscaler, set this to `null`. - replicas: 1 - # -- Set the controller upgrade strategy - # For Deployments, valid values are Recreate (default) and RollingUpdate. - # For StatefulSets, valid values are OnDelete and RollingUpdate (default). - # DaemonSets/CronJobs ignore this. - strategy: - rollingUpdate: - # -- Set deployment RollingUpdate max unavailable - unavailable: - # -- Set deployment RollingUpdate max surge - surge: - # -- Set statefulset RollingUpdate partition - partition: - # -- ReplicaSet revision history limit - revisionHistoryLimit: 3 - # -- Set statefulset podManagementPolicy, valid values are Parallel and OrderedReady (default). - podManagementPolicy: + + # -- Node selection constraint + # [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) + nodeSelector: {} + + # -- Custom priority class for different treatment by the scheduler + priorityClassName: # system-node-critical + # -- Set Container restart policy. # @default -- `Always`. When `controller.type` is `cronjob` it defaults to `Never`. restartPolicy: - # -- CronJob configuration. Required only when using `controller.type: cronjob`. - # @default -- See below - cronjob: - # -- Specifies how to treat concurrent executions of a job that is created by this cron job - # valid values are Allow, Forbid or Replace - concurrencyPolicy: Forbid - # -- Sets the CronJob time when to execute your jobs - schedule: "*/20 * * * *" - # -- The deadline in seconds for starting the job if it misses its scheduled time for any reason - startingDeadlineSeconds: 30 - # -- The number of succesful Jobs to keep - successfulJobsHistory: 1 - # -- The number of failed Jobs to keep - failedJobsHistory: 1 - # -- If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to - # be automatically deleted. - ttlSecondsAfterFinished: - # -- Limits the number of times a failed job will be retried - backoffLimit: 6 -image: - # -- image repository - repository: - # -- image tag - tag: - # -- image pull policy - pullPolicy: + # -- Allow specifying a runtimeClassName other than the default one (ie: nvidia) + runtimeClassName: # nvidia -# -- Set image pull secrets -imagePullSecrets: [] + # -- Allows specifying a custom scheduler name + schedulerName: # awkward-dangerous-scheduler -# -- Override the command(s) for the default container -command: [] -# -- Override the args for the default container -args: [] + # -- Configure the Security Context for the Pod + securityContext: {} -# -- Set annotations on the pod -podAnnotations: {} + # -- Duration in seconds the pod needs to terminate gracefully + # -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)] + terminationGracePeriodSeconds: -# -- Set labels on the pod -podLabels: {} + # -- Specify taint tolerations + # [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) + tolerations: [] + + # -- Defines topologySpreadConstraint rules. + # [[ref]](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) + topologySpreadConstraints: [] + # - maxSkew: + # topologyKey: + # whenUnsatisfiable: + # labelSelector: + +controllers: + main: + # -- enable the controller. + enabled: true + + # -- Set the controller type. + # Valid options are deployment, daemonset, statefulset or cronjob + type: deployment + # -- Set annotations on the deployment/statefulset/daemonset/cronjob + annotations: {} + # -- Set labels on the deployment/statefulset/daemonset/cronjob + labels: {} + # -- Number of desired pods. When using a HorizontalPodAutoscaler, set this to `null`. + replicas: 1 + # -- Set the controller upgrade strategy + # For Deployments, valid values are Recreate (default) and RollingUpdate. + # For StatefulSets, valid values are OnDelete and RollingUpdate (default). + # DaemonSets/CronJobs ignore this. + strategy: + + rollingUpdate: + # -- Set deployment RollingUpdate max unavailable + unavailable: + # -- Set deployment RollingUpdate max surge + surge: + # -- Set statefulset RollingUpdate partition + partition: + # -- ReplicaSet revision history limit + revisionHistoryLimit: 3 + + # -- CronJob configuration. Required only when using `controller.type: cronjob`. + # @default -- See below + cronjob: + # -- Specifies how to treat concurrent executions of a job that is created by this cron job + # valid values are Allow, Forbid or Replace + concurrencyPolicy: Forbid + # -- Sets the CronJob time when to execute your jobs + schedule: "*/20 * * * *" + # -- The deadline in seconds for starting the job if it misses its scheduled time for any reason + startingDeadlineSeconds: 30 + # -- The number of succesful Jobs to keep + successfulJobsHistory: 1 + # -- The number of failed Jobs to keep + failedJobsHistory: 1 + # -- If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to + # be automatically deleted. + ttlSecondsAfterFinished: + # -- Limits the number of times a failed job will be retried + backoffLimit: 6 + + # -- StatefulSet configuration. Required only when using `controller.type: statefulset`. + statefulset: + # -- Set podManagementPolicy, valid values are Parallel and OrderedReady (default). + podManagementPolicy: + + # -- Used to create individual disks for each instance. + volumeClaimTemplates: [] + # - name: data + # labels: {} + # annotations: {} + # mountPath: /data + # accessMode: "ReadWriteOnce" + # size: 1Gi + # - name: backup + # labels: {} + # annotations: {} + # mountPath: /backup + # subPath: theSubPath + # accessMode: "ReadWriteOnce" + # size: 2Gi + # storageClass: cheap-storage-class + + containers: + main: + # -- Override the container name + nameOverride: + + image: + # -- image repository + repository: + # -- image tag + tag: + # -- image pull policy + pullPolicy: + + # -- Override the command(s) for the default container + command: [] + # -- Override the args for the default container + args: [] + + # -- Environment variables. Template enabled. + # Syntax options: + # A) TZ: UTC + # B) PASSWD: '{{ .Release.Name }}' + # C) PASSWD: + # configMapKeyRef: + # name: config-map-name + # key: key-name + # D) PASSWD: + # valueFrom: + # secretKeyRef: + # name: secret-name + # key: key-name + # ... + # E) - name: TZ + # value: UTC + # F) - name: TZ + # value: '{{ .Release.Name }}' + env: + + # -- Secrets and/or ConfigMaps that will be loaded as environment variables. + # [[ref]](https://unofficial-kubernetes.readthedocs.io/en/latest/tasks/configure-pod-container/configmap/#use-case-consume-configmap-in-environment-variables) + envFrom: [] + # - configMapRef: + # name: config-map-name + # - secretRef: + # name: secret-name + + # -- Probe configuration + # -- [[ref]](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) + # @default -- See below + probes: + # -- Liveness probe configuration + # @default -- See below + liveness: + # -- Enable the liveness probe + enabled: true + # -- Set this to `true` if you wish to specify your own livenessProbe + custom: false + # -- sets the probe type when not using a custom probe + # @default -- "TCP" + type: TCP + # -- The spec field contains the values for the default livenessProbe. + # If you selected `custom: true`, this field holds the definition of the livenessProbe. + # @default -- See below + spec: + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + # -- Redainess probe configuration + # @default -- See below + readiness: + # -- Enable the readiness probe + enabled: true + # -- Set this to `true` if you wish to specify your own readinessProbe + custom: false + # -- sets the probe type when not using a custom probe + # @default -- "TCP" + type: TCP + # -- The spec field contains the values for the default readinessProbe. + # If you selected `custom: true`, this field holds the definition of the readinessProbe. + # @default -- See below + spec: + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + + # -- Startup probe configuration + # @default -- See below + startup: + # -- Enable the startup probe + enabled: true + # -- Set this to `true` if you wish to specify your own startupProbe + custom: false + # -- sets the probe type when not using a custom probe + # @default -- "TCP" + type: TCP + # -- The spec field contains the values for the default startupProbe. + # If you selected `custom: true`, this field holds the definition of the startupProbe. + # @default -- See below + spec: + initialDelaySeconds: 0 + timeoutSeconds: 1 + ## This means it has a maximum of 5*30=150 seconds to start up before it fails + periodSeconds: 5 + failureThreshold: 30 + + # -- Set the resource requests / limits for the container. + resources: + {} + ## We usually recommend not to specify default resources and to leave this as a conscious + ## choice for the user. This also increases chances charts run on environments with little + ## resources, such as Minikube. If you do want to specify resources, uncomment the following + ## lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + # -- Configure the Security Context for the container + securityContext: {} + + # -- Configure the lifecycle for the container + lifecycle: {} + + # -- Configure the path at which the file to which the containers termination message will be written. + # -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] + terminationMessagePath: + + # -- Indicate how the containers 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)] + terminationMessagePolicy: + + # -- Specify any initContainers here as dictionary items. + # Each initContainer should have its own key. The dictionary item key will determine the order. + # Helm templates can be used. + initContainers: {} serviceAccount: # -- Specifies whether a service account should be created @@ -89,13 +320,13 @@ serviceAccount: # -- Annotations to add to the service account annotations: {} + # -- Labels to add to the service account + labels: {} + # -- The name of the service account to use. # If not set and create is true, a name is generated using the fullname template name: "" -# -- Specifies whether a service account token should be automatically mounted. -automountServiceAccountToken: true - # -- Use this to populate 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. @@ -130,164 +361,6 @@ configMaps: {} # foo: bar -# -- Main environment variables. Template enabled. -# Syntax options: -# A) TZ: UTC -# B) PASSWD: '{{ .Release.Name }}' -# C) PASSWD: -# configMapKeyRef: -# name: config-map-name -# key: key-name -# D) PASSWD: -# valueFrom: -# secretKeyRef: -# name: secret-name -# key: key-name -# ... -# E) - name: TZ -# value: UTC -# F) - name: TZ -# value: '{{ .Release.Name }}' -env: - -# -- Secrets and/or ConfigMaps that will be loaded as environment variables. -# [[ref]](https://unofficial-kubernetes.readthedocs.io/en/latest/tasks/configure-pod-container/configmap/#use-case-consume-configmap-in-environment-variables) -envFrom: [] -# - configMapRef: -# name: config-map-name -# - secretRef: -# name: secret-name - -# -- Custom priority class for different treatment by the scheduler -priorityClassName: # system-node-critical - -# -- Allow specifying a runtimeClassName other than the default one (ie: nvidia) -runtimeClassName: # nvidia - -# -- Allows specifying a custom scheduler name -schedulerName: # awkward-dangerous-scheduler - -# -- Allows specifying explicit hostname setting -hostname: - -# -- Use the host's ipc namespace -hostIPC: false - -# -- When using hostNetwork make sure you set dnsPolicy to `ClusterFirstWithHostNet` -hostNetwork: false - -# -- Use the host's pid namespace -hostPID: false - -# -- Defaults to "ClusterFirst" if hostNetwork is false -# and "ClusterFirstWithHostNet" if hostNetwork is true. -dnsPolicy: # ClusterFirst - -# -- Configuring the ndots option may resolve nslookup issues on some Kubernetes setups. -dnsConfig: {} -# options: -# - name: ndots -# value: "1" - -# -- Enable/disable the generation of environment variables for services. -# [[ref]](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service) -enableServiceLinks: true - -# -- Configure the Security Context for the Pod -podSecurityContext: {} - -# -- Configure the Security Context for the main container -securityContext: {} - -# -- Configure the lifecycle for the main container -lifecycle: {} - -# -- Specify any initContainers here as dictionary items. -# Each initContainer should have its own key. The dictionary item key will determine the order. -# Helm templates can be used. -initContainers: {} - -# -- Specify any sidecar containers here as dictionary items. -# Each sidecar container should have its own key. The dictionary item key will determine the order. -# Helm templates can be used. -sidecars: {} - -# -- Probe configuration -# -- [[ref]](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) -# @default -- See below -probes: - # -- Liveness probe configuration - # @default -- See below - liveness: - # -- Enable the liveness probe - enabled: true - # -- Set this to `true` if you wish to specify your own livenessProbe - custom: false - # -- sets the probe type when not using a custom probe - # @default -- "TCP" - type: TCP - # -- The spec field contains the values for the default livenessProbe. - # If you selected `custom: true`, this field holds the definition of the livenessProbe. - # @default -- See below - spec: - initialDelaySeconds: 0 - periodSeconds: 10 - timeoutSeconds: 1 - failureThreshold: 3 - - # -- Redainess probe configuration - # @default -- See below - readiness: - # -- Enable the readiness probe - enabled: true - # -- Set this to `true` if you wish to specify your own readinessProbe - custom: false - # -- sets the probe type when not using a custom probe - # @default -- "TCP" - type: TCP - # -- The spec field contains the values for the default readinessProbe. - # If you selected `custom: true`, this field holds the definition of the readinessProbe. - # @default -- See below - spec: - initialDelaySeconds: 0 - periodSeconds: 10 - timeoutSeconds: 1 - failureThreshold: 3 - - # -- Startup probe configuration - # @default -- See below - startup: - # -- Enable the startup probe - enabled: true - # -- Set this to `true` if you wish to specify your own startupProbe - custom: false - # -- sets the probe type when not using a custom probe - # @default -- "TCP" - type: TCP - # -- The spec field contains the values for the default startupProbe. - # If you selected `custom: true`, this field holds the definition of the startupProbe. - # @default -- See below - spec: - initialDelaySeconds: 0 - timeoutSeconds: 1 - ## This means it has a maximum of 5*30=150 seconds to start up before it fails - periodSeconds: 5 - failureThreshold: 30 - -termination: - # -- Configure the path at which the file to which the main container's termination message will be written. - # -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] - messagePath: - - # -- Indicate how the main container's termination message should be populated. - # Valid options are `File` and `FallbackToLogsOnError`. - # -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle-1)] - messagePolicy: - - # -- Duration in seconds the pod needs to terminate gracefully - # -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)] - gracePeriodSeconds: - # -- Configure the services for the chart here. # Additional services can be added by adding a dictionary key similar to the 'main' service. # @default -- See below @@ -296,13 +369,17 @@ service: # -- Enables or disables the service enabled: true - # -- Make this the primary service (used in probes, notes, etc...). - # If there is more than 1 service, make sure that only 1 service is marked as primary. - primary: true - # -- Override the name suffix that is used for this service nameOverride: + # -- Configure which controller this service should target + controller: main + + # -- Make this the primary service for this controller (used in probes, notes, etc...). + # If there is more than 1 service targeting the controller, make sure that only 1 service is + # marked as primary. + primary: true + # -- Set the service type type: ClusterIP @@ -321,6 +398,9 @@ service: # -- Provide additional labels which may be required. labels: {} + # -- Allow adding additional match labels + extraSelectorLabels: {} + # -- Configure the Service port information here. # Additional ports can be added by adding a dictionary key similar to the 'http' service. # @default -- See below @@ -338,7 +418,7 @@ service: # -- Port protocol. # Support values are `HTTP`, `HTTPS`, `TCP` and `UDP`. - # HTTPS and HTTPS spawn a TCP service and get used for internal URL and name generation + # HTTP and HTTPS spawn a TCP service and get used for internal URL and name generation protocol: HTTP # -- Specify a service targetPort if you wish to differ the service port from the application port. @@ -350,9 +430,6 @@ service: # [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-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 @@ -412,7 +489,7 @@ ingress: labels: {} # -- Set the ingressClass that is used for this ingress. - ingressClassName: # "nginx" + className: # "nginx" ## Configure the hosts for the ingress hosts: @@ -425,8 +502,10 @@ ingress: pathType: Prefix service: # -- Overrides the service name reference for this path - name: - # -- Overrides the service port reference for this path + # This can be an actual service name, or reference a service identifier + # from this values.yaml + name: main + # -- Overrides the service port number reference for this path port: # -- Configure TLS for the ingress. Both secretName and hosts can process a Helm template. @@ -479,7 +558,7 @@ route: backendRefs: - group: "" kind: Service - name: + name: main namespace: port: weight: 1 @@ -494,24 +573,13 @@ route: # [[ref]](https://bjw-s.github.io/helm-charts/docs/common-library/common-library-storage) # @default -- See below persistence: - # -- Default persistence for configuration files. - # @default -- See below config: - # -- Enables or disables the persistence item + # -- Enables or disables the persistence item. Defaults to true enabled: false # -- Sets the persistence type - # Valid options are pvc, emptyDir, hostPath, secret, configMap or custom - type: pvc - - # -- Where to mount the volume in the main container. - # Defaults to `/`, - # setting to '-' creates the volume but disables the volumeMount. - mountPath: # /config - # -- Specify if the volume should be mounted read-only. - readOnly: false - # -- Override the name suffix that is used for this volume. - nameOverride: + # Valid options are persistentVolumeClaim, emptyDir, hostPath, secret, configMap or custom + type: persistentVolumeClaim # -- Storage Class for the config volume. # If set to `-`, dynamic provisioning is disabled. @@ -522,9 +590,6 @@ persistence: # -- If you want to reuse an existing claim, the name of the existing PVC can be passed here. existingClaim: # your-claim - # -- Used in conjunction with `existingClaim`. Specifies a sub-path inside the referenced volume instead of its root - subPath: # some-subpath - # -- AccessMode for the persistent volume. # Make sure to select an access mode that is supported by your storage provider! # [[ref]](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) @@ -536,305 +601,28 @@ persistence: # -- Set to true to retain the PVC upon `helm uninstall` retain: false - # -- Create an emptyDir volume to share between all containers - # [[ref]]https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) - # @default -- See below - shared: - enabled: false - type: emptyDir - mountPath: /shared + # -- Configure mounts to all controllers and containers. By default the persistence item + # will be mounted to `/`. + # Example: + # globalMounts: + # - path: /config + # readOnly: false + globalMounts: [] - # -- Set the medium to "Memory" to mount a tmpfs (RAM-backed filesystem) instead - # of the storage medium that backs the node. - medium: # Memory - - # -- If the `SizeMemoryBackedVolumes` feature gate is enabled, you can - # specify a size for memory backed volumes. - sizeLimit: # 1Gi - -# -- Used in conjunction with `controller.type: statefulset` to create individual disks for each instance. -volumeClaimTemplates: [] -# - name: data -# labels: {} -# annotations: {} -# mountPath: /data -# accessMode: "ReadWriteOnce" -# size: 1Gi -# - name: backup -# labels: {} -# annotations: {} -# mountPath: /backup -# subPath: theSubPath -# accessMode: "ReadWriteOnce" -# size: 2Gi -# storageClass: cheap-storage-class - -# -- Node selection constraint -# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector) -nodeSelector: {} - -# -- Defines affinity constraint rules. -# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) -affinity: {} - -# -- Defines topologySpreadConstraint rules. -# [[ref]](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) -topologySpreadConstraints: [] -# - maxSkew: -# topologyKey: -# whenUnsatisfiable: -# labelSelector: - -# -- Specify taint tolerations -# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) -tolerations: [] - -# -- Use hostAliases to add custom entries to /etc/hosts - mapping IP addresses to hostnames. -# [[ref]](https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/) -hostAliases: [] -# - ip: "192.168.1.100" -# hostnames: -# - "example.com" -# - "www.example.com" - -# -- Set the resource requests / limits for the main container. -resources: - {} - ## We usually recommend not to specify default resources and to leave this as a conscious - ## choice for the user. This also increases chances charts run on environments with little - ## resources, such as Minikube. If you do want to specify resources, uncomment the following - ## lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -# -- The common chart supports several add-ons. These can be configured under this key. -# @default -- See below -addons: - # -- The common chart supports adding a VPN add-on. It can be configured under this key. - # @default -- See values.yaml - vpn: - # -- Enable running a VPN in the pod to route traffic through a VPN - enabled: false - - # -- Specify the VPN type. Valid options are `gluetun`. - type: gluetun - - # -- Gluetun specific configuration - # -- Make sure to read the [documentation](https://github.com/qdm12/gluetun/wiki) - # to see how to configure this addon! - # @default -- See below - gluetun: - image: - # -- Specify the Gluetun image - repository: docker.io/qmcgaw/gluetun - # -- Specify the Gluetun image tag - tag: v3.34.3 - # -- Specify the Gluetun image pull policy - pullPolicy: IfNotPresent - - # -- Set the VPN container securityContext - # @default -- See values.yaml - securityContext: - capabilities: - add: - - NET_ADMIN - - SYS_MODULE - - # -- All variables specified here will be added to the vpn sidecar container - # See the documentation of the VPN image for all config values - env: - {} - # TZ: UTC - - # -- Override the args for the vpn sidecar container - args: [] - - # -- Provide a customized vpn configuration file to be used by the VPN. - configFile: - # |- - # Some Example Config - # remote greatvpnhost.com 8888 - # auth-user-pass - # Cipher AES - - # -- Reference an existing secret that contains the VPN configuration file - # The chart expects it to be present under the `vpnConfigfile` key. - configFileSecret: - - # -- Provide custom up/down scripts that can be used by the vpn configuration. - # @default -- See values.yaml - scripts: - # @default -- See below - up: - # |- - # !/bin/bash - # echo "connected" > /shared/vpnstatus - - # @default -- See below - down: - # |- - # #!/bin/bash - # echo "disconnected" > /shared/vpnstatus - - additionalVolumeMounts: [] - - # -- Optionally specify a livenessProbe, e.g. to check if the connection is still - # being protected by the VPN - livenessProbe: - {} - # exec: - # command: - # - sh - # - -c - # - if [ $(curl -s https://ipinfo.io/country) == 'US' ]; then exit 0; else exit $?; fi - # initialDelaySeconds: 30 - # periodSeconds: 60 - # failureThreshold: 1 - - networkPolicy: - # -- If set to true, will deploy a network policy that blocks all outbound - # traffic except traffic specified as allowed - enabled: false - - # -- Provide additional annotations which may be required. - annotations: {} - - # -- Provide additional labels which may be required. - labels: {} - - # -- Provide additional podSelector labels which may be required. - podSelectorLabels: {} - - # -- The egress configuration for your network policy, All outbound traffic - # from the pod will be blocked unless specified here. - # [[ref]](https://kubernetes.io/docs/concepts/services-networking/network-policies/) - # [[recipes]](https://github.com/ahmetb/kubernetes-network-policy-recipes) - egress: - # - to: - # - ipBlock: - # cidr: 0.0.0.0/0 - # ports: - # - port: 53 - # protocol: UDP - # - port: 53 - # protocol: TCP - - # -- The common library supports adding a code-server add-on to access files. It can be configured under this key. - # @default -- See values.yaml - codeserver: - # -- Enable running a code-server container in the pod - enabled: false - - image: - # -- Specify the code-server image - repository: ghcr.io/coder/code-server - # -- Specify the code-server image tag - tag: 4.13.0 - # -- Specify the code-server image pull policy - pullPolicy: IfNotPresent - - # -- Set any environment variables for code-server here - env: - {} - # TZ: UTC - - # -- Set codeserver command line arguments. - # Consider setting --user-data-dir to a persistent location to preserve code-server setting changes - args: - - --auth - - none - # - --user-data-dir - # - "/config/.vscode" - - # -- Specify a list of volumes that get mounted in the code-server container. - # At least 1 volumeMount is required! - volumeMounts: [] - # - name: config - # mountPath: /data/config - - # -- Specify the working dir that will be opened when code-server starts - # If not given, the app will default to the mountpah of the first specified volumeMount - workingDir: "" - - # -- Optionally allow access a Git repository by passing in a private SSH key - # @default -- See below - git: - # -- Raw SSH private key - deployKey: "" - # -- Base64-encoded SSH private key. When both variables are set, the raw SSH key takes precedence. - deployKeyBase64: "" - # -- Existing secret containing SSH private key - # The chart expects it to be present under the `id_rsa` key. - deployKeySecret: "" - - service: - # -- Enable a service for the code-server add-on. - enabled: true - type: ClusterIP - # Specify the default port information - ports: - codeserver: - port: 12321 - enabled: true - protocol: TCP - targetPort: 12321 - ## Specify the nodePort value for the LoadBalancer and NodePort service types. - ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport - ## - # nodePort: - annotations: {} - labels: {} - - ingress: - # -- Enable an ingress for the code-server add-on. - enabled: false - - annotations: - {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - - labels: {} - - # -- Set the ingressClass that is used for this ingress. - ingressClassName: # "nginx" - - hosts: - - host: code.chart-example.local - paths: - - path: / - pathType: Prefix - tls: [] - # - secretName: chart-example-tls - # hosts: - # - code.chart-example.local - - securityContext: - runAsUser: 0 - - # -- The common library supports adding a netshoot add-on to troubleshoot network issues within a Pod. - # It can be configured under this key. - # @default -- See values.yaml - netshoot: - # -- Enable running a netshoot container in the pod - enabled: false - - image: - # -- Specify the netshoot image - repository: ghcr.io/nicolaka/netshoot - # -- Specify the netshoot image tag - tag: v0.11 - # -- Specify the netshoot image pull policy - pullPolicy: IfNotPresent - - # -- Set any environment variables for netshoot here - env: {} - - securityContext: - capabilities: - add: - - NET_ADMIN + # -- Explicitly configure mounts for specific controllers and containers. + # Example: + # advancedMounts: + # main: # the controller with whe "main" identifier + # main: # the container with whe "main" identifier + # - path: /data/config.yaml + # readOnly: true + # subPath: config.yaml + # second-container: # the container with whe "second-container" identifier + # - path: /appdata/config + # readOnly: true + # second-controller: # the controller with whe "second-controller" identifier + # main: # the container with whe "main" identifier + # - path: /data/config.yaml + # readOnly: false + # subPath: config.yaml + advancedMounts: {} diff --git a/charts/other/app-template/ci/basic-values.yaml b/charts/other/app-template/ci/basic-values.yaml deleted file mode 100644 index 9816acdd..00000000 --- a/charts/other/app-template/ci/basic-values.yaml +++ /dev/null @@ -1,22 +0,0 @@ -image: - repository: b4bz/homer - tag: latest - pullPolicy: IfNotPresent - -service: - main: - ports: - http: - port: 8080 - -ingress: - main: - enabled: true - -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true diff --git a/charts/other/app-template/ci/codeserver-values.yaml b/charts/other/app-template/ci/codeserver-values.yaml deleted file mode 100644 index 8284a461..00000000 --- a/charts/other/app-template/ci/codeserver-values.yaml +++ /dev/null @@ -1,33 +0,0 @@ -image: - repository: b4bz/homer - tag: latest - pullPolicy: IfNotPresent - -service: - main: - ports: - http: - port: 8080 - -ingress: - main: - enabled: true - -persistence: - config: - enabled: true - emptyDir: - enabled: true - mountPath: /www/assets - -addons: - codeserver: - enabled: true - git: - deployKey: test - workingDir: "/www/assets" - ingress: - enabled: true - volumeMounts: - - name: config - mountPath: /www/assets diff --git a/charts/other/app-template/ci/cronjob-values.yaml b/charts/other/app-template/ci/cronjob-values.yaml deleted file mode 100644 index b93f3ed7..00000000 --- a/charts/other/app-template/ci/cronjob-values.yaml +++ /dev/null @@ -1,11 +0,0 @@ -controller: - type: cronjob - -image: - repository: b4bz/homer - tag: latest - pullPolicy: IfNotPresent - -service: - main: - enabled: false diff --git a/charts/other/app-template/ci/netshoot-values.yaml b/charts/other/app-template/ci/netshoot-values.yaml deleted file mode 100644 index ab78c9b1..00000000 --- a/charts/other/app-template/ci/netshoot-values.yaml +++ /dev/null @@ -1,26 +0,0 @@ -image: - repository: b4bz/homer - tag: latest - pullPolicy: IfNotPresent - -service: - main: - ports: - http: - port: 8080 - -ingress: - main: - enabled: true - -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true - -addons: - netshoot: - enabled: true diff --git a/charts/other/app-template/tests/addons/codeserver_test.yaml b/charts/other/app-template/tests/addons/codeserver_test.yaml deleted file mode 100644 index 377fe9ea..00000000 --- a/charts/other/app-template/tests/addons/codeserver_test.yaml +++ /dev/null @@ -1,167 +0,0 @@ -suite: addon codeserver -templates: - - common.yaml -tests: - - it: default should pass - asserts: - - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 - isKind: - of: Deployment - - documentIndex: 1 - isKind: - of: Service - - documentIndex: *DeploymentDocument - not: true - equal: - path: spec.template.spec.containers[0].name - value: codeserver - - - it: addon enabled should pass - set: - addons: - codeserver: - enabled: true - volumeMounts: - - name: "config" - mountPath: "/data/config" - asserts: - - hasDocuments: - count: 3 - - documentIndex: &DeploymentDocument 1 - isKind: - of: Deployment - - documentIndex: &AddonServiceDocument 0 - isKind: - of: Service - - documentIndex: &ApplicationServiceDocument 2 - isKind: - of: Service - - documentIndex: *DeploymentDocument - equal: - path: spec.template.spec.containers[1].name - value: codeserver - - documentIndex: *AddonServiceDocument - equal: - path: metadata.name - value: RELEASE-NAME-addon-codeserver - - - it: addon enabled with deployKey should pass - set: - addons: - codeserver: - enabled: true - git: - deployKey: test - volumeMounts: - - name: "config" - mountPath: "/data/config" - asserts: - - hasDocuments: - count: 4 - - documentIndex: &AddonDeployKeySecretDocument 3 - 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 InlineBase64 deployKey should pass - set: - addons: - codeserver: - enabled: true - git: - deployKeyBase64: dGVzdEtleQ== - volumeMounts: - - name: "config" - mountPath: "/data/config" - asserts: - - hasDocuments: - count: 4 - - documentIndex: &AddonDeployKeySecretDocument 3 - 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 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: test-secret diff --git a/charts/other/app-template/tests/addons/netshoot_test.yaml b/charts/other/app-template/tests/addons/netshoot_test.yaml deleted file mode 100644 index 45b2967e..00000000 --- a/charts/other/app-template/tests/addons/netshoot_test.yaml +++ /dev/null @@ -1,38 +0,0 @@ -suite: addon netshoot -templates: - - common.yaml -tests: - - it: default should pass - asserts: - - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 - isKind: - of: Deployment - - documentIndex: 1 - isKind: - of: Service - - documentIndex: *DeploymentDocument - not: true - equal: - path: spec.template.spec.containers[0].name - value: netshoot - - - it: addon enabled should pass - set: - addons: - netshoot: - enabled: true - asserts: - - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 - isKind: - of: Deployment - - documentIndex: 1 - isKind: - of: Service - - documentIndex: *DeploymentDocument - equal: - path: spec.template.spec.containers[1].name - value: netshoot diff --git a/charts/other/app-template/tests/addons/vpn_test.yaml b/charts/other/app-template/tests/addons/vpn_test.yaml deleted file mode 100644 index 45b0ee44..00000000 --- a/charts/other/app-template/tests/addons/vpn_test.yaml +++ /dev/null @@ -1,206 +0,0 @@ -suite: addon vpn -templates: - - common.yaml -tests: - - it: default should pass - asserts: - - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 - isKind: - of: Deployment - - documentIndex: 1 - isKind: - of: Service - - documentIndex: *DeploymentDocument - not: true - equal: - path: spec.template.spec.containers[0].name - value: vpn - - - it: addon enabled should pass - set: - addons: - vpn: - enabled: true - asserts: - - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 - isKind: - of: Deployment - - documentIndex: 1 - isKind: - of: Service - - documentIndex: *DeploymentDocument - equal: - path: spec.template.spec.containers[1].name - value: gluetun - - - it: addon enabled with configFile should pass - set: - addons: - vpn: - enabled: true - configFile: test - asserts: - - hasDocuments: - count: 3 - - documentIndex: &AddonVPNConfigSecretDocument 2 - isKind: - of: Secret - - documentIndex: &DeploymentDocument 0 - isKind: - of: Deployment - - documentIndex: *DeploymentDocument - contains: - path: spec.template.spec.containers[1].volumeMounts - content: - mountPath: /gluetun/config.conf - name: vpnconfig - subPath: vpnConfigfile - - documentIndex: *DeploymentDocument - contains: - path: spec.template.spec.volumes - content: - name: vpnconfig - secret: - items: - - key: vpnConfigfile - path: vpnConfigfile - secretName: RELEASE-NAME-addon-vpn-config - - documentIndex: *AddonVPNConfigSecretDocument - equal: - path: metadata.name - 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 2 - isKind: - of: ConfigMap - - documentIndex: &DeploymentDocument 0 - 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 - set: - addons: - vpn: - enabled: true - configFileSecret: test-secret - asserts: - - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 - isKind: - of: Deployment - - documentIndex: *DeploymentDocument - contains: - path: spec.template.spec.containers[1].volumeMounts - content: - mountPath: /gluetun/config.conf - name: vpnconfig - subPath: vpnConfigfile - - documentIndex: *DeploymentDocument - contains: - path: spec.template.spec.volumes - content: - name: vpnconfig - secret: - items: - - key: vpnConfigfile - path: vpnConfigfile - secretName: test-secret - - - it: addon enabled with custom env vars dict should pass - set: - addons: - vpn: - enabled: true - env: - int: 1 - float: 1.5 - string: value_of_env - template: "{{ .Release.Name }}-admin" - asserts: - - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 - isKind: - of: Deployment - - documentIndex: &ServiceDocument 1 - isKind: - of: Service - - documentIndex: *DeploymentDocument - not: true - equal: - path: spec.template.spec.containers[1].name - value: vpn - - documentIndex: *DeploymentDocument - equal: - path: spec.template.spec.containers[1].env[0] - value: - name: float - value: "1.5" - - documentIndex: *DeploymentDocument - equal: - path: spec.template.spec.containers[1].env[1] - value: - name: int - value: "1" - - documentIndex: *DeploymentDocument - equal: - path: spec.template.spec.containers[1].env[2] - value: - name: string - value: value_of_env - - documentIndex: *DeploymentDocument - equal: - path: spec.template.spec.containers[1].env[3] - value: - name: template - value: RELEASE-NAME-admin diff --git a/charts/other/app-template/tests/container/ports_test.yaml b/charts/other/app-template/tests/container/ports_test.yaml deleted file mode 100644 index 3dea0973..00000000 --- a/charts/other/app-template/tests/container/ports_test.yaml +++ /dev/null @@ -1,95 +0,0 @@ -suite: container ports -templates: - - common.yaml -tests: - - it: default should pass - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.containers[0].ports[0] - value: - containerPort: null - name: http - protocol: TCP - - - it: custom port should pass - set: - service: - main: - ports: - http: - enabled: false - server: - enabled: true - port: 8080 - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.containers[0].ports[0] - value: - containerPort: 8080 - name: server - protocol: TCP - - - it: HTTP protocol should pass - set: - service: - main: - ports: - http: - protocol: HTTP - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.containers[0].ports[0] - value: - containerPort: null - name: http - protocol: TCP - - - it: HTTPS protocol should pass - set: - service: - main: - ports: - http: - protocol: HTTPS - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.containers[0].ports[0] - value: - containerPort: null - name: http - protocol: TCP - - - it: UDP protocol should pass - set: - service: - main: - ports: - http: - protocol: UDP - asserts: - - documentIndex: 0 - isKind: - of: Deployment - - documentIndex: 0 - equal: - path: spec.template.spec.containers[0].ports[0] - value: - containerPort: null - name: http - protocol: UDP diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 0f9789e8..6d611067 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -11,8 +11,7 @@ # Helm Charts - [Common Library](common-library/introduction.md) - - [Add-ons](common-library/add-ons/index.md) - - [code-server](common-library/add-ons/code-server/index.md) + - [Storage](common-library/storage/index.md) - [Permissions](common-library/storage/permissions.md) - [Storage types](common-library/storage/types.md) diff --git a/docs/src/common-library/add-ons/code-server/index.md b/docs/src/common-library/add-ons/code-server/index.md deleted file mode 100644 index 109423e4..00000000 --- a/docs/src/common-library/add-ons/code-server/index.md +++ /dev/null @@ -1,47 +0,0 @@ -# Code Server - -The [code-server](https://github.com/cdr/code-server) add-on can be used to -access and modify persistent volume data in your application. This can be -useful when you need to edit the persistent volume data, for example with -Home Assistant. - -## Example values - -Below is a snippet from a `values.yaml` using the add-on. More configuration -options can be found in our common chart documentation. - -```admonish note -This example will mount `/config` into the code-server sidecar. -``` - -```yaml -addons: - codeserver: - enabled: true - image: - repository: codercom/code-server - tag: 3.9.0 - workingDir: "/config" - args: - - --auth - - "none" - - --user-data-dir - - "/config/.vscode" - - --extensions-dir - - "/config/.vscode" - ingress: - enabled: true - annotations: - kubernetes.io/ingress.class: "nginx" - hosts: - - host: app-config.domain.tld - paths: - - path: / - pathType: Prefix - tls: - - hosts: - - app-config.domain.tld - volumeMounts: - - name: config - mountPath: /config -``` diff --git a/docs/src/common-library/add-ons/index.md b/docs/src/common-library/add-ons/index.md deleted file mode 100644 index 92f8dae0..00000000 --- a/docs/src/common-library/add-ons/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# Common library add-ons - -The common library chart supplies a few add-ons which are meant to simplify some features -you might be looking for. These are sidecars that run in the same pod as your -application you configured it with. diff --git a/docs/src/common-library/howto/helm-templates.md b/docs/src/common-library/howto/helm-templates.md index 3c649306..befed867 100644 --- a/docs/src/common-library/howto/helm-templates.md +++ b/docs/src/common-library/howto/helm-templates.md @@ -10,15 +10,14 @@ This feature allows you to set the value of that key to the output of the given Given the following `values.yaml` ```yaml -image: - repository: k8s.gcr.io/git-sync/git-sync - tag: v3.6.2 - -additionalContainers: +containers: subcleaner: name: subcleaner - image: |- - {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }} + + image: + repository: k8s.gcr.io/git-sync/git-sync + tag: {{.Chart.AppVersion}} + args: - --repo=https://github.com/KBlixt/subcleaner.git - --branch=master @@ -29,14 +28,14 @@ additionalContainers: This would render as follows: ```yaml -image: - repository: k8s.gcr.io/git-sync/git-sync - tag: v3.6.2 - -additionalContainers: +containers: subcleaner: name: subcleaner - image: k8s.gcr.io/git-sync/git-sync:v3.6.2 + + image: + repository: k8s.gcr.io/git-sync/git-sync + tag: v3.6.2 + args: - --repo=https://github.com/KBlixt/subcleaner.git - --branch=master diff --git a/docs/src/common-library/howto/multiple-subpath.md b/docs/src/common-library/howto/multiple-subpath.md index d00d21b1..26e23826 100644 --- a/docs/src/common-library/howto/multiple-subpath.md +++ b/docs/src/common-library/howto/multiple-subpath.md @@ -1,43 +1,31 @@ # Multiple subPaths for 1 volume -It is possible to mount multiple subPaths from the same volume to the main +It is possible to mount multiple subPaths from the same volume to a container. This can be achieved by specifying `subPath` with a list instead of a string. -```admonish note -It is not possible to define `mountPath` at the top level when using this -feature -``` - ## Examples: ```yaml persistence: config: - enabled: true - type: custom - volumeSpec: - configMap: - name: myData - subPath: - - path: myFirstScript.sh - mountPath: /data/myFirstScript.sh - - path: myCertificate.pem - mountPath: /certs/myCertificate.pem - readOnly: true -``` - -```yaml -persistence: - config: - enabled: true - type: pvc - existingClaim: myAppData - subPath: - - path: . - mountPath: /my_media - - path: Series - mountPath: /series - - path: Downloads - mountPath: /downloads + type: configMap + name: my-configMap + advancedMounts: + main: # the controller with whe "main" identifier + main: # the container with whe "main" identifier + - path: /data/config.yaml + readOnly: false + subPath: config.yaml + - path: /data/secondConfigFile.yaml + readOnly: false + subPath: secondConfigFile.yaml + second-container: # the container with whe "second-container" identifier + - path: /appdata/config + readOnly: true + second-controller: # the controller with whe "second-controller" identifier + main: # the container with whe "main" identifier + - path: /data/config.yaml + readOnly: false + subPath: config.yaml ``` diff --git a/docs/src/common-library/introduction.md b/docs/src/common-library/introduction.md index 16a5a0e4..518938ec 100644 --- a/docs/src/common-library/introduction.md +++ b/docs/src/common-library/introduction.md @@ -3,7 +3,7 @@ ```admonish note The Common library chart is not meant to be installed directly, application charts use the Common library as a dependency. -See the [app template](../../app-template/introduction.md ) for an example how to +See the [app template](../app-template/introduction.md ) for an example how to deploy it. ``` @@ -13,9 +13,9 @@ In Helm 3, their team introduced the concept of a [Library chart](https://helm.sh/docs/topics/library_charts/). > A library chart is a type of Helm chart that defines chart primitives or - definitions which can be shared by Helm templates in other charts. This - allows users to share snippets of code that can be re-used across charts, - avoiding repetition and keeping charts DRY. +> definitions which can be shared by Helm templates in other charts. This +> allows users to share snippets of code that can be re-used across charts, +> avoiding repetition and keeping charts DRY. The common library was created because I saw many charts requiring only a few select configuration options in their Helm charts. diff --git a/examples/flux/helmrelease.yaml b/examples/flux/helmrelease.yaml index 6297b152..73646660 100644 --- a/examples/flux/helmrelease.yaml +++ b/examples/flux/helmrelease.yaml @@ -19,23 +19,26 @@ spec: namespace: flux-system values: - image: - # -- image repository - repository: vaultwarden/server - # -- image pull policy - pullPolicy: IfNotPresent - # -- image tag - # this example is not automatically updated, so be sure to use the latest image - tag: 1.25.2 + controllers: + main: + strategy: Recreate - strategy: - type: Recreate + containers: + main: + image: + # -- image repository + repository: vaultwarden/server + # -- image tag + # this example is not automatically updated, so be sure to use the latest image + tag: 1.25.2 + # -- image pull policy + pullPolicy: IfNotPresent - # -- environment variables. - # See [image docs](https://github.com/dani-garcia/vaultwarden/blob/main/.env.template) for more details. - env: - # -- Config dir - DATA_FOLDER: "config" + # -- environment variables. + # See [image docs](https://github.com/dani-garcia/vaultwarden/blob/main/.env.template) for more details. + env: + # -- Config dir + DATA_FOLDER: "config" # -- Configures service settings for the chart. service: @@ -50,28 +53,31 @@ spec: ingress: # -- Enable and configure ingress settings for the chart under this key. main: - enabled: false + enabled: true hosts: - host: chart-example.local paths: - path: / pathType: Prefix service: + name: main port: http - path: /notifications/hub/negotiate pathType: Prefix service: + name: main port: http - path: /notifications/hub pathType: Prefix service: + name: main port: websocket # -- Configure persistence settings for the chart under this key. persistence: config: enabled: true - type: pvc + type: persistentVolumeClaim accessMode: ReadWriteOnce size: 1Gi mountPath: /config diff --git a/examples/helm/values.yaml b/examples/helm/values.yaml index b459ff73..38855bd0 100644 --- a/examples/helm/values.yaml +++ b/examples/helm/values.yaml @@ -1,20 +1,23 @@ -image: - # -- image repository - repository: vaultwarden/server - # -- image pull policy - pullPolicy: IfNotPresent - # -- image tag - # this example is not automatically updated, so be sure to use the latest image - tag: 1.25.2 +controllers: + main: + strategy: Recreate -strategy: - type: Recreate + containers: + main: + image: + # -- image repository + repository: vaultwarden/server + # -- image tag + # this example is not automatically updated, so be sure to use the latest image + tag: 1.25.2 + # -- image pull policy + pullPolicy: IfNotPresent -# -- environment variables. -# See [image docs](https://github.com/dani-garcia/vaultwarden/blob/main/.env.template) for more details. -env: - # -- Config dir - DATA_FOLDER: "config" + # -- environment variables. + # See [image docs](https://github.com/dani-garcia/vaultwarden/blob/main/.env.template) for more details. + env: + # -- Config dir + DATA_FOLDER: "config" # -- Configures service settings for the chart. service: @@ -29,28 +32,31 @@ service: ingress: # -- Enable and configure ingress settings for the chart under this key. main: - enabled: false + enabled: true hosts: - host: chart-example.local paths: - path: / pathType: Prefix service: + name: main port: http - path: /notifications/hub/negotiate pathType: Prefix service: + name: main port: http - path: /notifications/hub pathType: Prefix service: + name: main port: websocket # -- Configure persistence settings for the chart under this key. persistence: config: enabled: true - type: pvc + type: persistentVolumeClaim accessMode: ReadWriteOnce size: 1Gi mountPath: /config diff --git a/examples/kustomize/values.yaml b/examples/kustomize/values.yaml index b459ff73..38855bd0 100644 --- a/examples/kustomize/values.yaml +++ b/examples/kustomize/values.yaml @@ -1,20 +1,23 @@ -image: - # -- image repository - repository: vaultwarden/server - # -- image pull policy - pullPolicy: IfNotPresent - # -- image tag - # this example is not automatically updated, so be sure to use the latest image - tag: 1.25.2 +controllers: + main: + strategy: Recreate -strategy: - type: Recreate + containers: + main: + image: + # -- image repository + repository: vaultwarden/server + # -- image tag + # this example is not automatically updated, so be sure to use the latest image + tag: 1.25.2 + # -- image pull policy + pullPolicy: IfNotPresent -# -- environment variables. -# See [image docs](https://github.com/dani-garcia/vaultwarden/blob/main/.env.template) for more details. -env: - # -- Config dir - DATA_FOLDER: "config" + # -- environment variables. + # See [image docs](https://github.com/dani-garcia/vaultwarden/blob/main/.env.template) for more details. + env: + # -- Config dir + DATA_FOLDER: "config" # -- Configures service settings for the chart. service: @@ -29,28 +32,31 @@ service: ingress: # -- Enable and configure ingress settings for the chart under this key. main: - enabled: false + enabled: true hosts: - host: chart-example.local paths: - path: / pathType: Prefix service: + name: main port: http - path: /notifications/hub/negotiate pathType: Prefix service: + name: main port: http - path: /notifications/hub pathType: Prefix service: + name: main port: websocket # -- Configure persistence settings for the chart under this key. persistence: config: enabled: true - type: pvc + type: persistentVolumeClaim accessMode: ReadWriteOnce size: 1Gi mountPath: /config