Random Template Variables​
Random template variables are built-in in the Elemental Operator.
They allow to include random Int
, Hex
or UUID
values in custom label templates.
The values are computed on the fly during the label template variables
rendering.
Variable | Description |
---|---|
${Random/UUID} | random UUID (e.g., fd95324a-c26b-4e28-8727-1dcec293a0ec) |
${Random/Hex/[1-32]} | random hexadecimal string of the specified lenght (min 1, max 32) |
${Random/Int/[MAXINT] | random integer (min 0, max MAXINT-1) |
Rendering Examples
template value | rendered value example |
---|---|
${Random/UUID} | fd95324a-c26b-4e28-8727-1dcec293a0ec |
${Random/Hex/12} | acd231f222b8 |
${Random/Int/10000} | 9432 |
The Random Template Variables can be handy for generating custom hostnames to be assigned to the registering host.
Since the hostname must be unique and is assigned through the
MachineRegistration spec.machineName
field, Random variables can be used
to ensure uniqueness of a group of host sharing the same custom prefix and/or suffix.
Check the HowTo/Customize hostname section for more information.
registration example Random template variables
apiVersion: elemental.cattle.io/v1beta1
kind: MachineRegistration
metadata:
name: fire-nodes
namespace: fleet-default
spec:
machineName: "fire-node-${Random/Hex/12}"
config:
cloud-config:
users:
- name: root
passwd: root
elemental:
install:
reboot: true
device: /dev/sda
debug: true
machineInventoryLabels:
elemental.cattle.io/UUID: "${Random/UUID}"