helm

package
v0.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2026 License: BSD-3-Clause Imports: 16 Imported by: 0

README

Helm Provider

The Helm Provider extends the platform-health server to enable monitoring the status of Helm releases. It does this by interacting with the Helm API to check the status of the specified Helm release.

Usage

Once the Helm Provider is configured, any query to the platform health server will trigger validation of the configured Helm release(s). The server will attempt to check the status of each Helm release, and it will report each release as "healthy" if the Helm release exists and is in deployed state, or "unhealthy" otherwise.

Configuration

The Helm Provider is configured through the platform-health server's configuration file. Each instance is defined with its name as the YAML key under components.

  • type (required): Must be helm.
  • timeout (optional): Per-instance timeout override.
  • spec: Provider-specific configuration:
    • release (required): The name of the Helm release to monitor.
    • namespace (required): The namespace of the Helm release to monitor.
    • context (optional): Kubeconfig context to use.
  • checks: A list of CEL expressions for custom health validation. Each check has:
    • check (required): A CEL expression that must evaluate to true for the release to be healthy.
    • message (optional): Custom error message when the check fails.

For queries to succeed, the platform-health server must be run in a context with appropriate access privileges to list and get the Secret resources that Helm uses internally to track releases. Running "in-cluster", this means an appropriate service account, role and role binding must be configured.

CEL Check Context

The following variables are available in CEL expressions:

Release Properties
  • release.Name - Release name
  • release.Namespace - Release namespace
  • release.Revision - Release revision number (int)
  • release.Status - Release status (string: "deployed", "failed", etc.)
  • release.FirstDeployed - First deployment timestamp
  • release.LastDeployed - Last deployment timestamp
  • release.Deleted - Deletion timestamp
  • release.Description - Release description
  • release.Notes - Chart NOTES.txt content
  • release.Manifest - Parsed manifest resources (list of maps, one per YAML document)
  • release.Labels - Release labels (map)
  • release.Config - User-provided value overrides (map)
  • release.ApplyMethod - Apply strategy used for the release: "csa" (client-side apply) or "ssa" (server-side apply). Defaults to "csa" for pre-v4 releases.
  • release.Hooks - List of lifecycle hooks (list of maps). Each hook has:
    • Name - Hook resource name (string)
    • Kind - Kubernetes kind, e.g. "Job" (string)
    • Path - Chart-relative template path (string)
    • Events - When the hook fires (list of strings: "pre-install", "post-install", "pre-upgrade", "post-upgrade", "pre-delete", "post-delete", "pre-rollback", "post-rollback", "test")
    • Weight - Execution order among same-event hooks (int)
    • DeletePolicies - Cleanup policies (list of strings: "hook-succeeded", "hook-failed", "before-hook-creation")
    • OutputLogPolicies - Log capture policies (list of strings: "hook-succeeded", "hook-failed")
    • LastRun - Last execution result (map):
      • StartedAt - Execution start timestamp
      • CompletedAt - Execution completion timestamp
      • Phase - Result: "" (never run), "Unknown", "Running", "Succeeded", "Failed"
Chart Properties
  • chart.Name - Chart name
  • chart.Version - Chart version
  • chart.AppVersion - Application version
  • chart.Description - Chart description
  • chart.Deprecated - Whether chart is deprecated (bool)
  • chart.KubeVersion - Required Kubernetes version
  • chart.Type - Chart type
  • chart.Annotations - Chart annotations (map)
  • chart.Values - Chart default values (map)

Examples

Basic Helm Release Check
components:
  example:
    type: helm
    timeout: 5s
    spec:
      release: example-chart
      namespace: example-namespace

In this example, the Helm Provider will check the status of the Helm release named "example-chart" in the "example-namespace" namespace, and it will wait for 5s before timing out.

Helm Release with CEL Checks
components:
  my-app:
    type: helm
    timeout: 10s
    spec:
      release: my-app
      namespace: production
    checks:
      - check: "release.Revision >= 2"
        message: "Release must have at least one upgrade"
      - check: "!chart.Deprecated"
        message: "Chart is deprecated"
      - check: "'team' in release.Labels && 'env' in release.Labels"
        message: "Release must have team and env labels"
      - check: "release.Config['replicas'] >= 3"
        message: "Production must have at least 3 replicas"

This example validates that:

  • The release has been upgraded at least once
  • The chart is not deprecated
  • Required labels are present
  • The replica count meets production requirements
Hook Validation
components:
  my-app:
    type: helm
    spec:
      release: my-app
      namespace: production
    checks:
      - check: '!release.Hooks.exists(h, h.LastRun.Phase == "Failed")'
        message: "One or more hooks have failed"
      - check: 'release.Hooks.filter(h, h.Events.exists(e, e == "test")).size() > 0'
        message: "Release must have test hooks"
      - check: 'release.ApplyMethod == "ssa"'
        message: "Release must use server-side apply"

Documentation

Index

Constants

View Source
const (
	ProviderType   = "helm"
	DefaultTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component added in v0.6.0

type Component struct {
	provider.Base
	provider.BaseWithChecks

	Context   string `mapstructure:"context"`
	Release   string `mapstructure:"release"`
	Namespace string `mapstructure:"namespace"`
}

func (*Component) GetCheckConfig added in v0.6.0

func (c *Component) GetCheckConfig() *checks.CEL

GetCheckConfig returns the Helm provider's CEL variable declarations.

func (*Component) GetCheckContext added in v0.6.0

func (c *Component) GetCheckContext(ctx context.Context) (map[string]any, error)

GetCheckContext fetches the Helm release and returns the CEL evaluation context.

func (*Component) GetHealth added in v0.6.0

func (c *Component) GetHealth(ctx context.Context) *ph.HealthCheckResponse

func (*Component) GetType added in v0.6.0

func (c *Component) GetType() string

func (*Component) LogValue added in v0.6.0

func (c *Component) LogValue() slog.Value

func (*Component) SetChecks added in v0.7.0

func (c *Component) SetChecks(exprs []checks.Expression) error

SetChecks sets and compiles CEL expressions.

func (*Component) Setup added in v0.6.0

func (c *Component) Setup() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL