Skip to main content

Parameters

Parameters are a very powerful component of templates. These parameters allow for giving users that may consume your template a bit of flexibility with configuration options for certain applications, while still maintaining control over the possible values the users can select.

When deploying a resource referring to a template with parameters configured, the platform will prompt the user for their selection for the given parameters.

Parameter Definition

Parameters are provided as YAML data structures. For example, with a parameters configuration as shown below, the user will get a dialog box where they can select 'one' or 'two' as the value for the mylabelvalue variable.

- variable: mylabelvalue
label: StatefulSet Label
description: Please select the value for the statefulset "my-label" key
options:
- one
- two
section: Labels

Parameters can also be free-form text fields that are optionally validated. The following snippet shows an example option that accepts a user input string and validates it against the validation regular expression:

- variable: anotherlabelvalue
label: AnImportantValue
description: Please enter this very important value
section: Important Values
required: true
validation: "^\w+{8,63}$"

Accessing Parameter Values

The value of Parameters can be accessed in the rest of the resource definition. If you have worked with go templates, this will be very familiar to you, but even if you haven't it is quite simple. Values can be accessed in your teamplate using the {{ .Values. myvalue }} notation -- where myvalue is the name of in the variable field of your Parameters declaration.

labels:
my-label: "{{ .Values.mylabelvalue }}"

vCluster Platform Parameter values

In addition to user created parameters, the vCluster Platform controller will always merge in some vCluster Platform-specific parameters that are also available to you. The available parameters differ slightly depending on where you are deploying the resource associated with the template. These values are behind the vCluster Platform key.

ObjectYAML KeyValue
ProjectprojectThe name of the project that contains the space/virtualcluster the app is being deployed into
SpacespaceThe name of the space (if applicable) the app is being deployed into
VirtualClustervirtualClusterNameThe name of the virtual cluster (if applicable) the app is being deployed into
ClusterclusterThe name of the cluster the space/virtualcluster (and by extension the app) is in
VirtualClusterNamespacevirtualClusterNamespaceThe namespace the virtualcluster is in

With this you could access the virtualClusterName as follows:

labels:
my-label: "{{ .Values.loft.virtualClusterName }}"