Customizing Charts


Before you can deploy customized catalog apps using Rancher, you must add charts to the GitHub repository serving as your custom catalog.

The custom catalog can contain native Helm charts, Rancher charts, or a combination of both (although we recommend using Rancher charts).

先决条件:

Note: Customization of Helm charts takes place outside of the Rancher UI.

  • Within the GitHub repo that you’re using as your custom catalog, create a directory structure that mirrors the structure listed in Chart Directory Structure.

Rancher requires this directory structure, although app-readme.md and questions.yml are optional.

Tip:

  • Recommended: Create an app-readme.md file.

Use this file to create custom text for your chart’s header in the Rancher UI. You can use this text to notify users that the chart is customized for your environment or provide special instruction on how to use it.Example:

  1. $ cat ./app-readme.md
  2. # Wordpress ROCKS!
  • Recommended: Create a questions.yml file.

This file creates a form for users to specify deployment parameters when they deploy the custom chart. Without this file, users must specify the parameters manually using key value pairs, which isn’t user-friendly.The example below creates a form that prompts users for persistent volume size and a storage class.For a list of variables you can use when creating a questions.yml file, see Question Variable Reference.

  1. categories:
  2. - Blog
  3. - CMS
  4. questions:
  5. - variable: persistence.enabled
  6. default: "false"
  7. description: "Enable persistent volume for WordPress"
  8. type: boolean
  9. required: true
  10. label: WordPress Persistent Volume Enabled
  11. show_subquestion_if: true
  12. group: "WordPress Settings"
  13. subquestions:
  14. - variable: persistence.size
  15. default: "10Gi"
  16. description: "WordPress Persistent Volume Size"
  17. type: string
  18. label: WordPress Volume Size
  19. - variable: persistence.storageClass
  20. default: ""
  21. description: "If undefined or null, uses the default StorageClass. Default to null"
  22. type: storageclass
  23. label: Default StorageClass for WordPress
  • Check the customized chart into your GitHub repo.

Result: Your custom chart is added to the repo. Your Rancher Server will replicate the chart within a few minutes.

What’s Next?

Launch your custom catalog app. For more information, see Launching a Catalog App.

Question Variable Reference

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

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, boolean, int, enum, password, storageclass and hostname).
requiredboolfalseDefine if the variable is required or not (true | false)
defaultstringfalseSpecify the default value.
groupstringfalseGroup questions by input value.
min_lengthintfalseMin character length.
max_lengthintfalseMax character length.
minintfalseMin integer length.
maxintfalseMax integer length.
options[]stringfalseSpecify the options when the variable type is enum, for example: options: - “ClusterIP” - “NodePort” - “LoadBalancer”
valid_charsstringfalseRegular expression for input chars validation.
invalid_charsstringfalseRegular expression for invalid input chars validation.
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"

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