Rendering & Validating in CI
Everything this course has run offline belongs in CI, on every pull request, before anything reaches a cluster: lint the chart, render every environment, validate the output, and show reviewers what will actually change. The cluster should never be the first place a packaging bug shows up.
The checks, in order
| Step | Command | Catches |
|---|---|---|
| 1. lint | helm lint --strict -f values-<env>.yaml per environment |
template errors, schema violations, bad chart metadata |
| 2. render | helm template … -f values-<env>.yaml, kustomize build overlays/<env> |
anything that breaks rendering with real environment values |
| 3. validate | … | kubeconform -strict -summary |
invalid objects, removed APIs, CRD mistakes |
| 4. policy | kube-linter, Kyverno CLI, Conftest (optional) | "no latest tags", "limits required", house rules |
| 5. diff | render the base branch too, diff the two |
shows reviewers the real change |
One script for laptops and CI
Put the steps in a script in the repository, so a developer runs exactly what CI runs. The session sets up a small deployment repository with linkly's chart and two environments, then runs the script:
mkdir -p deploy/chart/linkly/templates && cd deploy
cat > chart/linkly/Chart.yaml <<'EOF'
apiVersion: v2
name: linkly
version: 1.0.0
appVersion: "1.4.0"
icon: https://example.com/linkly.svg
EOF
cat > chart/linkly/values.yaml <<'EOF'
replicaCount: 2
image: {repository: ghcr.io/acme/linkly, tag: ""}
EOF
cat > chart/linkly/templates/deployment.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
spec:
replicas: {{ .Values.replicaCount }}
selector: {matchLabels: {app.kubernetes.io/instance: {{ .Release.Name }}}}
template:
metadata: {labels: {app.kubernetes.io/instance: {{ .Release.Name }}}}
spec:
containers:
- name: linkly
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
EOF
mkdir -p env
printf 'replicaCount: 1\nimage: {tag: "1.5.0-rc.2"}\n' > env/staging.yaml
printf 'replicaCount: 4\n' > env/production.yaml
cat > validate.sh <<'EOF'
#!/usr/bin/env bash
# Lint, render and validate every environment. Usage: ./validate.sh [output-dir]
set -euo pipefail
out=${1:-rendered}
rm -rf "$out" && mkdir -p "$out"
for values in env/*.yaml; do
env=$(basename "$values" .yaml)
helm lint chart/linkly --strict --quiet -f "$values"
helm template linkly chart/linkly -n "linkly-$env" -f "$values" > "$out/$env.yaml"
printf '%-11s ' "$env:"
kubeconform -strict -summary "$out/$env.yaml"
done
EOF
chmod +x validate.sh
./validate.shproduction: Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0
staging: Summary: 1 resource found in 1 file - Valid: 1, Invalid: 0, Errors: 0, Skipped: 0
set -euo pipefail makes the first failing step fail the script (the planned DevOps Scripting course explains each flag). --quiet keeps lint silent unless something is wrong.
Rendered manifests and PR diffs
Many teams commit the rendered output next to the sources. Reviewers then see the exact objects that will change, and GitOps tools can apply plain YAML. CI re-renders and fails if the committed files are stale. The session commits a rendered state, makes a "harmless" values change, and shows what CI reports:
mkdir -p deploy/chart/linkly/templates deploy/env && cd deploy
git init -q && git config user.email ci@example.com && git config user.name CI
printf 'apiVersion: v2\nname: linkly\nversion: 1.0.0\nappVersion: "1.4.0"\n' > chart/linkly/Chart.yaml
printf 'replicaCount: 2\nlogLevel: info\n' > chart/linkly/values.yaml
cat > chart/linkly/templates/configmap.yaml <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-config
data:
LOG_LEVEL: {{ .Values.logLevel | quote }}
REPLICAS: {{ .Values.replicaCount | quote }}
EOF
printf 'replicaCount: 4\n' > env/production.yaml
printf 'replicaCount: 1\n' > env/staging.yaml
render() { for v in env/*.yaml; do helm template linkly chart/linkly -f "$v" > "rendered/$(basename "$v")"; done; }
mkdir rendered && render && git add . && git commit -q -m "linkly 1.0.0, rendered"
echo "--- a developer edits the chart defaults but forgets to re-render:"
sed -i 's/logLevel: info/logLevel: warn/' chart/linkly/values.yaml
git commit -q -am "quieter logs"
echo "--- CI re-renders and compares:"
render
git diff --stat
git diff -U0 -- rendered/ | grep -E '^(\+\+\+|[-+] )'
git diff --exit-code --quiet || echo "FAIL: rendered/ is out of date; run the render step and commit the result"--- a developer edits the chart defaults but forgets to re-render:
--- CI re-renders and compares:
rendered/production.yaml | 2 +-
rendered/staging.yaml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
+++ b/rendered/production.yaml
- LOG_LEVEL: "info"
+ LOG_LEVEL: "warn"
+++ b/rendered/staging.yaml
- LOG_LEVEL: "info"
+ LOG_LEVEL: "warn"
FAIL: rendered/ is out of date; run the render step and commit the result
The diff shows that a one-line change to the chart's defaults touched both environments, which is exactly what a reviewer needs to see before approving.
A GitHub Actions job
A workflow that runs the script on every pull request (a configuration file, not run here). Tools are installed from their official release archives at pinned versions:
# .github/workflows/manifests.yml
name: manifests
on:
pull_request:
paths: ["chart/**", "env/**", "overlays/**", "validate.sh"]
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-24.04
env:
HELM_VERSION: v4.3.1
KUBECONFORM_VERSION: v0.8.0
steps:
- uses: actions/checkout@v7
- name: Install tools
run: |
curl -fsSL "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" | tar -xz linux-amd64/helm
sudo install linux-amd64/helm /usr/local/bin/helm
curl -fsSL "https://github.com/yannh/kubeconform/releases/download/${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" | tar -xz kubeconform
sudo install kubeconform /usr/local/bin/kubeconform
- name: Lint, render, validate
run: ./validate.sh rendered
- name: Rendered manifests are up to date
run: git diff --exit-code -- rendered/In a real pipeline also verify the downloads against their published checksums, pin actions by commit SHA, and pass -kubernetes-version and -schema-location to kubeconform as in Validating with kubeconform. The planned CI/CD course covers workflow security; the Toolkit covers ct (chart-testing), which wraps lint and install tests for chart repositories.
Publishing the chart from CI
On a merge to main (or a tag), a second job packages and pushes the chart. The version comes from the tag, never from a person:
version=${GITHUB_REF_NAME#v} # tag v1.0.3 -> 1.0.3
helm package chart/linkly --version "$version" --app-version "$APP_VERSION"
echo "$GITHUB_TOKEN" | helm registry login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
helm push "linkly-$version.tgz" oci://ghcr.io/acme/chartsAdd a signature (cosign sign on the pushed digest) so clusters and GitOps tools can verify where the chart came from (Supply Chain Security).
Test yourself
Why put the lint/render/validate steps in a script in the repo instead of only in the CI YAML?
- CI can't run commands
- Developers can run exactly what CI runs before pushing
- Scripts are faster
- Helm requires it
What does committing rendered manifests give reviewers?
- Faster builds
- The exact objects each environment will receive, as a diff
- Encrypted secrets
- Automatic rollbacks
Which command makes CI fail when re-rendering changed committed files?
- git status
- git diff --exit-code
- helm lint --strict
- kubeconform -summary