Helm plugin

8 minute readExtensibilityDeveloper productivity

This plugin integrates CloudBees CD/RO with Helm, the Helm package manager for Kubernetes.

There are three primary concepts:

  • A chart is a Helm package. It contains all resource definitions necessary to run an application, tool, or service inside a Kubernetes cluster. Think of it like the Kubernetes equivalent of a Homebrew formula, an Apt dpkg, or a Yum RPM file.

  • A repository is the place where charts can be collected and shared. It is like the Perl CPAN archive or the Fedora Package Database, but for Kubernetes packages.

  • A release is an instance of a chart running in a Kubernetes cluster. One chart can often be installed many times into the same cluster; each time it is installed, a new release is created. This is similar to a MySQL chart; if you want two databases running in your cluster, you can install the chart twice. Each one has its own release, which in turn has its own release name.

With these concepts in mind, Helm installs charts into Kubernetes, creating a new release for each installation. To find new charts, you can search Helm chart repositories.

Plugin version 1.6.0

Revised on November 29, 2022

Supported versions

The plugin has been tested with the following versions:

  • v3.10.0

  • v3.8.1

  • v3.5.0

  • v3.4.0

Plugin configurations

Plugin configurations are sets of parameters that can be applied across some, or all, of the plugin procedures. They can reduce the repetition of common values, create predefined parameter sets, and securely store credentials. Each configuration is given a unique name that is entered in the designated parameter for the plugin procedures that use them.

Creating plugin configurations

To create plugin configurations in CloudBees CD/RO, complete the following steps:

  1. Navigate to DevOps Essentials  Plugin Management  Plugin configurations.

  2. Select Add plugin configuration to create a new configuration.

  3. In the New Configuration window, specify a Name for the configuration.

  4. Select the Project that the configuration belongs to.

  5. Optionally, add a Description for the configuration.

  6. Select the appropriate Plugin for the configuration.

  7. Configure the parameters per the descriptions below.

Configuration procedure parameters

Parameter Description

Configuration name

Required. The name for the created configuration.

Description

The description for the configuration.

Helm executable path

Required. An absolute or relative path to the Helm executable.

Kubectl executable path

The absolute path to the kubectl executable. Kubectl is only used as a fallback option to retrieve pod information in the microservice deployment when the Helm-generated manifest cannot be parsed with the current Perl YAML libraries. If the value is empty, the executable is looked up in the PATH environment variable.

Helm version

Required. The version of the Helm client. The actual version is checked via Check Connection .

Options

The options to pass to the Helm executable. For example, --option-name[=parameter] .

Config file

The configuration file that should be used.

  • Default: The default configuration file, /home/user/.kube/config .

  • Use existing: Use an existing file via a specified path.

  • Create new: Create a new temporary file with specific content.

Config file location

The path to a kubectl configuration file. Examples:

  • /home/user/.kube/config

  • $[/myEnvironment/clusters/kub-cluster/kubeconfigpath]

Config file content

The content of the kubectl configuration file to use to connect to the cluster.

Kubeconfig Context

Context used by Kubectl to run against the cluster.

Check connection resource

The resource that is used to check the connection.

Check Connection?

If checked, the connection endpoint and credentials entered as part of the configuration will be tested. If this option is checked, configuration will not be saved if the test fails.

Debug level

This option sets the debug level for logs. If Info is selected, only a summary is displayed. If Debug is selected, debug information is displayed. If Trace is selected, all requests and responses are displayed.

Plugin procedures

Install Chart

Installs a chart archive.

Install Chart parameters

Parameter Description

Configuration name

Required. The unique name for the configuration.

Release name

Required. The name of the release to deploy.

Chart

Required. Specifies the chart to install. The following methods can be used:

  • Chart reference: stable/mariadb

  • Path to a packaged chart: ./nginx-1.2.3.tgz

  • Path to an unpacked chart directory: ./nginx

  • Absolute URL: https://example.com/charts/nginx-1.2.3.tgz

  • Chart reference and repo url: --repo https://example.com/charts/ nginx

Options

The options to pass to the Helm executable. For example, --option-name[=parameter].

Values

Specify the content for a YAML file that will be passed to the command.

Result property sheet

Required. Results are saved into this property/property sheet.

Output parameters

Parameter Description

installChart

STDOUT after successfully completing the command.

Upgrade Release

Upgrades a release to a specified version of a chart and/or updates chart values.

Upgrade Release parameters

Parameter Description

Configuration name

The unique name for the configuration.

Release name

Required. The release name.

Chart

Required. Specifies the chart to install. The following methods can be used:

  • Chart reference: stable/mariadb

  • Path to a packaged chart: ./nginx-1.2.3.tgz

  • Path to an unpacked chart directory: ./nginx

  • Absolute URL: https://example.com/charts/nginx-1.2.3.tgz

  • Chart reference and repo url: --repo https://example.com/charts/ nginx

Options

The options to pass to the Helm executable. For example, --option-name[=parameter].

Values

Specify the content for a YAML file that will be passed to the command.

Result property sheet

Required. Results are saved into this property/property sheet.

Output parameters

Parameter Description

upgradeRelease

STDOUT after successfully completing the command.

Delete Release

Deletes a release from Kubernetes. It removes all of the resources associated with the last release of the chart.

Delete Release parameters

Parameter Description

Configuration name

Required. The unique name for the configuration.

Release name

Required. The release name.

Options

The options to pass to the Helm executable. For example, --option-name[=parameter].

Action on error

Required. Ignores errors if they are expected. For example, if a repository is already present or an item to be deleted does not exist.

Error value

A pattern that triggers the Action on error condition.

Result property sheet

Required. Results are saved into this property/property sheet.

Output parameters

Parameter Description

deleteRelease

STDOUT after successfully completing the command.

Rollback Release

Rolls back a release to a previous revision.

Rollback Release parameters

Parameter Description

Configuration name

Required. The unique name for the configuration.

Release name

Required. The release name.

Revision number

Required. A revision (version) number of the release.

Options

The options to pass to the Helm executable. For example, --option-name[=parameter].

Result property sheet

Required. Results are saved into this property/property sheet.

Output parameters

Parameter Description

rollbackRelease

STDOUT after successfully completing the command.

Run Custom Command

Run any Helm command.

Run Custom Command parameters

Parameter Description

Configuration name

Required. The unique name for the configuration.

Command

Required. The name of the command.

Arguments

Arguments to pass to the Helm executable for the command.

Options

The options to pass to the Helm executable. For example, --option-name[=parameter].

Values

Specify the content for a YAML file that will be passed to the command.

Action on error

Required. Allows ignoring errors when they are expected. For example, the repository is already present or an item to delete does not exist.

Error value

A pattern that triggers the Action on error condition.

Result property sheet

Required. Results are saved into this property/property sheet.

Output parameters

Parameter Description

runCustomCommand

STDOUT after successfully completing the command.

Microservice deployment

Plugin allows deploying Helm charts into Kubernetes clusters. Clusters should be part of an Environment and have 'Helm - Kubernetes' in the cluster definition.

Microservice deployment uses 'upgrade --install' command to support both fresh and upgrade deployments. Deployment parameter 'Additional Options' can be used to provide list of flags and options for the deployment command. Content of the 'Values' parameter will be saved to a file and passed to the command with the '-f <fileName>' option.

Parameters will be prepended to the command in following order, which means options that are prepended later can override values set in previous options.

  • File supplied by the deployment 'Values' parameter

  • Configuration 'Options'

  • Deployment 'Additional Options'

  • Cluster definition 'Namespace' parameter

  • Cluster definition 'Kubeconfig Context' parameter

Optionally, rollback can be enabled with a specified timeout. When rollback is enabled, the --atomic parameter is added to the 'upgrade --install' command.

After invoking 'upgrade --install' command, the plugin procedure invokes set of commands to retrieve the deployment details:

  • Release details: 'list -l <releaseName>'

  • Notes: 'get notes <releaseName>'

  • Values: 'get values <releaseName>'

  • Manifests: 'get manifest <releaseName>'

Release manifests are parsed in order to get list of containers that were deployed with this release. These containers are reported to the Environment Inventory.

Because different yaml libraries have different implementation of the YAML specification, some manifests accepted by Kubernetes may not be parsed by Perl libraries used in the plugin. If you have warnings about specific yaml file that has containers, and the chart is under your governance, you can provide proper formatting and linting for the chart template to fix parse error. For charts provided by a third party provider, please file an issue for the maintainer.

In case when plugin fails to parse manifest for one of the generated yaml files, and it contains container spec, this container will not be reported to the inventory.

Use cases

GCP: Deploy Core using Helm v2

The demo is based on the official documentation:

Pipeline

Stage: Preparation GCP

Step: cleanup configurations
020 cleanup configurations
Step: create configuration
030 create configuration
Step: activate service account
040 activate service account
Step: config set compute
050 config set compute
Step: get cluster credentials
060 get cluster credentials
Step: Create namespace
070 create namespace
Step: cluster admin permissions
080 cluster admin permissions

Stage: preparation Helm

Step: Init Helm
090 init helm
Step: install Helm plugin
100 install helm plugin
Step: start Helm tiller
110 start helm tiller
Step: Add CloudBees Helm chart repository
120 add cloudbees helm chart repository
Step: update repositories
130 update repositories
Step: cleanup old release
140 cleanup old release
Step: cleanup old ingress controller
150 cleanup old ingress controller

Stage: Installation

Step: prepare values for Ingress Controller
160 prepare values for ingress controller
Step: install Ingress controller
170 install ingress controller
Step: get host for Ingress controller
180 get host for ingress controller
Step: install chart
190 install chart
Step: get release status
200 get release status
STDOUT:
LAST DEPLOYED: Tue Jan 21 12:47:29 2020
NAMESPACE: cloudbees-core
STATUS: DEPLOYED

RESOURCES:
==> v1/ClusterRole
NAME                                   AGE
cjoc-master-management-cloudbees-core  59s

==> v1/ClusterRoleBinding
NAME                              AGE
cjoc-role-binding-cloudbees-core  59s

==> v1/ConfigMap
NAME                           AGE
cjoc-configure-jenkins-groovy  60s
jenkins-agent                  60s

==> v1/Pod(related)
NAME    AGE
cjoc-0  56s

==> v1/Role
NAME                    AGE
cjoc-agents             58s
cjoc-master-management  58s

==> v1/RoleBinding
NAME                      AGE
cjoc-master-role-binding  57s
cjoc-role-binding         57s

==> v1/Service
NAME  AGE
cjoc  57s

==> v1/ServiceAccount
NAME     AGE
cjoc     60s
jenkins  60s

==> v1/StatefulSet
NAME  AGE
cjoc  56s

==> v1beta1/Ingress
NAME  AGE
cjoc  55s

NOTES:

  • Once Operations Center is up and running, get your initial admin user password by running:

    kubectl rollout status sts cjoc
    kubectl exec cjoc-0 -- sh -c "until cat /var/jenkins_home/secrets/initialAdminPassword 2>&-; do sleep 5; done"
  • Visit http://35.196.144.25.xip.io/cjoc

  • Login with the admin user password.

For more information on running CloudBees CI on Kubernetes, see the CloudBees CI on modern cloud platforms administration guide. Configure the Kubernetes plugin in Jenkins to use the following Service Account name cjoc using the following steps: . Create a Jenkins credential of type Kubernetes service account with service account name cjoc. . Under configure Jenkins — Update the credentials config in the cloud section to use the service account credential you created in the step above.

Step: get initial admin password

=

210 get initial admin password

Stage: Finalization

Step: stop Helm Tiller
220 stop helm tiller

OpenShift: Deploy Jenkins using Helm v3

Demonstrating how Microservices can be deployed to OpenShift cluster. In this example we will deploy Jenkins on OpenShift cluster.

Preparations

Kubectl config for Helm

If you do not have kubectl config for OpenShift cluster then you can easy generate it just using "oc" CLI. Example:

oc login https://your-openshift-cluster-endpoint-url
oc new-project helm-test-openshift
cat ~/.kube/config

Create and define environment

01 create env

Define a cluster in the created environment:

01 created env
01 setup env cluster

Add and define Utility Resource in the environment:

01 add utility resource
01 created utility resource
01 choose resource

Created and defined environment:

01 created and defined env

Create application

02 create app microservice

Create and define a microservice in the created application:

02 created app microservice
02 create microservice

Define microservice

03 define microservice part1
03 define microservice part2

Choose cluster

04 choose cluster
04 choose cluster 02

Ready for deploy

05 ready for deploy

Deploy

06 deploy success

Check inventory

You can check deploy status via oc CLI

$ oc status
In project default on server https://xx.xx.xxx.xxx

svc/myrelease-jenkins-agent - 10.7.253.124:50000
svc/myrelease-jenkins - 10.7.248.179:8080
  statefulset/myrelease-jenkins manages jenkins/jenkins:2.277.3-jdk11,kiwigrid/k8s-sidecar:0.1.275
    created 9 minutes ago - 1 pod

$ oc get pods
NAME                  READY     STATUS    RESTARTS   AGE
myrelease-jenkins-0   2/2       Running   0          13m

Known issues

For the microservice deployment you should use Helm version 3.4.0 or newer. Otherwise plugin will fail to get the release details.

Third-party dependencies

Module License

org.yaml:snakeyaml:1.33

Apache License, Version 2.0

Release notes

EC-Helm 1.6.0

  • Added handling for "Use Existing" config file case

  • Added the Kubeconfig Context parameter to plugin configuration.

  • Deprecated the Kubeconfig context parameter in Cluster Reference form in Microservices.

  • Fixed security issue.

  • Fixed hard-coded actionOnError parameter.

EC-Helm 1.5.1

  • Fixed application deployment on agents in version 10.5.

  • Fixed removing duplicate parameters in the microservice definition form.

EC-Helm 1.5.0

  • Enabled support of new configurations.

EC-Helm 1.4.1

  • Added the Compatibility property for the source provider.

EC-Helm 1.3.0

  • Added optional auto-rollback support for Microservices.

  • Cosmetic UI changes were made to the Create Configuration procedure.

  • Improvements were made to retain the environment inventory in its actual state.

  • Added a Chart Version parameter to the microservice definition form.

  • Added the OpenShift: Deploying Jenkins using Helm v3 use case to the documentation.

EC-Helm 1.2.0

  • Helm version v2 has been deprecated.

  • Added Microservices support.

  • Added the Values parameter to hold YAML content that is passed to the CLI as the values file for the following procedures:

    • Install Chart

    • Upgrade Release

    • Run Custom Command

EC-Helm 1.1.4

  • Fixed parsing of RC versions of Helm.

EC-Helm 1.1.3

  • Added the option to use custom config files.

EC-Helm 1.1.2

  • The documentation has been migrated to the main documentation site.

EC-Helm 1.1.1

  • Added an option for handling spaces in the path.

EC-Helm 1.1.0

  • Added the option to create a kubeconfig.

EC-Helm 1.0.0

  • The initial version of the plugin. The following procedures are supported:

    • Install Chart

    • Upgrade Release

    • Delete Release

    • Rollback Release

    • Run Custom Command