Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,56 @@ on:
push:
branches: [main]

env:
# renovate: datasource=github-releases depName=helm/helm
HELM_VERSION: v4.3.0
# renovate: datasource=github-releases depName=helm-unittest/helm-unittest
HELM_UNITTEST_VERSION: v1.2.1
# renovate: datasource=github-releases depName=yannh/kubeconform
KUBECONFORM_VERSION: v0.8.0

jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Helm
uses: azure/setup-helm@v4
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: ${{ env.HELM_VERSION }}

- name: Install helm-unittest plugin
# TODO: Remove --verify=false once helm-unittest publishes signed releases
# Tracking: https://github.com/helm-unittest/helm-unittest/issues/362
run: helm plugin install --verify=false https://github.com/helm-unittest/helm-unittest
# Helm 4 can only verify tarball installs, and only against the maintainer's GPG key.
run: helm plugin install --verify=false https://github.com/helm-unittest/helm-unittest --version "${HELM_UNITTEST_VERSION}"

- name: Lint
run: helm lint .

- name: Run unit tests
run: helm unittest .

validate-manifests:
runs-on: ubuntu-latest
strategy:
matrix:
# Oldest supported (README prerequisite) and newest available schemas.
kubernetes-version: ["1.26.15", "1.37.1"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: ${{ env.HELM_VERSION }}

- name: Set up just
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4

- name: Install kubeconform
run: |
curl -sSfL "https://github.com/yannh/kubeconform/releases/download/${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" \
| sudo tar -xz -C /usr/local/bin kubeconform

- name: Validate rendered manifests
run: just test manifests ${{ matrix.kubernetes-version }}
42 changes: 34 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,35 @@ permissions:
packages: write
contents: read

env:
# renovate: datasource=github-releases depName=helm/helm
HELM_VERSION: v4.3.0
# renovate: datasource=github-releases depName=helm-unittest/helm-unittest
HELM_UNITTEST_VERSION: v1.2.1
CHART_REPO: oci://ghcr.io/temikus/helm-charts

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Check tag matches chart version
run: |
CHART_VERSION=$(awk '/^version:/ {print $2}' Chart.yaml)
if [ "${GITHUB_REF_NAME}" != "v${CHART_VERSION}" ]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match Chart.yaml version ${CHART_VERSION}"
exit 1
fi

- name: Set up Helm
uses: azure/setup-helm@v4
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: ${{ env.HELM_VERSION }}

- name: Install helm-unittest plugin
# TODO: Remove --verify=false once helm-unittest publishes signed releases
# Tracking: https://github.com/helm-unittest/helm-unittest/issues/362
run: helm plugin install --verify=false https://github.com/helm-unittest/helm-unittest
# Helm 4 can only verify tarball installs, and only against the maintainer's GPG key.
run: helm plugin install --verify=false https://github.com/helm-unittest/helm-unittest --version "${HELM_UNITTEST_VERSION}"

- name: Lint
run: helm lint .
Expand All @@ -33,16 +49,26 @@ jobs:
needs: validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Helm
uses: azure/setup-helm@v4
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1
with:
version: ${{ env.HELM_VERSION }}

- name: Login to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Refuse to overwrite a published version
# GHCR accepts a push to an existing tag and replaces the artifact.
run: |
if helm show chart "${CHART_REPO}/workload" --version "${GITHUB_REF_NAME#v}" >/dev/null 2>&1; then
echo "::error::workload ${GITHUB_REF_NAME#v} is already published"
exit 1
fi

- name: Package chart
run: helm package .

- name: Push chart
run: helm push workload-*.tgz oci://ghcr.io/temikus/helm-charts
run: helm push workload-*.tgz "${CHART_REPO}"
3 changes: 3 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ CONTRIBUTING.md
CHANGELOG.md
.github/
docs/
ci/
.mise.toml
renovate.json
3 changes: 3 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tools]
trufflehog = "latest"
kubeconform = "0.8.0"
6 changes: 4 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ General-purpose Kubernetes workload Helm chart with addon sidecars (VPN, Postgre
Run from this directory (`charts/workload`):

- `just lint` — helm lint
- `just test` — helm unittest
- `just test -u` — update snapshots
- `just test` — helm unittest + kubeconform on `ci/*-values.yaml`
- `just test unit -u` — update snapshots
- `just test manifests [k8s-version]` — kubeconform only
- `helm unittest -f tests/<test_name>.yaml .` — run single test file

## Architecture
Expand Down Expand Up @@ -101,3 +102,4 @@ When modifying an addon:
- `values.yaml` — default values
- `values.schema.json` — JSON schema validation
- `tests/addons_<name>_test.yaml` — unit tests
- `ci/addons-values.yaml` — kubeconform render coverage (`just test manifests`); CRD kinds need a schema in `ci/schemas/`
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Thank you for your interest in contributing! This document provides guidelines f
## Development Setup

1. Install prerequisites:
- [Helm](https://helm.sh/) 3.x
- [helm-unittest](https://github.com/helm-unittest/helm-unittest) plugin: `helm plugin install https://github.com/helm-unittest/helm-unittest`
- [Helm](https://helm.sh/) 4
- [helm-unittest](https://github.com/helm-unittest/helm-unittest) plugin: `helm plugin install --verify=false https://github.com/helm-unittest/helm-unittest`
- [kubeconform](https://github.com/yannh/kubeconform), for `just test manifests` (or `mise install`)
- [just](https://github.com/casey/just) (optional, for task automation)

2. Clone the repository:
Expand Down Expand Up @@ -37,6 +38,7 @@ Every change should include corresponding tests:
- Use `failedTemplate` assertions to test validation guards
- Run `helm unittest .` to execute all tests
- Run `helm unittest . -u` to update snapshots after intentional changes
- Cover new values in `ci/*-values.yaml`; `just test manifests` validates those renders with kubeconform. A new CRD kind also needs its JSON schema in `ci/schemas/`

### Schema Validation

Expand All @@ -46,7 +48,7 @@ If you add or modify values, update `values.schema.json` accordingly. The schema

1. Fork the repository and create a feature branch
2. Make your changes with tests
3. Ensure all tests pass: `helm unittest .`
3. Ensure all tests pass: `just test`
4. Ensure linting passes: `helm lint .`
5. Submit a pull request with a clear description of the changes

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A general-purpose Kubernetes workload Helm chart with batteries included. Deploy
## Prerequisites

- Kubernetes 1.26+
- Helm 3.x
- Helm 4

## Installation

Expand Down Expand Up @@ -279,16 +279,18 @@ extraServices:

### Prerequisites

- [Helm](https://helm.sh/) 3.x
- [Helm](https://helm.sh/) 4
- [helm-unittest](https://github.com/helm-unittest/helm-unittest) plugin
- [kubeconform](https://github.com/yannh/kubeconform) (or `mise install`)
- [just](https://github.com/casey/just) (optional, for task automation)

### Commands

```bash
just lint # Lint the chart
just test # Run unit tests
just test -u # Update test snapshots
just test # Run unit tests and manifest validation
just test unit -u # Update test snapshots
just test manifests 1.26.15 # Validate ci/*-values.yaml renders against a Kubernetes version
just build # Package the chart
```

Expand Down
48 changes: 48 additions & 0 deletions ci/addons-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
image:
repository: nginx
tag: "1.27"
ports:
- name: http
port: 8080
service:
enabled: true
addons:
init:
enabled: true
command: ["sh", "-c", "echo init"]
vpn:
enabled: true
provider:
name: mullvad
type: wireguard
wireguard:
privateKey: not-a-key
addresses:
- 10.0.0.2/32
postgres:
enabled: true
auth:
password: not-a-password
cloudflareTunnel:
enabled: true
fqdn: app.example.com
targetPort: 8080
pathFilter:
enabled: true
paths:
- /webhook
tunnel:
create: true
cloudflare:
accountId: "0123456789"
domain: example.com
email: ops@example.com
credentials:
apiToken: not-a-token
networkPolicy:
enabled: true
infisical:
enabled: true
hostAPI: https://app.infisical.com/api
projectSlug: example
envSlug: prod
44 changes: 44 additions & 0 deletions ci/default-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
image:
repository: nginx
tag: "1.27"
ports:
- name: http
port: 80
service:
enabled: true
ingress:
enabled: true
className: nginx
hosts:
- host: example.local
paths:
- path: /
pathType: Prefix
tls:
- secretName: example-tls
hosts:
- example.local
autoscaling:
enabled: true
env:
LOG_LEVEL: info
secretEnv:
API_TOKEN: not-a-secret
health:
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
networkPolicy:
enabled: true
extraServices:
- name: metrics
type: ClusterIP
ports:
- name: metrics
port: 9090
targetPort: http
Loading
Loading