Template Rendering
What problem this solves
Template rendering turns a loaded chart and merged values into Kubernetes manifests. HelmSharp uses Helm CLI output as a compatibility oracle in tests, while application code calls the managed renderer directly.
Packages to install
powershell
dotnet add package HelmSharp.Chart --version 1.1.0
dotnet add package HelmSharp.Engine --version 1.1.0Minimal complete code
csharp
public static async Task<string> RenderForTargetClusterAsync(
string chartPath,
CancellationToken cancellationToken)
{
var chart = await HelmChartLoader.LoadAsync(chartPath, cancellationToken);
var values = await HelmValues.BuildAsync(
chart,
valuesFiles: null,
valuesContent: null,
setValues: null,
setFileValues: null,
setStringValues: null,
setJsonValues: null,
cancellationToken: cancellationToken);
var renderer = new HelmTemplateRenderer(
chart,
releaseName: "preview",
releaseNamespace: "platform",
values: values,
kubeVersion: "1.30.0",
apiVersions:
[
"monitoring.coreos.com/v1",
"policy/v1"
],
isUpgrade: false);
return renderer.Render();
}Why these APIs
HelmTemplateRenderer exposes .Release, .Chart, .Values, .Capabilities, .Files, .Template, named templates, include, tpl, and common Helm/Sprig functions to templates. kubeVersion and apiVersions let you preview output for a target cluster instead of the machine running the renderer.
Production notes
- Use explicit
kubeVersionandapiVersionswhen previewing manifests for a known cluster. - Render NOTES separately with
RenderNotes()when the output is user-facing. - Include CRDs through
HelmClient.TemplateAsyncwithIncludeCRDs = truewhen you want command-like output.
Next step
Move to Release Workflows if you need install, upgrade, history, or rollback behavior.