Create Cluster Profile Variables
Cluster profile variables allow you to define and manage reusable configuration parameters within a cluster profile, helping standardize deployments, reduce manual configuration errors, and simplify updates by allowing values to be dynamically set during cluster provisioning. This guide takes you through the process of creating cluster profile variables, adding them to profile layers, and deploying clusters with them.
Create a Cluster Profile Variable
Prerequisites
-
The
clusterProfile.create
andclusterProfile.update
permissions to create and update cluster profiles. Refer to Roles and Permissions for more information. -
An existing cluster profile.
Enablement
You can define profile variables when creating or updating cluster profiles. This guide assumes you have already created a cluster profile. Refer to the Create Cluster Profiles guide to learn how to create a cluster profile.
-
Log in to Palette.
-
On the left Main Menu, select Profiles and choose the cluster profile for which you want to define profile variables.
-
In the upper-right corner, click Variables. Then, on the Profile variables pane, click Create variable.
tipAlternatively, open a profile layer and, in the upper-right corner of its YAML configuration editor, select Variables, then Create variable.
-
Enter the Variable name. This name is automatically preceded by
.spectro.var.
, which cannot be changed. The full cluster profile variable,{{.spectro.var.variable_name}}
, is used when adding variables to layer configurations. The Variable name must be unique within the scope of the cluster profile. -
Enter the variable Display name that Palette will display during cluster deployment. The Display name must be unique within the scope of the cluster profile.
-
Optionally, enter a variable description.
-
Select the data format for the variable. The following table describes available data formats.
Format Description String Custom text input. Number Any numeric type, such as integers and floating point numbers. Boolean true
orfalse
. Values that evaluate totrue
orfalse
, such as 1 and 0, are not accepted.Version Version value that follows the Semantic Versioning convention, such as x.y.z
.IPv4 Valid representation of an IPv4 address. IPv4 CIDR A CIDR block of IP addresses that follow the IPv4 standard. IPv6 Valid representation of an IPv6 address. -
Optionally, configure additional data validation. The following table describes the available parameters.
Parameter Description Custom input validation Validate the cluster profile variable definition against a regular expression based on the regexp engine. Required Require a value for the cluster profile variable. Default value Set a default value for the cluster profile variable. Mask value Mask the cluster profile variable with asterisks in the layer YAML configuration. When you export a profile with masked variables, they will be masked in the exported profile. Upon import, you will be required to provide the masked values. Hidden Hide the cluster profile variable during cluster deployment. If the variable is both hidden and required, it must have a default value set. Read-only Prevent the cluster profile variable from being edited during cluster deployment. Read-only variables must have a default value set. -
As you make changes in the Create variable pane, the Preview field is updated, mirroring how the field will look and behave when deploying and updating clusters. When you are satisfied, select Create to create the variable.
-
Navigate to the YAML configuration of the profile layer to which you want to add the variable. In the upper-right corner of its YAML configuration editor, select Variables.
-
Next to the variable you want to add, click the Copy to clipboard icon to copy its name.
-
Paste the variable in the
parameter: "{{.spectro.var.variable_name}}"
format and click Confirm Updates.Alternatively, you can start typing
{{.spectro.var.}}
in the YAML configuration editor, and Palette will list the profile variables you have created. Continue typing to filter the list, or use the Up arrow and Down arrow keys to select the appropriate profile variable. Press Tab to accept the suggestion and add the variable.tipBy default, profile variables are listed in the order they are created. This order is also used when deploying or modifying clusters. To change the display order of variables, select the Variables three-dot Menu, choose Reorder variables, and drag and drop variables to change their display order. Finally, select Confirm order.
-
Repeat the steps described in this guide to define more variables and add them to the necessary cluster profile layers. Remember to choose Confirm Updates when you are finished with each layer, and select Save Changes when you are finished modifying your profile.
warningSome packs may not support certain cluster profile variable data formats. If there is an existing schema constraint defined in the pack, the variable must satisfy the schema; otherwise, the variable cannot be used, and the updated cluster profile cannot be saved. Refer to the Pack Constraints page for more information.
Validate
-
Log in to Palette.
-
From the left Main Menu, select Profiles and navigate to the cluster profile for which you have created profile variables.
-
In the upper-right corner, click Variables and, on the Profile variables pane, check that the necessary variables are properly defined.
-
Hover over the [#] layers pill next to the variables to review the profile layers where they are used.
-
Open the necessary profile layers and check that their YAML configuration contains the expected variables.
Cluster Deployment
You can now use your cluster profile to deploy or update a cluster. The steps involved in deploying a cluster depend on the infrastructure provider; however, when cluster profile variables are configured in the cluster profile, there will always be an additional Profile Config window displayed prior to deploying the cluster. To learn more about deploying clusters, visit our Getting Started series.
Note that in the below example, we entered amazing-hello-universe-namespace
for the namespace of the Hello Universe
application.
Once you deploy a cluster using profile variables, verify that any parameters containing cluster profile variables were
populated with the expected values. The following validation process uses the
kubectl CLI and the cluster's
kubeconfig file. For more
information on how to use kubectl
and kubeconfig with your Palette clusters, refer to the Spectro Cloud
Kubectl and
Kubeconfig guides.
-
Log in to Palette.
-
Navigate to the left Main Menu and select Clusters.
-
Select the host cluster you want to access.
-
Follow the Kubectl guide to download your cluster's kubeconfig file and access your cluster using
kubectl
. -
Issue the appropriate
kubectl
command to verify that your parameter was populated correctly.The following example verifies that the Hello Universe namespace entered on the Profile Config window during cluster deployment was created.
kubectl get namespaces
NAME STATUS AGE
amazing-hello-universe-namespace Active 5m49s
capi-webhook-system Active 14m
cert-manager Active 14m
cluster-67a235d83902eab79410087b Active 14m
default Active 15m
kube-node-lease Active 15m
kube-public Active 15m
kube-system Active 15m
kubecost Active 5m55s
os-patch Active 11m
palette-system Active 12m
Next Steps
Cluster profile variables were created not just to make deploying clusters easier but also updating their configuration values. Refer to the Modify Cluster Profile Variables guide to learn more.