Skip to content

Commit

Permalink
ClusterClass: Introduce NamingStrategy and allow generating names usi…
Browse files Browse the repository at this point in the history
…ng go templates
  • Loading branch information
chrischdi committed Aug 30, 2023
1 parent 7b6db93 commit cd17b46
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 28 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (src *ClusterClass) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Patches = restored.Spec.Patches
dst.Spec.Variables = restored.Spec.Variables
dst.Spec.ControlPlane.MachineHealthCheck = restored.Spec.ControlPlane.MachineHealthCheck
dst.Spec.ControlPlane.NamingStrategy = restored.Spec.ControlPlane.NamingStrategy
dst.Spec.ControlPlane.NodeDrainTimeout = restored.Spec.ControlPlane.NodeDrainTimeout
dst.Spec.ControlPlane.NodeVolumeDetachTimeout = restored.Spec.ControlPlane.NodeVolumeDetachTimeout
dst.Spec.ControlPlane.NodeDeletionTimeout = restored.Spec.ControlPlane.NodeDeletionTimeout
Expand All @@ -132,6 +133,7 @@ func (src *ClusterClass) ConvertTo(dstRaw conversion.Hub) error {
for i := range restored.Spec.Workers.MachineDeployments {
dst.Spec.Workers.MachineDeployments[i].MachineHealthCheck = restored.Spec.Workers.MachineDeployments[i].MachineHealthCheck
dst.Spec.Workers.MachineDeployments[i].FailureDomain = restored.Spec.Workers.MachineDeployments[i].FailureDomain
dst.Spec.Workers.MachineDeployments[i].NamingStrategy = restored.Spec.Workers.MachineDeployments[i].NamingStrategy
dst.Spec.Workers.MachineDeployments[i].NodeDrainTimeout = restored.Spec.Workers.MachineDeployments[i].NodeDrainTimeout
dst.Spec.Workers.MachineDeployments[i].NodeVolumeDetachTimeout = restored.Spec.Workers.MachineDeployments[i].NodeVolumeDetachTimeout
dst.Spec.Workers.MachineDeployments[i].NodeDeletionTimeout = restored.Spec.Workers.MachineDeployments[i].NodeDeletionTimeout
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions api/v1beta1/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ type ControlPlaneClass struct {
// +optional
MachineHealthCheck *MachineHealthCheckClass `json:"machineHealthCheck,omitempty"`

// NamingStrategy allows to change the naming pattern used when creating the control plane provider object.
// If not defined, it will fallback to `{{ .cluster.name }}-{{ .randomSuffix }}`
NamingStrategy *NamingStrategy `json:"namingStrategy,omitempty"`

// NodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
// The default value is 0, meaning that the node can be drained without any time limitations.
// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
Expand Down Expand Up @@ -162,6 +166,10 @@ type MachineDeploymentClass struct {
// +optional
FailureDomain *string `json:"failureDomain,omitempty"`

// NamingStrategy allows to change the naming pattern used when creating the MachineDeployment.
// If not defined, it will fallback to `{{ .cluster.name }}-{ .machineDeployment.topologyName }}-{{ .randomSuffix }}`
NamingStrategy *NamingStrategy `json:"namingStrategy,omitempty"`

// NodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
// The default value is 0, meaning that the node can be drained without any time limitations.
// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
Expand Down Expand Up @@ -267,6 +275,10 @@ type MachinePoolClass struct {
// +optional
FailureDomains []string `json:"failureDomains,omitempty"`

// NamingStrategy allows to change the naming pattern used when creating the MachinePool.
// If not defined, it will fallback to `{{ .cluster.name }}-{ .machinePool.topologyName }}-{{ .randomSuffix }}`
NamingStrategy *NamingStrategy `json:"namingStrategy,omitempty"`

// NodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
// The default value is 0, meaning that the node can be drained without any time limitations.
// NOTE: NodeDrainTimeout is different from `kubectl drain --timeout`
Expand Down Expand Up @@ -637,6 +649,11 @@ type LocalObjectTemplate struct {
Ref *corev1.ObjectReference `json:"ref"`
}

// NamingStrategy defines a naming strategy for templated objects.
type NamingStrategy struct {
Name *string `json:"name,omitempty"`
}

// ANCHOR: ClusterClassStatus

// ClusterClassStatus defines the observed state of the ClusterClass.
Expand Down
35 changes: 35 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 41 additions & 3 deletions api/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cd17b46

Please sign in to comment.