Helm for Container Deployments

Using Helm to execute deployments as an Action.

Helm is called to replace the DeployHub default processing engine for performing container deployments. When DeployHub executes the release process, it will call the Helm Chart you have defined as your Custom Action at the Component level. DeployHub includes the version of the Helm chart as part of its overall configuration data.

Helm and Key Value Pairs

In order to support a consistent Helm deployment across Cluster Endpoints and Environments (Dev, Test, Prod) Key value pair substitution is performed. When a Helm chart is used, DeployHub will pull your Helm Chart in the .tgz format from either a public or private Chart Museum. It then expands it out into a separate directory location where Helm is executed. This location is defined by the DeployHub Endpoint which you define (see “Connecting a DeployHub Endpoint to your Kubernetes Cluster through Helm” below).

DeployHub will then create an override values file which contains all the specific key value pairs defined at the Endpoint, Environment, Component or Application in this order of precedence. For example, if the same key value pairs are defined at the Endpoints as well as the Application, the Endpoint key values are used.

The override values file passes the Key value definitions Helm ‘upgrade’ command. This process allows a single Helm chart to be reused across all deployments, supporting the needed key value pairs for each deployment.

If you would like to create a hermetic Helm Chart stored in the DeployHub database, use the following key value:

helmcapture=Y

This must be defined at any level, i.e., Endpoint, Environment, Component or Application.

Connecting a DeployHub Endpoint to your Kubernetes Cluster through Helm

DeployHub' deployment engine comes pre-installed with Helm. For this reason you should use the deployment engine as the “localhost” Endpoint for your deployments. This Helm install on the “localhost” Endpoint needs to know how to connect to your Kubernetes Cluster.

Mount your “.kube/config” file to the DeployHub deployment engine Docker container to provide the connection. The additional parameter to the docker run command for the DeployHub container exposes the Kubernetes config file to the Helm install in DeployHub. The following is an example of the additional parameter:

-v ~/.kube:/home/omreleng/.kube:Z

For more information on starting the DeployHub Container see:

Helm and Custom Actions

Helm is called as a DeployHub Custom Action. To use Helm, you will need to import two Helm files as DeployHub Procedures and define them to your Custom Action. This Helm Custom Action can then be assigned to your Container Components. See Procedures and Functions and Customize Actions to learn more. The following steps will create your Helm Custom Action.

Step 1 - Download and Import the Helm scripts as Procedures

Download the the most current DeployHub Helm Procedures from the DeployHub Git Repo. There will be two:

  • WriteEnv2Toml.re: This Procedure takes all the attributes from DeployHub Environments, Applications, Endpoints and Components and writes them to a file readable by the Helm Procedure.

  • HelmUpgrade.re – This Procedure performs a Helm upgrade/install of the Helm Chart.

Step 2 - Create your Procedures

Once downloaded, you will need to Import the scripts into DeployHub as Procedures. To import these Procedures navigate to the Func/Procs Menu option on the left hand side of the DeployHub Main Menu panel. This will take you to the Functions and Procedures List View. From the Functions and Procedures List View select the Import option. The Import will bring you to your operating system “file open” dialog box for selecting the WriteEnv2Toml.re and HelmUpgrade.re files.

Next, select your “Global,” or highest level, Domain and upload the Procedure into DeployHub. If you select a lower level Subdomain you will restrict access. By defining it to your highest level Domain, all Users will be able to see the Procedures. Once you have both imported, you are now ready to create your Action.

Step 3 - Create your Action for Your Helm Procedures

Once you have imported your WriteEnv2Toml.re and HelmUpgrade.re files as Procedures, you can define your Action. Navigate to the Actions list view from the Actions menu option on the left hand side of the DeployHub Main Menu panel.

Use the +Add option to create a new Action for you Procedure. In the “Full Domain” field select your “Global” Domain. If you select a lower level Subdomain you will restrict access to this Custom Action. By defining it to your highest level Domain, all Users will be able to execute the process regardless of their SubDomain.

Name the new Action HelmChart (no spaces).

Now we are going to customize this Action. On the right hand side, you will see a list of Functions and Procedures you can choose from. Navigate to your Domain to find the WriteEnv2Toml.re and HelmUpgrade.re imported Procedures. Drag them onto the area under “Start”. The order should be WriteEnv2Toml, HelmUpgrade.

No Parameter fields are required for WriteEnv2File.

When you drag the HelmUpgrade Procedure onto the area under “Start” a pop-up dialog box will open for you to complete the following parameters:

Field Value Description
Title Not Required Name of the step in your deployment workflow.
Summary Not Required Enter a summary of this step.
RspFile $RspFile The results from the WriteEnv2Toml.re Procedure
Chart $(Chart) The Helm Chart to be used during the deployment
Release Name $(component.name) The name of the release

At this point the Action is ready to be used by anyone with access (based on Domain and security options). Each Component that uses the Action will need to define specific values. Because this new Action is reusable, no Component variables are defined at the Action level.

Assign the Helm Chart Action to a Component

Create your new Component from the Component Dashboard. See Defining Components. For each container Component you will need to define the variable values. Values are specified when you create a new container Component. Values will override those defined at the Application or Environment level. The values from DeployHub will be passed along to Helm’s values.yml file at execution time. For more information on defining your container Component see Container Specific Data Definition.

Storing and Retrieving a Hermetic Helm Chart

In order to create an ‘airtight’ Helm deployment, DeployHub takes the generated Helm overrides file created during a Helm deployment and executes the Helm template command to find the container images that were referenced. All container image digests are captured and stored in the DeployHub database along with the Helm Chart and all key values used in a specific deployment. To turn on this option, the following key value pair must be defined at any level, i.e., Endpoint, Environment, Component or Application.

helmcapture=Y

Once stored in the DeployHub database, you can retrieve the hermetic Helm Chart, key value pairs and all container digests to repeat the exact deployment utilizing Helm manually.

Retrieving and Running the Helm Chart Manually

To re-execute a Helm deployment manually, you will retrieve all captured data in a zip file (Helm Chart, all container digest, and key values ). To retrieve the data and generate a zip file, execute the following curl command if using the SaaS:

curl "https://console.deployhub.com/dmadminweb/API/helm/<DeploymentNumber>?format=zip"-o Helmchart.zip

where:
Deployment Number is the Number of the Deployment displayed in the DeployHub dashboard for the Application.

Helmchart.zip is the name of the zip file you want to create.

If you are using an on premise version use the following command:


curl "http://<myDeployHub>/dmadminweb/API/helm/<DeploymentNumber>?format=zip"-o Helmchart.zip

where:
myDeployHub is your on premise DeployHub Server.

Deployment Number is the Number of the Deployment displayed in the DeployHub dashboard for the Application.

Helmchart.zip is the name of the zip file you want to create.
Last modified October 28, 2020: Updated for hermetic helm chart (6a8a48d)