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 prompts 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 gets a dialog box where they can select 'one' or 'two' as the value for the mylabelvalue variable.

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

Parameter types can be one of the following:

  • string
  • multiline
  • boolean
  • number
  • password

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:

free-form text field
- 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.

accessing parameter values
labels:
my-label: "{{ .Values.mylabelvalue }}"

Parameter values​

In addition to user created parameters, the platform controller always merges in some 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:

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