Helm-Charts

Helm-Creation-Engine

In order to provision our manifests in a reliable way we want to use helm-charts to package all neccessary manifests (e.g. Serviceaccounts, Roles and their bindings, CustomResourceDefinitions, Deployment, Daemonset).

You can run the Helm-Creation-Engine by using:

python -m yaook.helm_builder -vvv

Default mode just creates the helm-chart tarball for verification. If GITLAB_USERNAME, CI_JOB_TOKEN and CI_PROJECT_ID is set, the Engine will also try to upload the tarball to the (helm) package registry.

Note

Helm Package Registry on Gitlab is currently in Beta Status and subject to change. See https://docs.gitlab.com/ee/user/packages/index.html

The Helm-Creation-Engine creates Chart.yaml (from .j2 template), values.yaml (from .j2 template). After creation of the files Chart.yaml, values.yaml and the content of /templates are packaged into a proper tarball and (optional) uploaded to the gitlab (helm) package registry.

Prerequisites

Note

If the prerequisites of the helm-charts are not fullfilled properly the unittests will fail

  • Folder in /yaook/helm_builder/Charts/ - the name of the folder is also the chartname

  • Subfolder of the previous generated Folder named /templates. All manifests are placed in /templates and can be regular helm-templates (using helm-variable syntax)

  • A template for Chart.yaml named chart-template.yaml.j2. This one just describes metadata for the chart and can be completely static besides the version. {{ version }} will be replaced by rendering the template and is replaced by the current operator version tag.

    Example from etcd-backup (chart-template.yaml.j2)

    apiVersion: v2
    description: Creates etcd backup from kubernetes master and stores it remotely via s3
    type: application
    name: etcdbackup
    version:  {{ version }}
    appVersion: {{ version }}
    kubeVersion: ">=1.16.0-0"
    
  • A template for values.yaml named template-values.yaml.j2 This one describes default values and can contain also image versions to be used as default helm-values. All versions from /assets/pinned_versions are available as a nested dict to be rendered.

    If template-values.yaml.j2 contains the line:

    backup_creator:
      imageRef: {{ images["registry.gitlab.com/yaook/images/backup-creator/backup-creator"] }}
    

    The Helm-Creation-Engine will create a values.yaml file with the content:

    backup_creator:
      imageRef: "registry.gitlab.com/yaook/images/backup-creator/backup-creator:1.0.13"
    

    This helm-variable can then be used within a template (e.g deployment) to provide proper default values.

    kind: Deployment
    metadata:
      name: etcd-backup
    spec:
      template:
        spec:
          containers:
          - name: backup-creator
            image: {{.Values.backup_creator.imageRef}}
    

Example Filestructure

  • /yaook/helm_builder/Charts/etcd-backup/templates/deployment.yaml

  • /yaook/helm_builder/Charts/etcd-backup/templates/configmap.yaml

  • /yaook/helm_builder/Charts/etcd-backup/chart-template.yaml.j2

  • /yaook/helm_builder/Charts/etcd-backup/values-template.yaml.j2