Skip to content

Commit

Permalink
Update charts
Browse files Browse the repository at this point in the history
Signed-off-by: d-kuro <[email protected]>
  • Loading branch information
d-kuro committed Aug 18, 2021
1 parent a7f2a92 commit 713a85b
Show file tree
Hide file tree
Showing 23 changed files with 566 additions and 145 deletions.
4 changes: 4 additions & 0 deletions .cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is the config file for helm/chart-releaser
owner: cybozu-go
git-repo: accurate
release-name-template: "{{ .Name }}-chart-v{{ .Version }}"
30 changes: 30 additions & 0 deletions .github/workflows/helm-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release Charts

on: workflow_dispatch

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
# Add depending repository for helm to avoid the error below.
# `Error: no repository definition for https://charts.jetstack.io`
# see: https://github.com/helm/chart-releaser-action/issues/74
- name: Add cert-manager repo for helm
run: helm repo add cert-manager https://charts.jetstack.io

- name: Run chart-releaser
uses: helm/[email protected]
with:
config: .cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
55 changes: 55 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Lint and Test Charts

on:
pull_request:
paths:
- "charts/**"

jobs:
lint-test:
runs-on: ubuntu-18.04

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup helm-docs
run: |
HELM_DOCS_VERSION="1.5.0"
OS=$(uname)
curl -L -sS https://github.com/norwoodj/helm-docs/releases/download/v"${HELM_DOCS_VERSION}"/helm-docs_"${HELM_DOCS_VERSION}"_${OS}_x86_64.tar.gz \
| tar zx -C /tmp
sudo mv /tmp/helm-docs /usr/local/bin
- name: Run helm-docs
run: helm-docs && git diff --no-patch --exit-code

- uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml

- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'

- name: Apply cert-manager CRDs
run: kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.1/cert-manager.crds.yaml

- name: Run chart-testing (install)
run: ct install --config ct.yaml
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@

# Generated files
/docs/book

# Ignore dependency charts
charts/*/charts
27 changes: 18 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Tool versions
CTRL_TOOLS_VERSION=0.6.1
CTRL_RUNTIME_VERSION := $(shell awk '/sigs.k8s.io\/controller-runtime/ {print substr($$2, 2)}' go.mod)
KUSTOMIZE_VERSION = 4.1.3
HELM_VERSION = 3.6.3
HELM_DOCS_VERSION = 1.5.0
CRD_TO_MARKDOWN_VERSION = 0.0.3
MDBOOK_VERSION = 0.4.10

Expand Down Expand Up @@ -92,7 +93,7 @@ build:
GOBIN=$(shell pwd)/bin go install ./cmd/...

.PHONY: release-build
release-build: kustomize
release-build:
rm -rf build
mkdir -p build
$(MAKE) kubectl-accurate GOOS=windows GOARCH=amd64 SUFFIX=.exe
Expand Down Expand Up @@ -120,14 +121,22 @@ $(SETUP_ENVTEST):
# see https://github.com/kubernetes-sigs/controller-runtime/tree/master/tools/setup-envtest
GOBIN=$(shell pwd)/bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

KUSTOMIZE := $(shell pwd)/bin/kustomize
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
HELM := $(shell pwd)/bin/helm
.PHONY: helm
helm: $(HELM) ## Download helm locally if necessary.

$(KUSTOMIZE):
mkdir -p bin
curl -fsL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv$(KUSTOMIZE_VERSION)/kustomize_v$(KUSTOMIZE_VERSION)_linux_amd64.tar.gz | \
tar -C bin -xzf -
$(HELM):
mkdir -p $(BIN_DIR)
curl -L -sS https://get.helm.sh/helm-v$(HELM_VERSION)-linux-amd64.tar.gz \
| tar xvz -C $(BIN_DIR) --strip-components 1 linux-amd64/helm

HELM_DOCS := $(shell pwd)/bin/helm-docs
.PHONY: helm-docs
helm-docs: $(HELM_DOCS) ## Download helm-docs locally if necessary.

$(HELM_DOCS):
mkdir -p $(BIN_DIR)
GOBIN=$(BIN_DIR) go install github.com/norwoodj/helm-docs/cmd/helm-docs@v$(HELM_DOCS_VERSION)

CRD_TO_MARKDOWN := $(shell pwd)/bin/crd-to-markdown
.PHONY: crd-to-markdown
Expand Down
6 changes: 6 additions & 0 deletions charts/accurate/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: cert-manager
repository: https://charts.jetstack.io
version: v1.5.1
digest: sha256:d00aee7a3873a9ced5b1212b4a904c54629112b1fdc59baab00899d39a885593
generated: "2021-08-18T12:07:14.637063+09:00"
6 changes: 6 additions & 0 deletions charts/accurate/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ version: 0.1.0
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: 0.1.0

dependencies:
- name: cert-manager
repository: https://charts.jetstack.io
version: 1.5.1
condition: cert-manager.enabled
111 changes: 111 additions & 0 deletions charts/accurate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Accurate Helm Chart

## How to use Accurate Helm repository

You need to add this repository to your Helm repositories:

```sh
helm repo add accurate https://cybozu-go.github.io/accurate/
helm repo update
```

## Dependencies

| Repository | Name | Version |
| ---------- | ---- | ------- |
| https://charts.jetstack.io | cert-manager | 1.5.0 |

## Quick start

### Installing the Chart

> NOTE:
>
> This installation method requires cert-manger to be installed beforehand.
To install the chart with the release name `accurate` using a dedicated namespace(recommended):

```sh
helm install --create-namespace --namespace accurate accurate accurate/accurate
```

Specify parameters using `--set key=value[,key=value]` argument to `helm install`.

Alternatively a YAML file that specifies the values for the parameters can be provided like this:

```sh
helm upgrade --create-namespace --namespace accurate -i accurate -f values.yaml accurate/accurate
```

### Install together with cert-manager

Before installing the chart, you must first install the cert-manager CustomResourceDefinition resources.

```sh
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.0/cert-manager.crds.yaml
```

Set the `cert-manager.enabled=true` parameter when installing Accurate chart:

```sh
helm install --create-namespace --namespace accurate accurate accurate/accurate --set cert-manager.enabled=true
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| cert-manager.enabled | bool | `false` | Install cert-manager together. |
| controller.additionalRBAC.rules | list | `[]` | Specify the RBAC rules to be added to the controller. ClusterRole and ClusterRoleBinding are created with the names `{{ release name }}-additional-resources`. The rules defined here will be used for the ClusterRole rules. |
| controller.config.annotationKeys | list | `[]` | Annotations to be propagated to sub-namespaces. It is also possible to specify a glob pattern that can be interpreted by Go's "path.Match" func. |
| controller.config.labelKeys | list | `[]` | Labels to be propagated to sub-namespaces. It is also possible to specify a glob pattern that can be interpreted by Go's "path.Match" func. |
| controller.config.watches | list | `[{"group":"rbac.authorization.k8s.io","kind":"Role","version":"v1"},{"group":"rbac.authorization.k8s.io","kind":"RoleBinding","version":"v1"},{"kind":"Secret","version":"v1"}]` | List of GVK for namespace-scoped resources that can be propagated. Any namespace-scoped resource is allowed. |
| controller.replicas | int | `2` | Specify the number of replicas of the controller Pod. |
| controller.resources | object | `{"requests":{"cpu":"100m","memory":"20Mi"}}` | Specify resources. |
| controller.terminationGracePeriodSeconds | int | `10` | Specify terminationGracePeriodSeconds. |
| image.pullPolicy | string | `nil` | Accurate image pullPolicy. |
| image.repository | string | `"ghcr.io/cybozu-go/accurate"` | Accurate image repository to use. |
| image.tag | string | `{{ .Chart.AppVersion }}` | Accurate image tag to use. |

## Generate Manifests

You can use the `helm template` command to render manifests.

```sh
helm template --namespace accurate accurate accurate/accurate
```

## Upgrade CRDs

There is no support at this time for upgrading or deleting CRDs using Helm.
Users must manually upgrade the CRD if there is a change in the CRD used by Accurate.

https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#install-a-crd-declaration-before-using-the-resource

## Update README

The `README.md` for this chart is generated by [helm-docs](https://github.com/norwoodj/helm-docs).
To update the README, edit the `README.md.gotmpl` file and run the helm-docs command.

```console
# path to Accurate repository root
$ make helm-docs
$ ./bin/helm-docs
helm-docs
INFO[2021-07-25T23:53:15+09:00] Found Chart directories [charts/accurate]
INFO[2021-07-25T23:53:15+09:00] Generating README Documentation for chart /path/to/dir/github.com/cybozu-go/accurate/charts/accurate
```

## Release Chart

Accurate Helm Chart will be released independently.
This will prevent the Accurate version from going up just by modifying the Helm Chart.

You must change the version of `Chart.yaml` when making changes to the Helm Chart.
CI fails with lint error when creating a Pull Request without changing the version of `Chart.yaml`.

When you release the Helm Chart, manually run the GitHub Actions workflow for the release.

https://github.com/cybozu-go/accurate/actions/workflows/helm-release.yaml

When you run workflow, [helm/chart-releaser-action](https://github.com/helm/chart-releaser-action) will automatically create a GitHub Release.
97 changes: 97 additions & 0 deletions charts/accurate/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Accurate Helm Chart

## How to use Accurate Helm repository

You need to add this repository to your Helm repositories:

```sh
helm repo add accurate https://cybozu-go.github.io/accurate/
helm repo update
```

## Dependencies

| Repository | Name | Version |
| ---------- | ---- | ------- |
| https://charts.jetstack.io | cert-manager | 1.5.0 |

## Quick start

### Installing the Chart

> NOTE:
>
> This installation method requires cert-manger to be installed beforehand.

To install the chart with the release name `accurate` using a dedicated namespace(recommended):

```sh
helm install --create-namespace --namespace accurate accurate accurate/accurate
```

Specify parameters using `--set key=value[,key=value]` argument to `helm install`.

Alternatively a YAML file that specifies the values for the parameters can be provided like this:

```sh
helm upgrade --create-namespace --namespace accurate -i accurate -f values.yaml accurate/accurate
```

### Install together with cert-manager

Before installing the chart, you must first install the cert-manager CustomResourceDefinition resources.

```sh
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.0/cert-manager.crds.yaml
```

Set the `cert-manager.enabled=true` parameter when installing Accurate chart:

```sh
helm install --create-namespace --namespace accurate accurate accurate/accurate --set cert-manager.enabled=true
```

{{ template "chart.valuesSection" . }}

## Generate Manifests

You can use the `helm template` command to render manifests.

```sh
helm template --namespace accurate accurate accurate/accurate
```

## Upgrade CRDs

There is no support at this time for upgrading or deleting CRDs using Helm.
Users must manually upgrade the CRD if there is a change in the CRD used by Accurate.

https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#install-a-crd-declaration-before-using-the-resource

## Update README

The `README.md` for this chart is generated by [helm-docs](https://github.com/norwoodj/helm-docs).
To update the README, edit the `README.md.gotmpl` file and run the helm-docs command.

```console
# path to Accurate repository root
$ make helm-docs
$ ./bin/helm-docs
helm-docs
INFO[2021-07-25T23:53:15+09:00] Found Chart directories [charts/accurate]
INFO[2021-07-25T23:53:15+09:00] Generating README Documentation for chart /path/to/dir/github.com/cybozu-go/accurate/charts/accurate
```

## Release Chart

Accurate Helm Chart will be released independently.
This will prevent the Accurate version from going up just by modifying the Helm Chart.

You must change the version of `Chart.yaml` when making changes to the Helm Chart.
CI fails with lint error when creating a Pull Request without changing the version of `Chart.yaml`.

When you release the Helm Chart, manually run the GitHub Actions workflow for the release.

https://github.com/cybozu-go/accurate/actions/workflows/helm-release.yaml

When you run workflow, [helm/chart-releaser-action](https://github.com/helm/chart-releaser-action) will automatically create a GitHub Release.
2 changes: 2 additions & 0 deletions charts/accurate/ci/enable-certmanager-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cert-manager:
enabled: true
Loading

0 comments on commit 713a85b

Please sign in to comment.