Configure Helm Chart Deployments
To deploy Helm charts, you need to configure them within the deployments
section of the devspace.yaml
.
deployments:
- name: database
helm:
chart:
name: stable/mysql
values:
mysqlRootPassword: ${MYSQL_ROOT_PASSWORD}
mysqlUser: db_user
mysqlDatabase: app_database
- name: backend
helm:
chart:
name: backend-chart
repository: https://my-repo.tld/
Chart
deployments[*].helm.componentChart
The componentChart
option expects a boolean which states if the Component Helm Chart should be used for deployment. Learn more about configuring component deployments.
If
componentChart: true
is configured, all options underchart
will be ignored.
componentChart
Default Value for componentChart: false
deployments[*].helm.chart.name
The name
option expects a string stating either:
- a path to a chart that is stored on the filesystem
- the name of a chart that is located in a repository (either the default repository or one specified via
repo
option)
DevSpace follows the same behavior as helm install
and first checks if the path specified in name
exists on the file system and is a valid chart. If not, DevSpace will assume that the name
is not a path but the name of a remote chart located in a chart repository.
Specifying the
name
option for Helm deployments is mandatory.
Example: Simple Helm Deployment
deployments:
- name: database
helm:
chart:
name: stable/mysql
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database stable/mysql
deployments[*].helm.chart.version
The version
option expects a string stating the version of the chart that should be used.
If no version is specified, Helm would try to get the latest version of this chart.
version
Default Value for version: ""
Example: Custom Chart Version
deployments:
- name: database
helm:
chart:
name: stable/mysql
version: "1.3.1"
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database stable/mysql --version="1.3.1"
deployments[*].helm.chart.repo
The repo
option expects a string with an URL to a Helm Chart Repository.
The official Helm Chart Repository
stable
does not need to be specified as serves as default value.
repo
Default Value for repo: stable
Example: Custom Chart Repository
deployments:
- name: database
helm:
chart:
name: custom-chart
repository: https://my-repo.tld/
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database custom-chart --repo "https://my-repo.tld/"
Values Overriding
deployments[*].helm.values
The values
option expects an object with values that should be overriding the default values of this Helm chart.
Compared to the valuesFiles
option, using values
has the following advantages:
- It is easier to comprehend and faster to find (no references)
- It allows you to use dynamic config variables
Because both,
values
andvaluesFiles
, have advantages and disadvantages, it if often useful to combine them. When setting both, values defined invalues
have precedence over values defined invaluesFiles
.
values
Default Value for values: {}
Example: Using Values in devspace.yaml
deployments:
- name: database
helm:
chart:
name: stable/mysql
values:
mysqlRootPassword: ${MYSQL_ROOT_PASSWORD}
mysqlUser: db_user
mysqlDatabase: app_database
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database stable/mysql --set mysqlRootPassword="$MYSQL_ROOT_PASSWORD" --set mysqlUser="db_user" --set mysqlDatabase="app_database"
deployments[*].helm.valuesFiles
The valuesFiles
option expects an array of paths to yaml files which specify values for overriding the values.yaml of the Helm chart.
Compared to the values
option, using valuesFiles
has the following advantages:
- It reduces the size of your
devspace.yaml
especially when setting many values for a chart - It allows you to run Helm commands directly without DevSpace, e.g.
helm upgrade [NAME] -f mysql/values.yaml
Because both,
values
andvaluesFiles
, have advantages and disadvantages, it if often useful to combine them. When setting both, values defined invalues
have precedence over values defined invaluesFiles
.
valuesFiles
Default Value for valuesFiles: []
Example: Using Values Files
deployments:
- name: database
helm:
chart:
name: stable/mysql
valuesFiles:
- mysql/values.yaml
- mysql/values.production.yaml
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database stable/mysql -f mysql/values.yaml -f mysql/values.production.yaml
deployments[*].helm.replaceImageTags
The replaceImageTags
option expects a boolean stating if DevSpace should do Image Tag Replacement.
By default, DevSpace searches all your values (specified via values
or valuesFiles
) for images that are defined in the images
section of the devspace.yaml
. If DevSpace finds an image, it replaces or appends the image tag with the tag it created during the image building process. Image tag replacement makes sure that your application will always be started with the most up-to-date image that DevSpace has built for you.
Tag replacement takes place in-memory and is not writing anything to the filesystem, i.e. it will never change any of your configuration files.
replaceImageTags
Default Value for replaceImageTags: true
Example: Disable Tag Replacement
deployments:
- name: database
helm:
chart:
name: stable/mysql
replaceImageTags: false
Helm Options
deployments[*].helm.wait
The wait
option expects a boolean that will be used for the helm flag --wait
.
wait
Default Value for wait: false
Example: Helm Flag Wait
deployments:
- name: database
helm:
chart:
name: stable/mysql
wait: true
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database stable/mysql --wait
deployments[*].helm.timeout
The timeout
option expects an integer representing a number of seconds that will be used for the helm flag --timeout
.
timeout
Default Value for timeout: 180
Example: Helm Flag Timeout
deployments:
- name: database
helm:
chart:
name: stable/mysql
timeout: 300
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database stable/mysql --timeout=300
deployments[*].helm.force
The force
option expects a boolean that will be used for the helm flag --force
.
force
Default Value for force: false
Example: Helm Flag Force
deployments:
- name: database
helm:
chart:
name: stable/mysql
force: true
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database stable/mysql --force
deployments[*].helm.rollback
The rollback
option expects a boolean that states if DevSpace should automatically rollback deployments that fail.
rollback
Default Value for rollback: false
Example: Enabling Automatic Rollback
deployments:
- name: database
helm:
chart:
name: stable/mysql
rollback: true
deployments[*].helm.tillerNamespace
The tillerNamespace
option expects a string that will be used for the helm flag --tiller-namespace
.
tillerNamespace
Default Value for tillerNamespace: "" # defaults to default namespace of current context
Example: Helm Flag Force
deployments:
- name: database
helm:
chart:
name: stable/mysql
tillerNamespace: my-tiller-ns
Explanation:
Deploying the above example would roughly be equivalent to this command:
helm install --name database stable/mysql --tiller-namespace=my-tiller-ns
Useful Commands
devspace add deployment [NAME] --chart=./path/to/my/chart
If you built your own Helm chart and it is located inside your project directory, you can simply add it as a deployment using the following command:
devspace add deployment [deployment-name] --chart="./path/to/my/chart"
Running
devspace add deployment
only adds a deployment todevspace.yaml
but does not actually deploy anything. To deploy the newly added deployment, rundevspace deploy
ordevspace dev
.
devspace add deployment [deployment-name] --chart=stable/[CHART]
If you want to deploy a Helm chart from a chart repository, you can simply add it as shown in this example:
devspace add deployment [deployment-name] --chart="stable/mysql"
You can replace stable
with the name of your Helm chart repository, if it already exists on your local computer. If you want to use a chart from a chart repository that you have not used yet, you can also specify the repository URL:
devspace add deployment [deployment-name] --chart="chart-name" --chart-repo="https://my-chart-repository.tld"
Use the --chart-version
flag to specifiy the char version that you want to deploy.
Running
devspace add deployment
only adds a deployment todevspace.yaml
but does not actually deploy anything. To deploy the newly added deployment, rundevspace deploy
ordevspace dev
.
devspace remove deployment [NAME]
Instead of manually removing a deployment from your devspace.yaml
, it is recommended to run this command instead:
devspace remove deployment [deployment-name]
The benefit of running devspace remove deployment
is that DevSpace will ask you this question:
? Do you want to delete all deployment resources deployed? [Use arrows to move, type to filter]
> yes
no
If you select yes, DevSpace will remove your deployment from your Kubernetes cluster before deleting it in your devspace.yaml
. This is great to keep your Kubernetes namespaces clean from zombie deployments that cannot be easily tracked, removed and updated anymore.