Spacelift
PrivacyT&Cs
  • 👋Hello, Spacelift!
  • 🚀Getting Started
  • 🌠Main concepts
    • Stack
      • Creating a stack
      • Stack settings
      • Organizing stacks
      • Stack locking
      • Drift detection
    • Configuration
      • Environment
      • Context
      • Runtime configuration
        • YAML reference
    • Run
      • Task
      • Proposed run (preview)
      • Tracked run (deployment)
      • Module test case
      • User-Provided Metadata
      • Run Promotion
      • Pull Request Comments
    • Policy
      • Login policy
      • Access policy
      • Approval policy
      • Initialization policy
      • Plan policy
      • Push policy
      • Task policy
      • Trigger policy
    • Resources
    • Worker pools
    • VCS Agent Pools
  • 🛰️Platforms
    • Terraform
      • Module registry
      • External modules
      • Provider
      • State management
      • Terragrunt
      • Version management
      • Handling .tfvars
      • CLI Configuration
      • Cost Estimation
      • Resource Sanitization
      • Storing Complex Variables
      • Debugging Guide
    • Pulumi
      • Getting started
        • C#
        • Go
        • JavaScript
        • Python
      • State management
      • Version management
    • CloudFormation
      • Getting Started
      • Reference
      • Integrating with SAM
      • Integrating with the serverless framework
    • Kubernetes
      • Getting Started
      • Authenticating
      • Custom Resources
      • Helm
      • Kustomize
  • ⚙️Integrations
    • Audit trail
    • Cloud Integrations
      • Amazon Web Services (AWS)
      • Microsoft Azure
      • Google Cloud Platform (GCP)
    • Source Control
      • GitHub
      • GitLab
      • Azure DevOps
      • Bitbucket Cloud
      • Bitbucket Datacenter/Server
    • Docker
    • GraphQL API
    • Single sign-on
      • GitLab OIDC Setup Guide
      • Okta OIDC Setup Guide
      • OneLogin OIDC Setup Guide
      • Azure AD OIDC Setup Guide
      • AWS IAM Identity SAML 2.0 Setup Guide
    • Slack
    • Webhooks
  • 📖Product
    • Privacy
    • Security
    • Support
      • Statement of Support
    • Disaster Continuity
    • Billing
      • Stripe
      • AWS Marketplace
    • Terms and conditions
    • Refund Policy
  • Cookie Policy
Powered by GitBook
On this page
  • Prerequisites
  • Repository Creation
  • Create a new Stack
  • Define Behavior
  • Configure Environment
  • Configure Integrations
  • Trigger a Run

Was this helpful?

  1. Platforms
  2. Kubernetes

Helm

PreviousCustom ResourcesNextKustomize

Last updated 3 years ago

Was this helpful?

There is no native support within Spacelift for Helm, but you can use the command in a before plan hook to generate the Kubernetes resource definitions to deploy.

Please note, the following caveats apply:

  • Using helm template means that you are not using the full Helm workflow, which may cause limitations or prevent certain Charts from working.

  • You need to use a custom that has Helm installed, or alternatively you can install Helm using a before init hook.

The rest of this page will go through an example of deploying the using the Kubernetes integration. See for an example repository.

Prerequisites

The following prerequisites are required to follow the rest of this guide:

  • A Kubernetes cluster that you can authenticate to from a Spacelift stack.

  • A namespace called spacelift-worker that exists within that cluster.

Repository Creation

Start by creating a new repository for your Helm stack. This repository only needs to contain a single item - a kustomization.yaml file:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: spacelift-worker

resources:
  # spacelift-worker-pool.yaml will be generated in a pre-plan hook
  - spacelift-worker-pool.yaml

The kustomization file is used to tell kubectl where to find the file containing the output of the helm template command, and prevents kubectl from attempting to apply every yaml file in your repository. This is important if you want to commit a values.yaml file to your repository.

Our example repository contains a values.yaml file used to configure some of the chart values. This isn't required, and is simply there for illustrative purposes.

Create a new Stack

Define Behavior

helm repo add spacelift https://downloads.spacelift.io/helm
helm template spacelift-worker-pool spacelift/spacelift-worker --values values.yaml --set "replicaCount=$SPACELIFT_WORKER_REPLICAS" --set "credentials.token=$SPACELIFT_WORKER_POOL_TOKEN" --set "credentials.privateKey=$SPACELIFT_WORKER_POOL_PRIVATE_KEY" > spacelift-worker-pool.yaml

Also, make sure to specify your custom Runner image that has Helm installed if you are not installing Helm using a before init hook.

Once you've completed both steps, you should see something like this:

Configure Environment

Once you have successfully created your Stack, add values for the following environment variables to your Stack environment:

  • SPACELIFT_WORKER_REPLICAS - the number of worker pool replicas to create.

  • SPACELIFT_WORKER_POOL_TOKEN - the token downloaded when creating your worker pool.

  • SPACELIFT_WORKER_POOL_PRIVATE_KEY - your base64-encoded private key.

Your Stack environment should look something like this:

Configure Integrations

Trigger a Run

This example assumes that a Kubernetes namespace called spacelift-worker already exists. If it doesn't, create it using kubectl create namespace spacelift-worker before triggering a run.

Triggering runs works exactly the same as when not using Helm. Once the planning stage has completed, you should see a preview of your changes, showing the Chart resources that will be created:

After approving the run, you should see the changes applying, along with a successful rollout of your Chart resources:

Follow the same steps to create your stack as per the guide, but when you get to the Define Behavior step, add the following commands as before plan hooks:

Configure any required Cloud Provider integrations as per the guide.

You can use a to run the kubectl create namespace command.

🛰️
helm template
Spacelift worker image
Spacelift Workerpool Helm Chart
here
Getting Started
Getting Started
Spacelift Task