Skip to main content

ChartPress: render and publish helm charts and images

Project description

chartpress

Automate building and publishing Helm charts and associated images.

This is used as part of the JupyterHub and Binder projects.

Chartpress can:

  • build docker images and tag them appropriately
  • push those images to a docker iamge repository
  • update Chart.yaml and values.yaml to reference the built images
  • publish the chart to a GitHub pages based Helm chart repository
  • reset Chart.yaml and values.yaml

A chartpress.yaml file contains a specification of charts and images to build for each chart.

For example:

charts:
  # list of charts by name
  # each name should be a directory containing a helm chart
  - name: binderhub
    # the prefix to use for built images
    imagePrefix: jupyterhub/k8s-
    # tag to use when resetting the chart values
    # with the --reset flag. It defaults to "set-by-chartpress".
    resetTag: latest
    # version to use when resetting the Chart.yaml's version field with the
    # --reset flag. It defaults to "0.0.1-set.by.chartpress". This is a valid
    # SemVer 2 version, which is required for a helm lint command to succeed.
    resetVersion: 1.2.3
    # the git repo whose gh-pages contains the charts
    repo:
      git: jupyterhub/helm-chart
      published: https://jupyterhub.github.io/helm-chart
    # additional paths (if any) relevant to the chart version
    # outside the chart directory itself
    paths:
      - ../setup.py
      - ../binderhub
    # images to build for this chart (optional)
    images:
      binderhub:
        # Template docker build arguments to be passed using docker's
        # --build-arg flag as --build-arg <key>=<value>. Available dynamic
        # values are TAG and LAST_COMMIT.
        buildArgs:
          MY_STATIC_BUILD_ARG: "hello world"
          MY_DYNAMIC_BUILD_ARG: "{TAG}-{LAST_COMMIT}"
        # Context to send to docker build for use by the Dockerfile
        # (if different from the current directory)
        contextPath: ..
        # Dockerfile path, if different from the default
        # (may be needed if contextPath is set)
        dockerfilePath: images/binderhub/Dockerfile
        # path in values.yaml to be updated with image name and tag
        valuesPath: image
        # additional paths (if any) relevant to the image
        # outside the image directory itself
        paths:
          - ../setup.py
          - ../binderhub

Requirements

The following binaries must be in your PATH:

If you are publishing a chart to GitHub Pages create a gh-pages branch in the destination repository.

Usage

In a directory containing a chartpress.yaml, run:

chartpress

to build your chart(s) and image(s). Add --push to publish images to docker hub and --publish-chart to publish the chart and index to gh-pages.

usage: chartpress [-h] [--push] [--publish-chart]
                  [--extra-message EXTRA_MESSAGE] [--tag TAG | --long]
                  [--image-prefix IMAGE_PREFIX] [--reset] [--skip-build]
                  [--version] [--commit-range COMMIT_RANGE]

Automate building and publishing helm charts and associated images. This is
used as part of the JupyterHub and Binder projects.

optional arguments:
  -h, --help            show this help message and exit
  --push                Push built images to their docker image registry.
  --publish-chart       Package a Helm chart and publish it to a Helm chart
                        repository contructed with a GitHub git repository and
                        GitHub pages.
  --extra-message EXTRA_MESSAGE
                        Extra message to add to the commit message when
                        publishing charts.
  --tag TAG             Explicitly set the image tags and chart version.
  --long                Use this to always get a build suffix for the
                        generated tag and chart version, even when the
                        specific commit has a tag.
  --image-prefix IMAGE_PREFIX
                        Override the configured image prefix with this value.
  --reset               Skip image build step and reset Chart.yaml's version
                        field and values.yaml's image tags. What it resets to
                        can be configured in chartpress.yaml with the resetTag
                        and resetVersion configurations.
  --skip-build          Skip the image build step.
  --version             Print current chartpress version and exit.
  --commit-range COMMIT_RANGE
                        Deprecated: this flag will be ignored. The new logic
                        to determine if an image needs to be rebuilt does not
                        require this. It will find the time in git history
                        where the image was last in need of a rebuild due to
                        changes, and check if that build exists locally or
                        remotely already.

Caveats

TravisCI mirror image registry

If you run chartpress on TravisCI, its logic can be fooled by a mirror image registry to rebuild something that didn't need rebuilding. A workaround for this can be found in this repo's .travis.yml.

Shallow clones

Chartpress detects the latest commit which changed a directory or file when determining the tag to use for charts and images. This means that shallow clones should not be used because if the last commit that changed a relevant file is outside the shallow commit range, the wrong tag will be assigned.

Travis uses a clone depth of 50 by default, which can result in incorrect image tagging. You can disable this shallow clone behavior in your .travis.yml:

git:
  depth: false

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

chartpress-0.4.2-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file chartpress-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: chartpress-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for chartpress-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e0f3fdbbcb4f1e48fd5a8c3e15a2a75f39183255385c09b57834baad9c2fe0d0
MD5 c5b1a35046060c432d8dfde128e1ecd7
BLAKE2b-256 c71f905e78b91a6cec7b286025a4566da401cf168f77dd9d830fe5f7c7dd07a8

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page