38 / 75 · 08 Infrastructure as Code Testing · Helm Chart Testing← prev⊞ allnext →☰ Read as one page
7.4Template Rendering and Validation
Rendering templates without deploying is the most important testing step. It catches issues that lint cannot detect because lint does not evaluate template logic.
# Render templates with default values
helm template myapp ./charts/myapp/
# Render with production values
helm template myapp ./charts/myapp/ \
--values values-production.yaml
# Pipe rendered output to kubeconform for K8s schema validation
helm template myapp ./charts/myapp/ \
--values values-production.yaml | kubeconform -strict
# Test with multiple value files
helm template myapp ./charts/myapp/ \
--values values-production.yaml \
--values values-us-east-1.yaml | kubeconform -strict
# Render with value overrides to test specific scenarios
helm template myapp ./charts/myapp/ \
--set replicas=1 \
--set image.tag=latest \
--set ingress.enabled=true | kubeconform -strict
Testing All Value Combinations
#!/bin/bash
# scripts/test-helm-values.sh
# Test chart rendering with all supported value files
CHART_DIR="./charts/myapp"
FAILURES=0
# Test each environment's values
for values_file in values-*.yaml; do
echo "Testing with $values_file..."
if ! helm template myapp "$CHART_DIR" --values "$values_file" | kubeconform -strict; then
echo "FAIL: $values_file produces invalid manifests"
FAILURES=$((FAILURES + 1))
fi
done
# Test with minimal values (defaults only)
echo "Testing with defaults only..."
if ! helm template myapp "$CHART_DIR" | kubeconform -strict; then
echo "FAIL: Default values produce invalid manifests"
FAILURES=$((FAILURES + 1))
fi
if [ $FAILURES -gt 0 ]; then
echo "$FAILURES value combinations failed"
exit 1
fi
echo "All value combinations passed"