mirror of
https://github.com/k8s-at-home/charts.git
synced 2025-01-23 15:39:02 +00:00
Add a contributing helper, for helping creating new chart (#508)
Co-authored-by: ᗪєνιη ᗷυнʟ <onedr0p@users.noreply.github.com>
This commit is contained in:
parent
1549e9056f
commit
5e86ce93b7
6
.github/workflows/charts-lint-test.yaml
vendored
6
.github/workflows/charts-lint-test.yaml
vendored
@ -38,14 +38,14 @@ jobs:
|
||||
echo "::set-output name=changed::true"
|
||||
fi
|
||||
|
||||
changed_unfiltered=$(ct list-changed --config .github/ct.yaml --excluded-charts "")
|
||||
changed_unfiltered=$(ct list-changed --config .github/ct.yaml --excluded-charts ".template")
|
||||
if [[ $(grep -E "^charts/common(-test)?$" <<< "$changed_unfiltered") ]]; then
|
||||
echo "::set-output name=common::true"
|
||||
fi
|
||||
|
||||
- name: Run chart-testing (lint)
|
||||
id: lint
|
||||
run: ct lint --config .github/ct.yaml --excluded-charts ""
|
||||
run: ct lint --config .github/ct.yaml --excluded-charts ".template"
|
||||
if: steps.list-changed.outputs.changed == 'true' || steps.list-changed.outputs.common == 'true'
|
||||
|
||||
unittest:
|
||||
@ -105,7 +105,7 @@ jobs:
|
||||
if: needs.lint.outputs.changed == 'true' || needs.lint.outputs.common == 'true'
|
||||
|
||||
- name: Run chart-testing (install)
|
||||
run: ct install --config .github/ct.yaml
|
||||
run: ct install --config .github/ct.yaml --excluded-charts ".template"
|
||||
if: needs.lint.outputs.changed == 'true'
|
||||
|
||||
- name: Run chart-testing (common-test)
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
# Developer dependencies
|
||||
.bin
|
||||
|
||||
# IDE resources
|
||||
.vscode
|
||||
.idea
|
||||
@ -9,4 +12,6 @@ charts/*/charts
|
||||
|
||||
# Other rsources
|
||||
.env
|
||||
.envrc
|
||||
Gemfile.lock
|
||||
.helmignore
|
||||
|
46
.taskfiles/Taskfile_chart.yml
Normal file
46
.taskfiles/Taskfile_chart.yml
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
version: '3'
|
||||
|
||||
tasks:
|
||||
|
||||
create:
|
||||
desc: create new chart
|
||||
cmds:
|
||||
- cp -r {{.GIT_ROOT}}/charts/.template {{.GIT_ROOT}}/charts/{{.CHART}}
|
||||
- ./.bin/go-replace -s '${CHARTNAME}' -r "{{.CHART}}" --path={{.GIT_ROOT}}/charts/{{.CHART}} --path-pattern='*.*'
|
||||
- task: dependency
|
||||
- echo "Congratulations, charts/{{.CHART}} successfully generated, you can now edit chart informations ( Chart.yaml and values.yaml )"
|
||||
status:
|
||||
- test -d {{.GIT_ROOT}}/charts/{{.CHART}}
|
||||
deps:
|
||||
- check-chart
|
||||
|
||||
|
||||
dependency:
|
||||
cmds:
|
||||
- test -d {{.GIT_ROOT}}/charts/{{.CHART}}/Chart.lock && rm {{.GIT_ROOT}}/charts/{{.CHART}}/Chart.lock || exit 0
|
||||
- test -d {{.GIT_ROOT}}/charts/{{.CHART}}/tmpcharts && rm -rf {{.GIT_ROOT}}/charts/{{.CHART}}/tmpcharts || exit 0
|
||||
- cd {{.GIT_ROOT}}/charts/{{.CHART}} && helm dependency update
|
||||
silent: true
|
||||
|
||||
lint:
|
||||
desc: lint your chart code
|
||||
cmds:
|
||||
- cd {{.GIT_ROOT}}/charts/{{.CHART}} && helm lint
|
||||
deps:
|
||||
- dependency
|
||||
- check-chart
|
||||
|
||||
test:
|
||||
desc: test your chart code
|
||||
cmds:
|
||||
- docker run --rm -it --user $(id -u):$(id -g) -e "HELM_CONFIG_HOME=/tmp/helm" -e "HELM_CACHE_HOME=/tmp/helm" -v {{.GIT_ROOT}}:/ci -w /ci quay.io/helmpack/chart-testing:latest ct lint --charts charts/{{.CHART}} --config /ci/.github/ct.yaml
|
||||
deps:
|
||||
- check-chart
|
||||
- lint
|
||||
|
||||
# Checks Parameters
|
||||
check-chart:
|
||||
cmds:
|
||||
- cmd: test ! -z "{{.CHART}}" || (echo "Please define CHART parameter"; exit 1)
|
||||
silent: true
|
10
.taskfiles/Taskfile_darwin.yml
Normal file
10
.taskfiles/Taskfile_darwin.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
version: '3'
|
||||
|
||||
# Todo: add darwin requirements
|
||||
|
||||
tasks:
|
||||
default:
|
||||
cmds:
|
||||
- task -l
|
||||
silent: true
|
67
.taskfiles/Taskfile_linux.yml
Normal file
67
.taskfiles/Taskfile_linux.yml
Normal file
@ -0,0 +1,67 @@
|
||||
---
|
||||
version: '3'
|
||||
|
||||
env:
|
||||
URL_GOREPLACE: https://github.com/webdevops/go-replace/releases/download/1.1.2/gr-64-linux
|
||||
URL_HELM: https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
|
||||
|
||||
tasks:
|
||||
|
||||
install:
|
||||
desc: Install all developer dependencies
|
||||
deps:
|
||||
- distrib-requirements
|
||||
- helm
|
||||
- pre-commit
|
||||
- go-replace
|
||||
|
||||
distrib-requirements:
|
||||
desc: Check needed distribution packages
|
||||
cmds:
|
||||
- task deps:need BIN=wget
|
||||
- task deps:need BIN=python3
|
||||
- task deps:need BIN=docker
|
||||
silent: true
|
||||
|
||||
need:
|
||||
desc: Check needed binary is present
|
||||
cmds:
|
||||
- type {{.BIN}} 2>&1 >/dev/null || (echo "Please install {{.BIN}}"; exit 1)
|
||||
silent: true
|
||||
|
||||
helm:
|
||||
desc: Install helm client
|
||||
cmds:
|
||||
- wget -q -O - "$URL_HELM" | USE_SUDO=false HELM_INSTALL_DIR=.bin bash
|
||||
status:
|
||||
- test -e .bin/helm
|
||||
deps:
|
||||
- distrib-requirements
|
||||
|
||||
pre-commit:
|
||||
desc: Install a precommit pip package
|
||||
cmds:
|
||||
- python3 -m pip install --user pre-commit
|
||||
status:
|
||||
- type pre-commit
|
||||
deps:
|
||||
- distrib-requirements
|
||||
|
||||
# env-replacer:
|
||||
# desc: Install env-replace binary
|
||||
# cmds:
|
||||
# - wget -q "$URL_ENVREPLACER" -O - | tar -xz -C .bin && chmod +x .bin/env-replacer
|
||||
# status:
|
||||
# - test -e .bin/env-replacer
|
||||
# deps:
|
||||
# - distrib-requirements
|
||||
|
||||
go-replace:
|
||||
desc: Install go-replace
|
||||
cmds:
|
||||
# - echo wget -q "$URL_GOREPLACE" -O - | tar -xz -C .bin/ && chmod +x .bin/go-replace
|
||||
- wget -q "$URL_GOREPLACE" -O .bin/go-replace && chmod +x .bin/go-replace
|
||||
status:
|
||||
- test -e .bin/go-replace
|
||||
deps:
|
||||
- distrib-requirements
|
10
.taskfiles/Taskfile_windows.yml
Normal file
10
.taskfiles/Taskfile_windows.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
version: '3'
|
||||
|
||||
# Todo: add windows requirements
|
||||
|
||||
tasks:
|
||||
default:
|
||||
cmds:
|
||||
- task -l
|
||||
silent: true
|
@ -39,6 +39,23 @@ See `git help commit`:
|
||||
|
||||
Once changes have been merged, the release job will automatically run to package and release changed charts.
|
||||
|
||||
### Create new chart
|
||||
```
|
||||
# Clone
|
||||
git clone
|
||||
cd charts
|
||||
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b .bin
|
||||
|
||||
# Create chart
|
||||
PATH=$PATH:$PWD/.bin
|
||||
task chart:create CHART=chart_name
|
||||
# Don't forgot edit some chart informations in charts/char_name/Chart.yaml and charts/char_name/values.yaml
|
||||
|
||||
# Lint & Test
|
||||
task chart:lint CHART=chart_name
|
||||
task chart:test CHART=chart_name
|
||||
```
|
||||
|
||||
### Immutability
|
||||
|
||||
Chart releases must be immutable. Any change to a chart warrants a chart version bump even if it is only changed to the documentation.
|
||||
|
16
Taskfile.yml
Normal file
16
Taskfile.yml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
version: '3'
|
||||
|
||||
vars:
|
||||
GIT_ROOT:
|
||||
sh: git rev-parse --show-toplevel
|
||||
|
||||
includes:
|
||||
deps: .taskfiles/Taskfile_{{OS}}.yml
|
||||
chart: .taskfiles/Taskfile_chart.yml
|
||||
|
||||
tasks:
|
||||
default:
|
||||
cmds:
|
||||
- task -l
|
||||
silent: true
|
19
charts/.template/Chart.yaml
Normal file
19
charts/.template/Chart.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
apiVersion: v2
|
||||
appVersion: 1.0.0
|
||||
description: ${CHARTNAME} helm package
|
||||
name: ${CHARTNAME}
|
||||
version: 1.0.0
|
||||
keywords:
|
||||
- ${CHARTNAME}
|
||||
home: https://github.com/k8s-at-home/charts/tree/master/charts/${CHARTNAME}
|
||||
icon: https://${CHARTNAME}.org/icon
|
||||
sources:
|
||||
- https://github.com/${CHARTNAME}/${CHARTNAME}-docker
|
||||
- https://github.com/k8s-at-home/charts/tree/master/charts/${CHARTNAME}
|
||||
maintainers:
|
||||
- name: ${CHARTNAME}
|
||||
email: ${CHARTNAME}@${CHARTNAME}.com
|
||||
dependencies:
|
||||
- name: common
|
||||
repository: https://k8s-at-home.com/charts/
|
||||
version: 2.2.1
|
8
charts/.template/OWNERS
Normal file
8
charts/.template/OWNERS
Normal file
@ -0,0 +1,8 @@
|
||||
approvers:
|
||||
- billimek
|
||||
- onedr0p
|
||||
- bjw-s
|
||||
reviewers:
|
||||
- billimek
|
||||
- onedr0p
|
||||
- bjw-s
|
68
charts/.template/README.md
Normal file
68
charts/.template/README.md
Normal file
@ -0,0 +1,68 @@
|
||||
# ${CHARTNAME}
|
||||
|
||||
This is a helm chart for [${CHARTNAME}](https://${CHARTNAME}.org/).
|
||||
|
||||
**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)**
|
||||
|
||||
## TL;DR;
|
||||
|
||||
```shell
|
||||
$ helm repo add k8s-at-home https://k8s-at-home.com/charts/
|
||||
$ helm install k8s-at-home/${CHARTNAME}
|
||||
```
|
||||
|
||||
## Installing the Chart
|
||||
|
||||
To install the chart with the release name `my-release`:
|
||||
|
||||
```console
|
||||
helm install --name my-release k8s-at-home/${CHARTNAME}
|
||||
```
|
||||
|
||||
## Uninstalling the Chart
|
||||
|
||||
To uninstall/delete the `my-release` deployment:
|
||||
|
||||
```console
|
||||
helm delete my-release --purge
|
||||
```
|
||||
|
||||
The command removes all the Kubernetes components associated with the chart and deletes the release.
|
||||
|
||||
## Configuration
|
||||
Read through the charts [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/${CHARTNAME}/values.yaml)
|
||||
file. It has several commented out suggested values.
|
||||
Additionally you can take a look at the common library [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/common/values.yaml) for more (advanced) configuration options.
|
||||
|
||||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
|
||||
```console
|
||||
helm install ${CHARTNAME} \
|
||||
--set env.TZ="America/New_York" \
|
||||
k8s-at-home/${CHARTNAME}
|
||||
```
|
||||
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the
|
||||
chart. For example,
|
||||
```console
|
||||
helm install ${CHARTNAME} k8s-at-home/${CHARTNAME} --values values.yaml
|
||||
```
|
||||
|
||||
These values will be nested as it is a dependency, for example
|
||||
```yaml
|
||||
image:
|
||||
tag: ...
|
||||
```
|
||||
|
||||
---
|
||||
**NOTE**
|
||||
|
||||
If you get
|
||||
```console
|
||||
Error: rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: ...`
|
||||
```
|
||||
it may be because you uninstalled the chart with `skipuninstall` enabled, you need to manually delete the pvc or use `existingClaim`.
|
||||
|
||||
---
|
||||
|
||||
## Upgrading an existing Release to a new major version
|
||||
|
||||
A major chart version change (like 4.0.1 -> 5.0.0) indicates that there is an incompatible breaking change potentially needing manual actions.
|
1
charts/.template/templates/NOTES.txt
Normal file
1
charts/.template/templates/NOTES.txt
Normal file
@ -0,0 +1 @@
|
||||
{{- include "common.notes.defaultNotes" . -}}
|
1
charts/.template/templates/common.yaml
Normal file
1
charts/.template/templates/common.yaml
Normal file
@ -0,0 +1 @@
|
||||
{{ include "common.all" . }}
|
24
charts/.template/values.yaml
Normal file
24
charts/.template/values.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
# Default values for ${CHARTNAME}.
|
||||
|
||||
image:
|
||||
repository: ${CHARTNAME}/${CHARTNAME}
|
||||
pullPolicy: IfNotPresent
|
||||
tag: 1.2.5
|
||||
|
||||
strategy:
|
||||
type: Recreate
|
||||
|
||||
# See more environment varaibles in the ${CHARTNAME} documentation
|
||||
# https://${CHARTNAME}.org/docs
|
||||
env: {}
|
||||
# TZ:
|
||||
|
||||
service:
|
||||
port:
|
||||
port: 1880
|
||||
|
||||
# persistence:
|
||||
# data:
|
||||
# enabled: false
|
||||
# emptyDir: false
|
||||
# mountPath: /data
|
Loading…
Reference in New Issue
Block a user