Deployments
Pants has experimental support for managing deployments via the experimental-deploy
goal. Helm deployments provides with a basic implementation of this goal.
Please share feedback for what you need to use Pants with your Helm deployments by either opening a GitHub issue or joining our Slack!
Motivation
Helm's ultimate purpose is to simplify the deployment of Kubernetes resources and help in making these reproducible. However it is quite common to deploy the same software application into different kind of environments using slightly different configuration overrides.
This hinders reproducibility since operators end up having a set of configuration files and additional shell scripts that ensure that the Helm command line used to deploy a piece of software into a given environment is always the same.
Pants solves this problem by providing with the ability to manage the configuration files and the different parameters of a deployment as single unit such that a simple command line as pants experimental-deploy ::
will always have the same effect on each of the deployments previously defined.
Defining Helm deployments
Helm deployments are defined using the helm_deployment
target which has a series of fields that can be used to guarantee the reproducibility of the given deployment. helm_deployment
targets need to be added by hand as there is no deterministic way of introspecting your repository to find sources that are specific to Helm:
- src/chart/BUILD
- src/chart/Chart.yaml
- src/deployment/BUILD
- src/deployment/common-values.yaml
- src/deployment/dev-override.yaml
- src/deployment/stage-override.yaml
- src/deployment/prod-override.yaml
helm_chart()
apiVersion: v2
description: Example Helm chart
name: example
version: 0.1.0
helm_deployment(
name="dev",
chart="//src/chart",
sources=["common-values.yaml", "dev-override.yaml"]
)
helm_deployment(
name="stage",
chart="//src/chart",
sources=["common-values.yaml", "stage-override.yaml"]
)
helm_deployment(
name="prod",
chart="//src/chart",
sources=["common-values.yaml", "prod-override.yaml"]
)
# Default values common to all deployments
env:
SERVICE_NAME: my-service
# Specific values to the DEV environment
env:
ENV_ID: dev
# Specific values to the STAGE environment
env:
ENV_ID: stage
# Specific values to the PRODUCTION environment
env:
ENV_ID: prod
There are quite a few things to notice in the previous example:
- The
helm_deployment
target requires you to explicitly set thechart
field to specify which chart to use. - We have three different deployments using different sets of configuration files with the same chart.
- One of those value files (
common-values.yaml
) provides with default values that are common to all deployments. - Each deployment uses an additional
xxx-override.yaml
file with values that are specific to the given deployment.
The helm_deployment
target has many additional fields including the target kubernetes namespace, adding inline override values (similar to using helm's --set
arg) and many others. Please run pants help helm_deployment
to see all the possibilities.