HelmStorage#

class phalanx.storage.helm.HelmStorage(config_storage)#

Bases: object

Interface to Helm operations.

Provides an interface to use Helm to create and process templates and to use Helm to install charts in a Kubernetes cluster.

Parameters:

config_storage (ConfigStorage) – Storage object for the Phalanx configuration.

Methods Summary

create(application, starter)

Use helm create to create a new application chart.

dependency_update(application, *[, quiet])

Download chart dependencies for an application.

lint_application(application, environment, ...)

Lint an application chart with Helm.

lint_environment(environment)

Lint the top-level chart for an environment with Helm.

repo_add(url, *[, quiet])

Add a Helm chart repository to Helm's cache.

repo_update(*[, quiet])

Update Helm's cache of upstream repository indices.

template_application(application, ...)

Expand an application chart into its Kubernetes resources.

template_environment(environment)

Expand the top-level chart into its Kubernetes resources.

Methods Documentation

create(application, starter)#

Use helm create to create a new application chart.

Parameters:
  • application (str) – Name of the new application.

  • starter (HelmStarter) – Name of the Helm starter template to use.

Return type:

None

dependency_update(application, *, quiet=False)#

Download chart dependencies for an application.

Tell Helm to update any third-party chart dependencies for an application and store them in the charts subdirectory. This is a prerequisite for helm lint or helm template.

Assumes that remote repositories have already been refreshed with repo_update and tells Helm to skip that.

Parameters:
  • application (str) – Application whose dependencies should be updated.

  • quiet (bool, default: False) – Whether to suppress Helm’s standard output.

Return type:

None

lint_application(application, environment, values)#

Lint an application chart with Helm.

Assumes that helm dependency update has already been run to download any third-party charts. Any output is sent to standard output and standard error, and if Helm fails, a failure message will be printed to standard error.

Parameters:
  • application (str) – Name of the application.

  • environment (str) – Name of the environment in which to lint that application chart, used to select the values-environment.yaml file to add.

  • values (dict[str, str]) – Extra key/value pairs to set, reflecting the settings injected by Argo CD.

Returns:

Whether linting passed.

Return type:

bool

lint_environment(environment)#

Lint the top-level chart for an environment with Helm.

Any output is sent to standard output and standard error, and if Helm fails, a failure message will be printed to standard error.

Parameters:

environment (str) – Name of the environment.

Returns:

Whether linting passed.

Return type:

bool

repo_add(url, *, quiet=False)#

Add a Helm chart repository to Helm’s cache.

Used primarily to enable Helm linting and templating, since both require any third-party chart repositories be added first.

Annoyingly, Helm requires you to name repositories, but chart configurations don’t include repository names. Automating adding Helm repositories therefore requires making up a name. This uses some arbitrary heuristics that produce consistent names and hopefully won’t produce conflicts.

Parameters:
  • url (str) – Chart repository to add.

  • quiet (bool, default: False) – Whether to suppress Helm’s standard output.

Raises:

ValueError – Raised if the Helm repository URL is invalid.

Return type:

None

repo_update(*, quiet=False)#

Update Helm’s cache of upstream repository indices.

Parameters:

quiet (bool, default: False) – Whether to suppress Helm’s standard output.

Return type:

None

template_application(application, environment, values)#

Expand an application chart into its Kubernetes resources.

Runs helm template to expand a chart into its Kubernetes resources for a given environment. Assumes that helm dependency update has already been run to download any third-party charts. Any output to standard error is passed along.

Parameters:
  • application (str) – Name of the application.

  • environment (str) – Name of the environment in which to lint that application chart, used to select the values-environment.yaml file to add.

  • values (dict[str, str]) – Extra key/value pairs to set, reflecting the settings injected by Argo CD.

Returns:

Kubernetes resources created by the chart.

Return type:

str

Raises:

CommandFailedError – Raised if Helm fails.

template_environment(environment)#

Expand the top-level chart into its Kubernetes resources.

Runs helm template to expand the top-level chart into its Kubernetes resources for a given environment. Any output to standard error is passed along.

Parameters:

environment (str) – Name of the environment for which to expand the chart.

Returns:

Kubernetes resources created by the chart.

Return type:

str

Raises:

CommandFailedError – Raised if Helm fails.