Skip to content

Repository files navigation

HelmSharp

CI NuGet NuGet Downloads License

简体中文

HelmSharp is a managed .NET library for rendering Helm-style charts and driving Kubernetes release workflows without invoking the helm executable. It is intended for applications that need Helm-like behavior inside a .NET process: template rendering, values merging, chart packaging, repository operations, and release lifecycle operations against Kubernetes.

The project is under active development. M1 (Helm template parity), M2 (chart packaging and repository parity), and M3 (release lifecycle parity) are complete. The renderer and lifecycle flows are continuously checked with focused fixtures, controlled Kubernetes dependencies, and selected public Helm charts. Later milestones expand Kubernetes semantics and compatibility coverage.

The latest published version is 1.3.1. The M2 chart-distribution and M3 release-lifecycle capabilities described below and in the linked guides are available in the 1.3.1 NuGet packages.

Documentation site: https://gattgeng.github.io/HelmSharp/

The documentation now includes workflow guides, realistic integration examples, package-by-package guidance, and generated API reference pages for public types and members.

Packages

This repository is organized as several NuGet packages:

Package Purpose
HelmSharp.Action High-level Helm client API and release operations.
HelmSharp.Chart Chart loading, values merging, YAML helpers, chart metadata.
HelmSharp.Engine Helm-style template rendering.
HelmSharp.Kube Kubernetes manifest apply/delete/wait helpers.
HelmSharp.Release Helm release storage records backed by Kubernetes Secrets.
HelmSharp.Repo Chart repository, index, pull, and search helpers.
HelmSharp.Registry Registry-related extension point package.
HelmSharp.Storage Storage extension point package.
HelmSharp.PostRenderer Post-renderer extension point package.

For most applications, start with HelmSharp.Action.

Requirements

  • .NET 8, .NET 9, and .NET 10 SDKs for building all target frameworks locally.
  • A Kubernetes cluster and kubeconfig for release install, upgrade, rollback, uninstall, and status operations.
  • No helm binary is required.
  • Supported package target frameworks: net8.0, net9.0, and net10.0.
  • .NET Framework is not supported unless a future release adds a netstandard target.

Installation

dotnet add package HelmSharp.Action

For lower-level use cases:

dotnet add package HelmSharp.Chart
dotnet add package HelmSharp.Engine

Quick Start

Render a local chart:

using HelmSharp.Action;

var client = new HelmClient(new StaticHelmOptionsProvider());

var result = await client.TemplateAsync(new HelmTemplateRequest
{
    ReleaseName = "demo",
    Namespace = "default",
    Chart = @"C:\charts\my-chart",
    SetValues = new Dictionary<string, string>
    {
        ["image.tag"] = "1.2.3",
        ["replicaCount"] = "2"
    }
});

Console.WriteLine(result.StandardOutput);

sealed class StaticHelmOptionsProvider : IHelmOptionsProvider
{
    public ValueTask<HelmExecutionOptions> GetHelmAsync(CancellationToken cancellationToken = default)
        => ValueTask.FromResult(new HelmExecutionOptions
        {
            DefaultNamespace = "default",
            FieldManager = "helmsharp"
        });
}

More complete examples are available in examples.

Install or upgrade a release:

var result = await client.UpgradeInstallAsync(new HelmUpgradeInstallRequest
{
    ReleaseName = "demo",
    Namespace = "default",
    Chart = @"C:\charts\my-chart",
    CreateNamespace = true,
    Wait = true,
    TimeoutSeconds = 300
});

if (result.ExitCode != 0)
{
    Console.Error.WriteLine(result.StandardError);
}
else
{
    Console.WriteLine(result.StandardOutput);
}

Run a dry run without mutating the cluster:

await foreach (var line in client.UpgradeInstallStreamAsync(new HelmUpgradeInstallRequest
{
    ReleaseName = "demo",
    Namespace = "default",
    Chart = @"C:\charts\my-chart",
    DryRun = true
}))
{
    Console.WriteLine(line);
}

Supported Capabilities

The list below describes the current master branch. See the version note above before using M2 APIs from NuGet.

  • Chart loading from directories and .tgz archives.
  • values.yaml, inline values, --set, --set-string, --set-json, and --set-file-style value overrides.
  • Helm-style template rendering for common control flow and functions.
  • Helm-compatible chart packaging with .helmignore, version/appVersion overrides, dependencies, and safe archive layout.
  • Traditional HTTP repository config/cache management, index generation/merge, offline search, semantic-version pull, digest verification, and safe extraction.
  • Dependency list/update/build with Helm-compatible Chart.lock, repository aliases, chart aliases, and local file:// dependencies.
  • Managed Kubernetes apply/delete/wait operations for common Kubernetes resources.
  • Helm v3-compatible release history stored in Kubernetes Secrets, including failed and retained-uninstall revisions.
  • Install, upgrade, uninstall, rollback, status, history, manifest, values, hooks, notes, and test-oriented APIs with revision-aware inspection, lifecycle timeouts, atomic recovery, and deterministic hook execution.

See the chart packaging and repository workflow guide for complete examples. OCI/provenance parity remains planned separately.

Compatibility Validation

HelmSharp uses focused fixture charts and selected public charts to compare managed rendering with helm template. These tests prevent regressions in the behaviors they exercise; they do not certify every Helm chart or every Sprig function.

The maintained template-function compatibility matrix records the exact Helm/Sprig baseline and the status of every exposed function.

For supported behavior, known boundaries, and guidance for validating a production chart, see Helm Compatibility.

Known Scope

HelmSharp is not a full Helm CLI clone. An unimplemented template function produces a path-aware rendering diagnostic; it is not silently substituted. Kubernetes apply/delete discovers resource kinds from the target cluster for kinds outside the typed client surface, while readiness handling remains selective. Advanced Helm behaviors, plugins, provenance verification flows, and OCI authentication flows may need additional implementation.

Documentation

Build

dotnet restore HelmSharp.sln
dotnet build HelmSharp.sln --configuration Release --no-restore
dotnet test HelmSharp.sln --configuration Release --no-build --no-restore

Pack

dotnet pack HelmSharp.sln --configuration Release --no-build --output artifacts/packages

The NuGet package metadata is defined in src/Directory.Build.props. The package README is packed from this file.

Continuous Integration and Release

This repository includes GitHub Actions workflows:

  • .github/workflows/ci.yml restores, builds, tests, packs, and uploads package artifacts on pushes and pull requests.
  • .github/workflows/deploy-docs.yml builds the VitePress documentation site and deploys it to GitHub Pages on pushes to master.
  • .github/workflows/release-nuget.yml packs release packages and can publish them to NuGet.org.

NuGet.org publishing is handled by maintainers through the release workflow.

Contributing

See CONTRIBUTING.md.

Security

Please report security issues privately. See SECURITY.md.

License

HelmSharp is licensed under the MIT License.

About

Managed Helm-compatible chart rendering and Kubernetes release workflows for .NET.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages