Creating Apps

Creating Apps - 图1tip

For a complete walkthrough of developing charts, see the Chart Template Developer’s Guide in the official Helm documentation.

Chart Types

Rancher supports two different types of charts: Helm charts and Rancher charts.

Helm Charts

Native Helm charts include an application along with other software required to run it. When deploying native Helm charts, you’ can provide the chart’s parameter values in a YAML editor.

Rancher Charts

Rancher charts are native Helm charts with two files that enhance user experience: app-readme.md and questions.yaml. Read more about them in Additional Files for Rancher Charts.

Rancher charts add simplified chart descriptions and configuration forms to make the application deployment easy. Rancher users do not need to read through the entire list of Helm variables to understand how to launch an application.

Chart Directory Structure

You can provide Helm Charts in a standard, HTTP based Helm Repository. For more information see the Chart Repository Guide in the official Helm documentation.

Alternatively you can organize your charts in a Git Repository and directly add this to the App Marketplace.

The following table demonstrates the directory structure for a Git repository. The charts directory is the top level directory under the repository base. Adding the repository to Rancher will expose all charts contained within it. The questions.yaml, README.md, and requirements.yml files are specific to Rancher charts, but are optional for chart customization.

  1. <Repository-Base>/
  2. ├── charts/
  3. │ ├── <Application Name>/ # This directory name will be surfaced in the Rancher UI as the chart name
  4. │ │ ├── <App Version>/ # Each directory at this level provides different app versions that will be selectable within the chart in the Rancher UI
  5. │ │ │ ├── Chart.yaml # Required Helm chart information file.
  6. │ │ │ ├── questions.yaml # Form questions displayed within the Rancher UI. Questions display in Configuration Options.*
  7. │ │ │ ├── README.md # Optional: Helm Readme file displayed within Rancher UI. This text displays in Detailed Descriptions.
  8. │ │ │ ├── requirements.yml # Optional: YAML file listing dependencies for the chart.
  9. │ │ │ ├── values.yml # Default configuration values for the chart.
  10. │ │ │ ├── templates/ # Directory containing templates that, when combined with values.yml, generates Kubernetes YAML.

Additional Files for Rancher Charts

Before you create your own custom catalog, you should have a basic understanding about how a Rancher chart differs from a native Helm chart. Rancher charts differ slightly from Helm charts in their directory structures. Rancher charts include two files that Helm charts do not.

  • app-readme.md

    A file that provides descriptive text in the chart’s UI header.

  • questions.yml

    A file that contains questions for a form. These form questions simplify deployment of a chart. Without it, you must configure the deployment using a values YAML config, which is more difficult. The following images display the difference between a Rancher chart (which includes questions.yml) and a native Helm chart (which does not).

    Rancher Chart with questions.yml (top) vs. Helm Chart without (bottom)

    questions.yml values.yaml

Chart.yaml annotations

Rancher supports additional annotations that you can add to the Chart.yaml file. These annotations allow you to define application dependencies or configure additional UI defaults:

AnnotationDescriptionExample
catalog.cattle.io/auto-installIf set, will install the specified chart in the specified version before installing this chartother-chart-name=1.0.0
catalog.cattle.io/display-nameA display name that should be displayed in the App Marketplace instead of the chart nameDisplay Name of Chart
catalog.cattle.io/namespaceA fixed namespace where the chart should be deployed in. If set, this can’t be changed by the userfixed-namespace
catalog.cattle.io/release-nameA fixed release name for the Helm installation. If set, this can’t be changed by the userfixed-release-name
catalog.cattle.io/requests-cpuTotal amount of CPU that should be unreserverd in the cluster. If less CPU is available, a warning will be shown2000m
catalog.cattle.io/requests-memoryTotal amount of memory that should be unreserverd in the cluster. If less memory is available, a warning will be shown2Gi
catalog.cattle.io/osRestricts the OS where this chart can be installed. Possible values: linux, windows. Default: no restrictionlinux

questions.yml

Inside the questions.yml, most of the content will be around the questions to ask the end user, but there are some additional fields that can be set in this file.

Min/Max Rancher versions

For each chart, you can add the minimum and/or maximum Rancher version, which determines whether or not this chart is available to be deployed from Rancher.

Creating Apps - 图4note

Even though Rancher release versions are prefixed with a v, there is no prefix for the release version when using this option.

  1. rancher_min_version: 2.3.0
  2. rancher_max_version: 2.3.99

Question Variable Reference

This reference contains variables that you can use in questions.yml nested under questions:.

VariableTypeRequiredDescription
variablestringtrueDefine the variable name specified in the values.yml file, using foo.bar for nested objects.
labelstringtrueDefine the UI label.
descriptionstringfalseSpecify the description of the variable.
typestringfalseDefault to string if not specified (current supported types are string, multiline, boolean, int, enum, password, storageclass, hostname, pvc, secret and cloudcredential).
defaultstringfalseSpecify the default value. Only used if there is no corresponding value in the values.yml file.
groupstringfalseGroup questions by input value.
options[]stringfalseSpecify the options when the variable type is enum, for example: options:
- “ClusterIP”
- “NodePort”
- “LoadBalancer”
subquestions[]subquestionfalseAdd an array of subquestions.
show_ifstringfalseShow current variable if conditional variable is true. For example show_if: “serviceType=Nodeport”
show_subquestion_ifstringfalseShow subquestions if is true or equal to one of the options. for example show_subquestion_if: “true”

Creating Apps - 图5note

subquestions[] cannot contain subquestions or show_subquestions_if keys, but all other keys in the above table are supported.