Skip to main content

Example: Mapping the Configuration Screen to Helm Values

Replicated KOTS allows you to map the values that your users provides through the Replicated admin console configuration screen to your Helm chart values.yaml file. This example shows a possible configuration for the Grafana platform.

For more information about customizing the configuration screen, see Creating and Editing Configuration Fields.

Choosing Values

To start, we can read the values.yaml to find a few values.

tar -xOf ~/helm-grafana/manifests/grafana-5.0.13.tgz grafana/values.yaml

In this example, we will use adminUser and adminPassword.

adminUser: admin
adminPassword: admin

Create config fields

Add username and password fields to ~/helm-grafana/manifests/config.yaml

kind: Config
name: grafana-config
- name: grafana
title: Grafana
description: Grafana Configuration
- name: admin_user
title: Admin User
type: text
default: 'admin'
- name: admin_password
title: Admin Password
type: password
default: 'admin'

To test this, run replicated release create --auto, deploy the new version, and go to the admin console Config screen. Helm Chart Grafana Config Screen

For now, these fields will have no effect. Next, we'll map these user-supplied values to Helm Chart values.

Map to Helm Chart

In ~/helm-grafana/manifests/grafana.yaml, update values with the ConfigOption template function.

@@ -7,5 +7,5 @@
name: grafana
chartVersion: 5.0.13
- adminUser: "admin"
- adminPassword: "admin"
+ adminUser: "repl{{ ConfigOption `admin_user`}}"
+ adminPassword: "repl{{ ConfigOption `admin_password`}}"

Before deploying let's quickly check the value of the secret, so we can confirm it changed

$ kubectl get secret grafana -o yaml

apiVersion: v1
admin-password: YWRtaW4=
admin-user: YWRtaW4=

Next, we can make a release and get ready to test it out

replicated release create --auto

Deploy the new release Helm Chart Check for Updates 2

Update the User and Password fields in kotsadm Config and verify the grafana secret got updated.

$ kubectl get secret grafana -o yaml

apiVersion: v1
admin-password: cGFzc3dvcmQhMTIz
admin-user: YWRtaW4=

Login via http://localhost:8080 with the new credentials.