@@ -106,6 +106,10 @@ type ControlPlaneClass struct {
106106 // +optional
107107 MachineHealthCheck * MachineHealthCheckClass `json:"machineHealthCheck,omitempty"`
108108
109+ // NamingStrategy allows changing the naming pattern used when creating the control plane provider object.
110+ // +optional
111+ NamingStrategy * ControlPlaneClassNamingStrategy `json:"namingStrategy,omitempty"`
112+
109113 // NodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
110114 // The default value is 0, meaning that the node can be drained without any time limitations.
111115 // NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
@@ -127,6 +131,19 @@ type ControlPlaneClass struct {
127131 NodeDeletionTimeout * metav1.Duration `json:"nodeDeletionTimeout,omitempty"`
128132}
129133
134+ // ControlPlaneClassNamingStrategy defines the naming strategy for control plane objects.
135+ type ControlPlaneClassNamingStrategy struct {
136+ // Template defines the template to use for generating the name of the ControlPlane object.
137+ // If not defined, it will fallback to `{{ .cluster.name }}-{{ .random }}`.
138+ // If the templated string exceeds 63 characters, it will be trimmed to 58 characters and will
139+ // get concatenated with a random suffix of length 5.
140+ // The templating mechanism provides the following arguments:
141+ // * `.cluster.name`: The name of the cluster object.
142+ // * `.random`: A random alphanumeric string, without vowels, of length 5.
143+ // +optional
144+ Template * string `json:"template,omitempty"`
145+ }
146+
130147// WorkersClass is a collection of deployment classes.
131148type WorkersClass struct {
132149 // MachineDeployments is a list of machine deployment classes that can be used to create
@@ -162,6 +179,10 @@ type MachineDeploymentClass struct {
162179 // +optional
163180 FailureDomain * string `json:"failureDomain,omitempty"`
164181
182+ // NamingStrategy allows changing the naming pattern used when creating the MachineDeployment.
183+ // +optional
184+ NamingStrategy * MachineDeploymentClassNamingStrategy `json:"namingStrategy,omitempty"`
185+
165186 // NodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
166187 // The default value is 0, meaning that the node can be drained without any time limitations.
167188 // NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
@@ -212,6 +233,20 @@ type MachineDeploymentClassTemplate struct {
212233 Infrastructure LocalObjectTemplate `json:"infrastructure"`
213234}
214235
236+ // MachineDeploymentClassNamingStrategy defines the naming strategy for machine deployment objects.
237+ type MachineDeploymentClassNamingStrategy struct {
238+ // Template defines the template to use for generating the name of the MachineDeployment object.
239+ // If not defined, it will fallback to `{{ .cluster.name }}-{{ .machineDeployment.topologyName }}-{{ .random }}`.
240+ // If the templated string exceeds 63 characters, it will be trimmed to 58 characters and will
241+ // get concatenated with a random suffix of length 5.
242+ // The templating mechanism provides the following arguments:
243+ // * `.cluster.name`: The name of the cluster object.
244+ // * `.random`: A random alphanumeric string, without vowels, of length 5.
245+ // * `.machineDeployment.topologyName`: The name of the MachineDeployment topology (Cluster.spec.topology.workers.machineDeployments[].name).
246+ // +optional
247+ Template * string `json:"template,omitempty"`
248+ }
249+
215250// MachineHealthCheckClass defines a MachineHealthCheck for a group of Machines.
216251type MachineHealthCheckClass struct {
217252 // UnhealthyConditions contains a list of the conditions that determine
@@ -267,6 +302,10 @@ type MachinePoolClass struct {
267302 // +optional
268303 FailureDomains []string `json:"failureDomains,omitempty"`
269304
305+ // NamingStrategy allows changing the naming pattern used when creating the MachinePool.
306+ // +optional
307+ NamingStrategy * MachinePoolClassNamingStrategy `json:"namingStrategy,omitempty"`
308+
270309 // NodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
271310 // The default value is 0, meaning that the node can be drained without any time limitations.
272311 // NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
@@ -312,6 +351,20 @@ type MachinePoolClassTemplate struct {
312351 Infrastructure LocalObjectTemplate `json:"infrastructure"`
313352}
314353
354+ // MachinePoolClassNamingStrategy defines the naming strategy for machine pool objects.
355+ type MachinePoolClassNamingStrategy struct {
356+ // Template defines the template to use for generating the name of the MachinePool object.
357+ // If not defined, it will fallback to `{{ .cluster.name }}-{{ .machinePool.topologyName }}-{{ .random }}`.
358+ // If the templated string exceeds 63 characters, it will be trimmed to 58 characters and will
359+ // get concatenated with a random suffix of length 5.
360+ // The templating mechanism provides the following arguments:
361+ // * `.cluster.name`: The name of the cluster object.
362+ // * `.random`: A random alphanumeric string, without vowels, of length 5.
363+ // * `.machinePool.topologyName`: The name of the MachinePool topology (Cluster.spec.topology.workers.machinePools[].name).
364+ // +optional
365+ Template * string `json:"template,omitempty"`
366+ }
367+
315368// IsZero returns true if none of the values of MachineHealthCheckClass are defined.
316369func (m MachineHealthCheckClass ) IsZero () bool {
317370 return reflect .ValueOf (m ).IsZero ()
0 commit comments