Helm Charts

The GitOps Toolkit Custom Resource Definitions documentation.

The HelmChart API defines a source for Helm chart artifacts coming from HelmRepository sources. The resource exposes the latest pulled or packaged chart as an artifact.

Specification

Helm chart:

// HelmChartSpec defines the desired state of a Helm chart.
type HelmChartSpec struct {
	// The name or path the Helm chart is available at in the SourceRef.
	// +required
	Chart string `json:"chart"`

	// The chart version semver expression, ignored for charts from GitRepository
	// and Bucket sources. Defaults to latest when omitted.
	// +optional
	Version string `json:"version,omitempty"`

	// The reference to the Source the chart is available at.
	// +required
	SourceRef LocalHelmChartSourceReference `json:"sourceRef"`

	// The interval at which to check the Source for updates.
	// +required
	Interval metav1.Duration `json:"interval"`

	// Alternative list of values files to use as the chart values (values.yaml
	// is not included by default), expected to be a relative path in the SourceRef.
	// Values files are merged in the order of this list with the last file overriding
	// the first. Ignored when omitted.
	// +optional
	ValuesFiles []string `json:"valuesFiles,omitempty"`

	// Alternative values file to use as the default chart values, expected to
	// be a relative path in the SourceRef. Deprecated in favor of ValuesFiles,
	// for backwards compatibility the file defined here is merged before the
	// ValuesFiles items. Ignored when omitted.
	// +optional
	// +deprecated
	ValuesFile string `json:"valuesFile,omitempty"`

	// This flag tells the controller to suspend the reconciliation of this source.
	// +optional
	Suspend bool `json:"suspend,omitempty"`
}

Reference types

// LocalHelmChartSourceReference contains enough information to let you locate
// the typed referenced object at namespace level.
type LocalHelmChartSourceReference struct {
	// APIVersion of the referent.
	// +optional
	APIVersion string `json:"apiVersion,omitempty"`

	// Kind of the referent, valid values are ('HelmRepository', 'GitRepository',
	// 'Bucket').
	// +kubebuilder:validation:Enum=HelmRepository;GitRepository;Bucket
	// +required
	Kind string `json:"kind"`

	// Name of the referent.
	// +required
	Name string `json:"name"`
}

Status

// HelmChartStatus defines the observed state of the HelmChart.
type HelmChartStatus struct {
	// ObservedGeneration is the last observed generation.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`

	// Conditions holds the conditions for the HelmChart.
	// +optional
	Conditions []meta.Condition `json:"conditions,omitempty"`

	// URL is the download link for the last chart pulled.
	// +optional
	URL string `json:"url,omitempty"`

	// Artifact represents the output of the last successful chart sync.
	// +optional
	Artifact *Artifact `json:"artifact,omitempty"`

	// LastHandledReconcileAt is the last manual reconciliation request (by
	// annotating the HelmChart) handled by the reconciler.
	// +optional
	LastHandledReconcileAt string `json:"lastHandledReconcileAt,omitempty"`
}

Condition reasons

const (
	// ChartPullFailedReason represents the fact that the pull of the Helm chart
	// failed.
	ChartPullFailedReason string = "ChartPullFailed"

	// ChartPullSucceededReason represents the fact that the pull of the Helm chart
	// succeeded.
	ChartPullSucceededReason string = "ChartPullSucceeded"

	// ChartPackageFailedReason represent the fact that the package of the Helm
	// chart failed.
	ChartPackageFailedReason string = "ChartPackageFailed"

	// ChartPackageSucceededReason represents the fact that the package of the Helm
	// chart succeeded.
	ChartPackageSucceededReason string = "ChartPackageSucceeded"
)

Spec examples

Pull a specific chart version every five minutes:

apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmChart
metadata:
  name: redis
  namespace: default
spec:
  chart: redis
  version: 10.5.7
  sourceRef:
    name: stable
    kind: HelmRepository
  interval: 5m

Pull the latest chart version that matches the semver range every ten minutes:

apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmChart
metadata:
  name: redis
  namespace: default
spec:
  chart: redis
  version: 10.5.x
  sourceRef:
    name: stable
    kind: HelmRepository
  interval: 10m

Check a Git repository every ten minutes for a new version in the Chart.yaml, and package a new chart if the revision differs:

apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmChart
metadata:
  name: podinfo
  namespace: default
spec:
  chart: ./charts/podinfo
  sourceRef:
    name: podinfo
    kind: GitRepository
  interval: 10m

Check a S3 compatible bucket every ten minutes for a new version in the Chart.yaml, and package a new chart if the revision differs:

apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmChart
metadata:
  name: podinfo
  namespace: default
spec:
  chart: ./podinfo
  sourceRef:
    name: charts
    kind: Bucket
  interval: 10m

Override default values with alternative values files relative to the path in the SourceRef:

apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmChart
metadata:
  name: redis
  namespace: default
spec:
  chart: redis
  version: 10.5.7
  sourceRef:
    name: stable
    kind: HelmRepository
  interval: 5m
  valuesFiles:
    - values.yaml
    - values-production.yaml
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmChart
metadata:
  name: podinfo
  namespace: default
spec:
  chart: ./charts/podinfo
  sourceRef:
    name: podinfo
    kind: GitRepository
  interval: 10m
  valuesFiles:
    - ./charts/podinfo/values.yaml
    - ./charts/podinfo/values-production.yaml

Status examples

Successful chart pull:

status:
  url: http://<host>/helmchart/default/redis/redis-10.5.7.tgz
  conditions:
    - lastTransitionTime: "2020-04-10T09:34:45Z"
      message: Helm chart is available at /data/helmchart/default/redis/redis-10.5.7.tgz
      reason: ChartPullSucceeded
      status: "True"
      type: Ready

Failed chart pull:

status:
  conditions:
    - lastTransitionTime: "2020-04-10T09:34:45Z"
      message: 'invalid chart URL format'
      reason: ChartPullFailed
      status: "False"
      type: Ready

Wait for ready condition:

kubectl wait helmchart/redis --for=condition=ready --timeout=1m
Last modified 0001-01-01