From e0b3b333309e4ef1bed400c99395e08d74a8d1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20B=C3=A4hler?= Date: Sun, 10 Jan 2021 14:17:13 +0100 Subject: [PATCH 1/2] Bugfixing/Improve Documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Oliver Bähler --- .github/workflows/docs.yml | 39 +++++ .github/workflows/release.yml | 39 ----- .gitignore | 4 - charts/manifests/Chart.yaml | 2 +- charts/manifests/README.md | 14 +- charts/manifests/README.md.gotmpl | 21 ++- charts/manifests/plugin/README.md | 30 ---- charts/manifests/plugin/generator.sh | 70 -------- charts/manifests/plugin/plugin.yaml | 6 - .../plugin/values-generator/.helmignore | 23 --- .../plugin/values-generator/Chart.yaml | 10 -- .../plugin/values-generator/README.md | 24 --- .../templates/values-generator.yaml | 1 - .../plugin/values-generator/values.yaml | 23 --- charts/manifests/templates/Quickstart.md | 151 ++++++++++++++++++ charts/manifests/templates/README.md | 5 + .../manifests/templates/manifests/_bundle.tpl | 4 +- .../templates/manifests/_ingress.tpl | 2 +- .../manifests/templates/_containerTpl.tpl | 6 +- charts/manifests/templates/utils/_intern.tpl | 2 +- charts/manifests/templates/values/README.md | 2 +- .../manifests/templates/_containerTpl.yaml | 6 +- 22 files changed, 230 insertions(+), 254 deletions(-) create mode 100644 .github/workflows/docs.yml delete mode 100755 charts/manifests/plugin/README.md delete mode 100755 charts/manifests/plugin/generator.sh delete mode 100755 charts/manifests/plugin/plugin.yaml delete mode 100755 charts/manifests/plugin/values-generator/.helmignore delete mode 100755 charts/manifests/plugin/values-generator/Chart.yaml delete mode 100644 charts/manifests/plugin/values-generator/README.md delete mode 100755 charts/manifests/plugin/values-generator/templates/values-generator.yaml delete mode 100755 charts/manifests/plugin/values-generator/values.yaml create mode 100644 charts/manifests/templates/Quickstart.md diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..4608a1a8 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,39 @@ +name: Helm Documentation +on: push +jobs: + documentation: + runs-on: ubuntu-latest + container: + image: alpine + steps: + - name: Install Dependencies + run: | + apk add jq git curl + - name: Checkout + uses: actions/checkout@v2 + + - name: Fetch history + run: git fetch --prune --unshallow + + - name: Install Helm Docs + run: | + curl -s -L -o /usr/local/bin/helm-docs.tar.gz "https://github.com/norwoodj/helm-docs/releases/download/$(curl --silent "https://api.github.com/repos/norwoodj/helm-docs/releases/latest" | jq -r .tag_name)/helm-docs_$(curl --silent "https://api.github.com/repos/norwoodj/helm-docs/releases/latest" | jq -r .tag_name | cut -d "v" -f2-)_Linux_x86_64.tar.gz" + cd /usr/local/bin/ && tar xfv helm-docs.tar.gz + chmod +x ./helm-docs + + - name: Update Documentation + run: | + git status + CHARTS_ROOT="./charts" + if [ -d "${CHARTS_ROOT}" ]; then + ## Generate Documentation + helm-docs + ## Push Changes + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add -A + git commit -sam "Update Documentation" || true + git push || true + else + echo -e "\n\e[33m-- Root Direcoty not found: $CHART_ROOT\e[0m" && exit 0; + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c7147d64..d721099a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,47 +4,8 @@ on: branches: - master jobs: - documentation: - runs-on: ubuntu-latest - container: - image: alpine - steps: - - name: Install Dependencies - run: | - apk add jq git curl - - name: Checkout - uses: actions/checkout@v2 - - - name: Fetch history - run: git fetch --prune --unshallow - - - name: Install Helm Docs - run: | - curl -s -L -o /usr/local/bin/helm-docs.tar.gz "https://github.com/norwoodj/helm-docs/releases/download/$(curl --silent "https://api.github.com/repos/norwoodj/helm-docs/releases/latest" | jq -r .tag_name)/helm-docs_$(curl --silent "https://api.github.com/repos/norwoodj/helm-docs/releases/latest" | jq -r .tag_name | cut -d "v" -f2-)_Linux_x86_64.tar.gz" - cd /usr/local/bin/ && tar xfv helm-docs.tar.gz - chmod +x ./helm-docs - - - name: Update Documentation - run: | - git status - CHARTS_ROOT="./charts" - if [ -d "${CHARTS_ROOT}" ]; then - ## Generate Documentation - helm-docs - ## Push Changes - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - git add -A - git commit -sam "Update Documentation" || true - git push || true - else - echo -e "\n\e[33m-- Root Direcoty not found: $CHART_ROOT\e[0m" && exit 0; - fi - release: runs-on: ubuntu-latest - needs: - - documentation steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 2a5ca52a..b7ab50a0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,3 @@ Sessionx.vim .idea/ .intellij/ *.iml - -# Custom Files -charts/manifests/plugin/values-generator/charts/ -charts/manifests/plugin/values-generator/Chart.lock diff --git a/charts/manifests/Chart.yaml b/charts/manifests/Chart.yaml index a3676113..6f7447a2 100644 --- a/charts/manifests/Chart.yaml +++ b/charts/manifests/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: manifests description: "Bedag's Manifest chart. Library full of basic kubernetes manifests." type: library -version: 0.4.0 +version: 0.4.1 icon: "https://www.bedag.ch/wGlobal/wGlobal/layout/images/logo.svg" keywords: - Bedag diff --git a/charts/manifests/README.md b/charts/manifests/README.md index 7ae02932..1b8022d5 100644 --- a/charts/manifests/README.md +++ b/charts/manifests/README.md @@ -1,6 +1,6 @@ # Manifests Library -![Version: 0.3.0](https://img.shields.io/badge/Version-0.3.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) +![Version: 0.4.1](https://img.shields.io/badge/Version-0.4.1-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) This library's purpose is to have more flexibility as chart author but at the same time have kubernetes manifests managed in a central library. This way you can avoid big surprises when Kubernetes has breaking changes in any of their APIs. Currently we support a base set of resources. Resources may be added as soon as we see or get a request that there's a need for it. This chart is still under development and testing, since it's rather complex. Feel free to use it. Our goal is to get it as reliable as possible. @@ -39,6 +39,12 @@ Major Changes to functions are documented with the version affected. **Before up | :----------- | :---------------- | :--------------------- | :-------------- | ||||| +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| https://buttahtoast.github.io/helm-charts/ | library | ~0.3.0 | + # Documentation For Artifacthub Users: The entire documentation can be found in the GitHub Repository. @@ -53,8 +59,6 @@ We recommend looking thirst through the **Kubernetes Manifests** section. * **[Values](./templates/values/README.md)** * **[Utilities](./templates/utils/README.md)** -## Requirements +## Quickstart -| Repository | Name | Version | -|------------|------|---------| -| https://buttahtoast.github.io/helm-charts/ | library | ~0.3.0 | +[See this page for a quickstart](./templates/Quickstart.md) diff --git a/charts/manifests/README.md.gotmpl b/charts/manifests/README.md.gotmpl index 5cf9530e..fdd85875 100644 --- a/charts/manifests/README.md.gotmpl +++ b/charts/manifests/README.md.gotmpl @@ -41,6 +41,17 @@ Major Changes to functions are documented with the version affected. **Before up ||||| +{{/* + Chart Sources +*/}} +{{ template "chart.sourcesSection" . }} + +{{/* + Chart Requirements +*/}} +{{ template "chart.requirementsSection" . }} + + # Documentation For Artifacthub Users: The entire documentation can be found in the GitHub Repository. @@ -55,12 +66,6 @@ We recommend looking thirst through the **Kubernetes Manifests** section. * **[Values](./templates/values/README.md)** * **[Utilities](./templates/utils/README.md)** -{{/* - Chart Sources -*/}} -{{ template "chart.sourcesSection" . }} +## Quickstart -{{/* - Chart Requirements -*/}} -{{ template "chart.requirementsSection" . }} +[See this page for a quickstart](./templates/Quickstart.md) diff --git a/charts/manifests/plugin/README.md b/charts/manifests/plugin/README.md deleted file mode 100755 index b8533ebf..00000000 --- a/charts/manifests/plugin/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Values Generator - -This is currently only a temporary solution. - -# Install - -To install this plugin, clone the entire git repository. - -Make sure the script is executable: - -``` -chmod +x helm-charts/charts/manifests/plugin/generator.sh -``` - -## Local - -You can install Helm Plugins local. This means, in the HELM_PLUGIN directory will be a symbolic link created given to the directory. This is how you would install it locally: - -``` -helm install helm-charts/charts/manifests/plugin -``` -Since it's a symbolic link, the git repository has to persist. - -# Usage - -Learn which arguments are available: - -``` -helm manifests -h -``` diff --git a/charts/manifests/plugin/generator.sh b/charts/manifests/plugin/generator.sh deleted file mode 100755 index 8d261930..00000000 --- a/charts/manifests/plugin/generator.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -## -- Help Context -show_help() { -cat << EOF -Usage: ${0##*/} [-h] [-p] ] - -m [manifest] Manifest Name - -p [preset] Preset Name - -k [parentkey] Custom Parent Key - -P [keypath] Custom Key Path - -a [helm args] Additional Helm Arguments - -M Minimal Structure - -h Show this context - -EOF -} - -## -- Defaults -MANIFEST="" -PRESET="" -HELM_ARGS="" -KEYPATH="" -MINIMAL="" -PARENTKEY="" - -## -- Opting arguments -OPTIND=1; # Reset OPTIND, to clear getopts when used in a prior script -while getopts ":ha:P:k:m:p:k:M" opt; do - case ${opt} in - m) - MANIFEST="${OPTARG}" - ;; - p) - PRESET="${OPTARG}" - ;; - k) - PARENTKEY="${OPTARG}" - ;; - P) - KEYPATH="${OPTARG}" - ;; - a) - HELM_ARGS="${OPTARG}" - ;; - M) - MINIMAL="true" - ;; - h) - show_help - exit 0 - ;; - ?) - echo "Invalid Option: -$OPTARG" 1>&2 - exit 1 - ;; - esac -done -shift $((OPTIND -1)) - -## -- Helm Values -HELM_VALUES="" -[ -n "$MANIFEST" ] && HELM_VALUES="--set doc.manifest=${MANIFEST}" -[ -n "$PRESET" ] && HELM_VALUES="${HELM_VALUES} --set doc.preset=${PRESET}" -[ -n "$KEYPATH" ] && HELM_VALUES="${HELM_VALUES} --set doc.path=${KEYPATH}" -[ -n "$PARENTKEY" ] && HELM_VALUES="${HELM_VALUES} --set doc.key=${PARENTKEY}" -[ -n "$MINIMAL" ] && HELM_VALUES="${HELM_VALUES} --set doc.minimal=true" - -## -- Execute Helm -#$HELM_BIN -helm template $HELM_VALUES ${HELM_ARGS} --dependency-update values-generator/ diff --git a/charts/manifests/plugin/plugin.yaml b/charts/manifests/plugin/plugin.yaml deleted file mode 100755 index 113ef6a0..00000000 --- a/charts/manifests/plugin/plugin.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: "manifests" -version: "0.1.0" -usage: "Get Manifest Values" -description: "Get Manifest Values" -ignoreFlags: false -command: "bash ./generator.sh" diff --git a/charts/manifests/plugin/values-generator/.helmignore b/charts/manifests/plugin/values-generator/.helmignore deleted file mode 100755 index 0e8a0eb3..00000000 --- a/charts/manifests/plugin/values-generator/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# 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 -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/charts/manifests/plugin/values-generator/Chart.yaml b/charts/manifests/plugin/values-generator/Chart.yaml deleted file mode 100755 index ad0facb2..00000000 --- a/charts/manifests/plugin/values-generator/Chart.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v2 -name: values -description: A Helm chart for Kubernetes -type: application -version: 1.0.0 -appVersion: 1.16.0 -dependencies: -- name: "manifests" - version: ">=0.1.0" - repository: https://bedag.github.io/helm-charts diff --git a/charts/manifests/plugin/values-generator/README.md b/charts/manifests/plugin/values-generator/README.md deleted file mode 100644 index 05ddfd9f..00000000 --- a/charts/manifests/plugin/values-generator/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# values - -![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square) - -A Helm chart for Kubernetes - -## Requirements - -| Repository | Name | Version | -|------------|------|---------| -| https://bedag.github.io/helm-charts | manifests | >=0.1.0 | - -## Values - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| doc.key | string | `""` | | -| doc.manifest | string | `""` | | -| doc.minimal | bool | `false` | | -| doc.path | string | `""` | If you want your values to be in a more complex structure, you can define the yaml path. This mostly matters for all the helm-docs fields being generated. | -| doc.preset | string | `""` | Define which preset to render (e.g. "permissions") | - ----------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.4.0](https://github.com/norwoodj/helm-docs/releases/v1.4.0) diff --git a/charts/manifests/plugin/values-generator/templates/values-generator.yaml b/charts/manifests/plugin/values-generator/templates/values-generator.yaml deleted file mode 100755 index 6ef40c12..00000000 --- a/charts/manifests/plugin/values-generator/templates/values-generator.yaml +++ /dev/null @@ -1 +0,0 @@ -{{- include "bedag-lib.utils.values.generator" $ | nindent 0 }} diff --git a/charts/manifests/plugin/values-generator/values.yaml b/charts/manifests/plugin/values-generator/values.yaml deleted file mode 100755 index 845f2df5..00000000 --- a/charts/manifests/plugin/values-generator/values.yaml +++ /dev/null @@ -1,23 +0,0 @@ -## Enabled Values Generator -doc: - - ## doc.manifest -- Define which manifest to generate (e.g. "statfulset") - manifest: "" - - - # doc.preset -- Define which preset to render (e.g. "permissions") - preset: "" - - # doc.path -- If you want your values to be in a more complex structure, you can define the yaml path. This mostly matters for all the helm-docs fields being generated. - #path: "custom.sub.path" - path: "" - - ## Overwrite the top key for the values. - ## E.g. for the manifest statefulset the default top key is "statefulset", which has all other - ## keys as child. With this option you can change this key to e.g. "frontend" - key: "" - - ## A single manifest can have a lot of values. With enabling minimal output the values - ## which come from sub templates or manifests will only be referenced as comment but not printed - ## to keep your values slim. - minimal: false diff --git a/charts/manifests/templates/Quickstart.md b/charts/manifests/templates/Quickstart.md new file mode 100644 index 00000000..6fd8ed81 --- /dev/null +++ b/charts/manifests/templates/Quickstart.md @@ -0,0 +1,151 @@ +# Quickstart + +It's difficult to quickstart with this project unless you already have a deeper understanding. But we will show you how to set everything for a good experience with the manifests library. For better understanding check the entire documentation. + +1. **Get the Helm Manifests Plugin**
+ The Helm Manifests Plugin will help you generate the correct vales for all the resources you are going to need. [Find it here](https://github.com/bedag/helm-manifests-plugin) + +2. **Create a new Chart**
+ You can do this by using helm. Tough we won't need a lot of files from the helm generated chart directory. + + Create the basic layout with the following command + + ``` + helm create new-chart + ``` + + That will create a new directory in your current location named `new-chart`. In there you will find the typical helm chart structure. + +3. **Prepare Chart**
+ As mentioned, we don't need any of the helm default files, so we are going to remove them. + + ``` + rm -rf new-chart/templates/* && rm -f new-chart/values.yaml + ``` + +4. **Add Dependency**
+ Now let's add the Manifests library as dependency to your new chart. In your `new-chart/Chart.yaml` file: + + ``` + ... + dependencies: + - name: manifests + version: "~0.4.0" + repository: https://bedag.github.io/helm-charts + ... + ``` + + We like to have our dependencies fixed over all bugfix versions of a minor release (which is implied by `~`). Use your prefered dependency strategie. + +5. **Initialize Bundle**
+ Now it's time to get started with actually using the Manifests library. Let's create a new file `new-charts/templates/bundle.yaml` and add the basic Bundle structure ([Read More on Bundles](./manifests/README.md#bundles)). Let's also add our first bundle resource of type `statefulset` + + ``` + {{- include "bedag-lib.manifest.bundle" (dict "bundle" (fromYaml (include "new-chart.bundle" $)) "context" $) | nindent 0 }} + {{- define "new-chart.bundle" -}} + resources: + - type: "statefulset" + values: {{ toYaml $.Values.frontend | nindent 6 }} + overwrites: + {{- if $.Release.IsInstall }} + replicaCount: 1 + {{- end }} + {{- end }} + ``` + + As you can see, we already added an overwrite for the `replicaCount`. We always want the replicaCount the be one, when this chart is installed. + +6. **Get Some Values**
+ First I will get all the common/global values and recreate the values file: + + ``` + helm manifests > new-chart/values.yaml + ``` + + Since we have already referenced my values in the bundle for the statefulset to `$.Values.frontend`, we will generate all values for the statefulset under this key: + + ``` + helm manifests -m "statefulset" -P "frontend" + ``` + + And append the output to the `new-chart/values.yaml`. + +7. **Manifest, Sleep & Repeat** + + Now it's your turn. Implement the logic you need on manifest basis and add many more manifests. We are going to add a service with you, then it's up to you. The `new-charts/templates/bundle.yaml` looks now like this: + + ``` + {{- include "bedag-lib.manifest.bundle" (dict "bundle" (fromYaml (include "new-chart.bundle" $)) "context" $) | nindent 0 }} + {{- define "new-chart.bundle" -}} + resources: + - type: "statefulset" + values: {{ toYaml $.Values.frontend | nindent 6 }} + overwrites: + {{- if $.Release.IsInstall }} + replicaCount: 1 + {{- end }} + - type: "service" + values: {{ toYaml $.Values.service | nindent 6 }} + {{- end }} + ``` + + And the values for it: + + ``` + helm manifests -m "service" + ``` + + There's your service! :) + +8. **Before you go**
+ 1. Don't forget that you have all the power of go sprif in your hands within your bundles file. Use it whisely: + + * [http://masterminds.github.io/sprig/](http://masterminds.github.io/sprig/) + + 2. Just overwrite what's necessary. We want to give each end user of our charts as much freedom as possible. You should always consider a user's inputs. This is mainly required for slice inputs, since maps are merged. With slices, entire lists are overwritten. + + ``` + {{- include "bedag-lib.manifest.bundle" (dict "bundle" (fromYaml (include "new-chart.bundle" $)) "context" $) | nindent 0 }} + {{- define "new-chart.bundle" -}} + resources: + - type: "statefulset" + values: {{ toYaml $.Values.frontend | nindent 6 }} + overwrites: + {{- if $.Release.IsInstall }} + replicaCount: 1 + {{- end }} + + ports: + {{- if $.Values.frontend.ports }} + {{- toYaml $.Values.frontend.ports | nindent 8 }} + {{- end }} + - name: http + containerPort: {{ $.Values.config.port }} + protocol: TCP + + {{- end }} + ``` + Eventough we are overwriting the port, we are still using the ports the user might input. + + 3. ExtraResources are always welcome :) + + ``` + {{- define "new-chart.bundle" -}} + resources: + {{- if $.Values.extraResources }} + {{- toYaml $.Values.extraResources | nindent 2 }} + {{- end }} + + - type: "statefulset" + values: {{ toYaml $.Values.statefulset | nindent 6 }} + overwrites: + ... + + {{- end -}} + ``` + + 4. Sometimes you might encounter errors. Most of the time the source of errors will be a mallformed bundle YAML. To check how your YAML looks, you can do something like this and then `helm template` it: + + ``` + test: | {{- include "bedag-lib.manifest.bundle" (dict "bundle" (fromYaml (include "new-chart.bundle" $)) "context" $) | nindent 2 }} + ``` diff --git a/charts/manifests/templates/README.md b/charts/manifests/templates/README.md index 1a9076ec..6634c837 100644 --- a/charts/manifests/templates/README.md +++ b/charts/manifests/templates/README.md @@ -1,3 +1,8 @@ + + + + + # Development Here you find some documentation on how to add manifests or components to the library or expanding it by yourself. diff --git a/charts/manifests/templates/manifests/_bundle.tpl b/charts/manifests/templates/manifests/_bundle.tpl index 834d256f..43cc884b 100644 --- a/charts/manifests/templates/manifests/_bundle.tpl +++ b/charts/manifests/templates/manifests/_bundle.tpl @@ -41,6 +41,8 @@ limitations under the License. {{- end -}} {{- end -}} {{- end -}} - {{- end -}} + {{- else }} + {{- fail "Missing Keys or Wrong YAML structure!" }} + {{- end }} {{- end -}} {{- end -}} diff --git a/charts/manifests/templates/manifests/_ingress.tpl b/charts/manifests/templates/manifests/_ingress.tpl index ba99d38c..6efffa01 100644 --- a/charts/manifests/templates/manifests/_ingress.tpl +++ b/charts/manifests/templates/manifests/_ingress.tpl @@ -80,7 +80,7 @@ spec: {{- if .resource }} {{- $_ := set $p "resource" .resource }} {{- else }} - {{- $_ := set $p "service" (dict "name" (include "lib.utils.strings.toDns1123" (default (include "bedag-lib.utils.common.fullname" $context) .serviceName)) "port" (include "lib.utils.toDns1123" (default "http" .servicePort))) }} + {{- $_ := set $p "service" (dict "name" (include "lib.utils.strings.toDns1123" (default (include "bedag-lib.utils.common.fullname" $context) .serviceName)) "port" (include "lib.utils.strings.toDns1123" (default "http" .servicePort))) }} {{- end }} {{- end }} - path: {{ $p.path }} diff --git a/charts/manifests/templates/manifests/templates/_containerTpl.tpl b/charts/manifests/templates/manifests/templates/_containerTpl.tpl index f961e6fd..e0a80211 100644 --- a/charts/manifests/templates/manifests/templates/_containerTpl.tpl +++ b/charts/manifests/templates/manifests/templates/_containerTpl.tpl @@ -31,7 +31,7 @@ resources: {{- include "lib.utils.strings.template" (dict "value" . "context" $c {{- if $values.containerFields }} {{- include "lib.utils.strings.template" (dict "value" $values.containerFields "context" $context) | nindent 0 }} {{- end }} - {{- if $values.environment }} + {{- if and $values.environment (kindIs "slice" $values.environment) }} {{- if $context.Bundle }} env: {{- include "bedag-lib.utils.environment.keyList" (dict "environment" $values.environment "allowSecrets" true "context" $context) | nindent 2 }} {{- else }} @@ -56,10 +56,10 @@ startupProbe: {{ include "lib.utils.strings.template" (dict "value" $values.star {{- with $values.lifecycle }} lifecycle: {{ include "lib.utils.strings.template" (dict "value" $values.lifecycle "context" $context) | nindent 2 }} {{- end }} - {{- if $values.volumeMounts }} + {{- if and $values.volumeMounts (kindIs "slice" $values.volumeMounts) }} volumeMounts: {{- include "lib.utils.strings.template" (dict "value" $values.volumeMounts "context" $context) | nindent 2 }} {{- end }} - {{- if $values.ports }} + {{- if and $values.ports (kindIs "slice" $values.ports) }} ports: {{- include "lib.utils.strings.template" (dict "value" $values.ports "context" $context) | nindent 2 }} {{- end }} {{- end }} diff --git a/charts/manifests/templates/utils/_intern.tpl b/charts/manifests/templates/utils/_intern.tpl index 51cb395c..0a2d3be8 100644 --- a/charts/manifests/templates/utils/_intern.tpl +++ b/charts/manifests/templates/utils/_intern.tpl @@ -16,5 +16,5 @@ limitations under the License. */ {{- define "bedag-lib.utils.intern.docLink" -}} -https://github.com/bedag/helm-charts/tree/master/charts/manifests/templates/manifests/README.md#container-template +https://github.com/bedag/helm-charts/tree/master/charts/manifests/templates/manifests/README.md {{- end }} diff --git a/charts/manifests/templates/values/README.md b/charts/manifests/templates/values/README.md index 364fe21a..efdbdabd 100644 --- a/charts/manifests/templates/values/README.md +++ b/charts/manifests/templates/values/README.md @@ -10,4 +10,4 @@ This library ships with a Values Generator, which allows to generate values.yaml ### Plugin -[See the Generator Helm Plugin](../../plugin/README.md) +To make life easier, we created a dedicated helm plugin to generate values. [See the Generator Helm Plugin]((https://github.com/bedag/helm-manifests-plugin)) diff --git a/charts/manifests/templates/values/manifests/templates/_containerTpl.yaml b/charts/manifests/templates/values/manifests/templates/_containerTpl.yaml index 4f5fa0c5..fd59d2ec 100644 --- a/charts/manifests/templates/values/manifests/templates/_containerTpl.yaml +++ b/charts/manifests/templates/values/manifests/templates/_containerTpl.yaml @@ -48,7 +48,7 @@ args: {{ toYaml (default dict $_.data.args) | nindent 2 }} ## Environment Variables # {{ $_.path }}environment -- Configure Environment Variables (Refer to values.yaml) -environment: {{ toYaml (default dict $_.data.environment) | nindent 2 }} +environment: {{ toYaml (default list $_.data.environment) | nindent 2 }} # - name: "MY_ENV" # value: "someValue" # secret: true @@ -60,14 +60,14 @@ environment: {{ toYaml (default dict $_.data.environment) | nindent 2 }} ## Container Ports # {{ $_.path }}ports -- Configure Container Ports -ports: {{ toYaml (default dict $_.data.ports) | nindent 2 }} +ports: {{ toYaml (default list $_.data.ports) | nindent 2 }} # - name: "health" # containerPort: 9090 # protocol: TCP ## Additional Volume Mounts # {{ $_.path }}volumeMounts -- Configure Container [volumeMounts](https://kubernetes.io/docs/tasks/configure-pod-container/configure-volume-storage/) -volumeMounts: {{ toYaml (default dict $_.data.volumeMounts) | nindent 2 }} +volumeMounts: {{ toYaml (default list $_.data.volumeMounts) | nindent 2 }} # - name: "cache" # mountPath: /cache # - name: "share" From 1f81f0f4d5a13a1ef8e8f7df1f87bb734a240638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20B=C3=A4hler?= Date: Mon, 11 Jan 2021 15:02:06 +0100 Subject: [PATCH 2/2] Add Contributing guidelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Oliver Bähler --- CONTRIBUTING.md | 25 ++++--------------------- charts/manifests/.helmignore | 1 - charts/manifests/templates/README.md | 5 ----- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2f96c703..99c60892 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ See git help commit: With these steps you can make a contribution: 1. Fork this repository, develop and test your changes on that fork. - 2. All commits have a meaningful description and are signed off as described above and also verified. + 2. All commits have a meaningful description, are signed off as described above and verified. 3. Submit a pull request from your fork to this project. ## Code reviews @@ -42,6 +42,7 @@ All submissions, including submissions by project members, require review. We us To have consistent README documentations for each chart we use the [helm-docs plugin](https://github.com/norwoodj/helm-docs). Make sure to write the chart README in a compatible format. Helm-Docs is executed on Push events. +**NOTE**: When creating your own `README.md.gotmpl`, don't forget to add it to your `.helmignore` file. ## Release Action @@ -59,6 +60,8 @@ Unit Tests can be created on a chart basis. Unit Tests are optional. Your PR has to fulfill the following points, to be considered: + * Chart should use [Bedag Manifests Library](./charts/manifests/README.md), if possible + * Make use of [Artifacthub Annotations](https://github.com/artifacthub/hub/blob/master/docs/helm_annotations.md) * CI Jobs for linting must pass. * The title of the PR starts with the chart name (e.g. `[chart_name] Additional options for SecurityContext`) * Changes must follow [Helm best practices](https://helm.sh/docs/chart_best_practices/). @@ -85,23 +88,3 @@ Currently these are the only requirements to add a new chart: * **Only Helm Version 3+ Charts ([ApiVersion 2](https://helm.sh/docs/topics/v2_v3_migration/)) are accepted/supported.** * The chart has it's on `README.md` describing it's configuration options with default values. The documentation should also cover some basic configuration examples. * Follow a best practice structure for the layout of the chart directory (A good reference is [bitnami's blog](https://docs.bitnami.com/tutorials/production-ready-charts/) on this topic) - -## Recommendations - -We have some recommendations for creating a new chart. - -### Chart Schema - -A [Chart Schema](https://helm.sh/docs/topics/charts#schema-files) helps improving the value validations of the given chart values. But it's also used in solutions, where you can deploy charts over a gui. For example [Rancher](https://rancher.com/products/rancher/) uses the Chart Schema to render a user friendly page, where you can change the chart values. To get a good first layout of your values you might want to use [this Helm Plugin](https://github.com/karuppiah7890/helm-schema-gen). It automatically creates the schema file according to your values file. - -Install the Plugin - -``` -helm plugin install https://github.com/karuppiah7890/helm-schema-gen -``` - -Generate Schema file - -``` -helm schema-gen values.yaml -``` diff --git a/charts/manifests/.helmignore b/charts/manifests/.helmignore index 1b5e6745..fa15b2e1 100644 --- a/charts/manifests/.helmignore +++ b/charts/manifests/.helmignore @@ -24,4 +24,3 @@ # Custom README.md.gotmpl -plugin/ diff --git a/charts/manifests/templates/README.md b/charts/manifests/templates/README.md index 6634c837..1a9076ec 100644 --- a/charts/manifests/templates/README.md +++ b/charts/manifests/templates/README.md @@ -1,8 +1,3 @@ - - - - - # Development Here you find some documentation on how to add manifests or components to the library or expanding it by yourself.