Skip to content

Commit

Permalink
Add template metadata to CABPK and KCP types
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Büringer [email protected]
  • Loading branch information
sbueringer committed Feb 27, 2023
1 parent d21addf commit 03b55b9
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 30 deletions.
7 changes: 7 additions & 0 deletions bootstrap/kubeadm/api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ func (src *KubeadmConfigTemplate) ConvertTo(dstRaw conversion.Hub) error {
}
}

dst.Spec.Template.ObjectMeta = restored.Spec.Template.ObjectMeta

if restored.Spec.Template.Spec.JoinConfiguration != nil && restored.Spec.Template.Spec.JoinConfiguration.NodeRegistration.IgnorePreflightErrors != nil {
if dst.Spec.Template.Spec.JoinConfiguration == nil {
dst.Spec.Template.Spec.JoinConfiguration = &bootstrapv1.JoinConfiguration{}
Expand Down Expand Up @@ -275,3 +277,8 @@ func Convert_v1beta1_User_To_v1alpha3_User(in *bootstrapv1.User, out *User, s ap
// User.PasswdFrom does not exist in kubeadm v1alpha3 API.
return autoConvert_v1beta1_User_To_v1alpha3_User(in, out, s)
}

func Convert_v1beta1_KubeadmConfigTemplateResource_To_v1alpha3_KubeadmConfigTemplateResource(in *bootstrapv1.KubeadmConfigTemplateResource, out *KubeadmConfigTemplateResource, s apiconversion.Scope) error {
// KubeadmConfigTemplateResource.metadata does not exist in kubeadm v1alpha3.
return autoConvert_v1beta1_KubeadmConfigTemplateResource_To_v1alpha3_KubeadmConfigTemplateResource(in, out, s)
}
16 changes: 6 additions & 10 deletions bootstrap/kubeadm/api/v1alpha3/zz_generated.conversion.go

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

7 changes: 7 additions & 0 deletions bootstrap/kubeadm/api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func (src *KubeadmConfigTemplate) ConvertTo(dstRaw conversion.Hub) error {
}
}

dst.Spec.Template.ObjectMeta = restored.Spec.Template.ObjectMeta

dst.Spec.Template.Spec.Ignition = restored.Spec.Template.Spec.Ignition
if restored.Spec.Template.Spec.InitConfiguration != nil {
if dst.Spec.Template.Spec.InitConfiguration == nil {
Expand Down Expand Up @@ -213,3 +215,8 @@ func Convert_v1beta1_NodeRegistrationOptions_To_v1alpha4_NodeRegistrationOptions
// kubeadm v1alpha4 API.
return autoConvert_v1beta1_NodeRegistrationOptions_To_v1alpha4_NodeRegistrationOptions(in, out, s)
}

func Convert_v1beta1_KubeadmConfigTemplateResource_To_v1alpha4_KubeadmConfigTemplateResource(in *bootstrapv1.KubeadmConfigTemplateResource, out *KubeadmConfigTemplateResource, s apiconversion.Scope) error {
// KubeadmConfigTemplateResource.metadata does not exist in kubeadm v1alpha4.
return autoConvert_v1beta1_KubeadmConfigTemplateResource_To_v1alpha4_KubeadmConfigTemplateResource(in, out, s)
}
16 changes: 6 additions & 10 deletions bootstrap/kubeadm/api/v1alpha4/zz_generated.conversion.go

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

7 changes: 7 additions & 0 deletions bootstrap/kubeadm/api/v1beta1/kubeadmconfigtemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// KubeadmConfigTemplateSpec defines the desired state of KubeadmConfigTemplate.
Expand All @@ -27,6 +29,11 @@ type KubeadmConfigTemplateSpec struct {

// KubeadmConfigTemplateResource defines the Template structure.
type KubeadmConfigTemplateResource struct {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`

Spec KubeadmConfigSpec `json:"spec,omitempty"`
}

Expand Down
1 change: 1 addition & 0 deletions bootstrap/kubeadm/api/v1beta1/zz_generated.deepcopy.go

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

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

10 changes: 10 additions & 0 deletions controlplane/kubeadm/api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ func (src *KubeadmControlPlaneTemplate) ConvertTo(dstRaw conversion.Hub) error {
}
}

dst.Spec.Template.ObjectMeta = restored.Spec.Template.ObjectMeta
if restored.Spec.Template.Spec.MachineTemplate != nil {
dst.Spec.Template.Spec.MachineTemplate.ObjectMeta = restored.Spec.Template.Spec.MachineTemplate.ObjectMeta
}

if restored.Spec.Template.Spec.KubeadmConfigSpec.InitConfiguration != nil {
if dst.Spec.Template.Spec.KubeadmConfigSpec.InitConfiguration == nil {
dst.Spec.Template.Spec.KubeadmConfigSpec.InitConfiguration = &bootstrapv1.InitConfiguration{}
Expand Down Expand Up @@ -281,3 +286,8 @@ func Convert_v1beta1_KubeadmControlPlaneStatus_To_v1alpha4_KubeadmControlPlaneSt
// .LastRemediation was added in v1beta1.
return autoConvert_v1beta1_KubeadmControlPlaneStatus_To_v1alpha4_KubeadmControlPlaneStatus(in, out, scope)
}

func Convert_v1beta1_KubeadmControlPlaneTemplateResource_To_v1alpha4_KubeadmControlPlaneTemplateResource(in *controlplanev1.KubeadmControlPlaneTemplateResource, out *KubeadmControlPlaneTemplateResource, scope apiconversion.Scope) error {
// .metadata and .spec.machineTemplate.metadata was added in v1beta1.
return autoConvert_v1beta1_KubeadmControlPlaneTemplateResource_To_v1alpha4_KubeadmControlPlaneTemplateResource(in, out, scope)
}
16 changes: 6 additions & 10 deletions controlplane/kubeadm/api/v1alpha4/zz_generated.conversion.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
)

Expand Down Expand Up @@ -55,6 +56,11 @@ func init() {

// KubeadmControlPlaneTemplateResource describes the data needed to create a KubeadmControlPlane from a template.
type KubeadmControlPlaneTemplateResource struct {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`

Spec KubeadmControlPlaneTemplateResourceSpec `json:"spec"`
}

Expand Down Expand Up @@ -104,6 +110,11 @@ type KubeadmControlPlaneTemplateResourceSpec struct {
// because they are calculated by the Cluster topology reconciler during reconciliation and thus cannot
// be configured on the KubeadmControlPlaneTemplate.
type KubeadmControlPlaneTemplateMachineTemplate struct {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`

// NodeDrainTimeout is the total amount of time that the controller will spend on draining a controlplane 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
2 changes: 2 additions & 0 deletions controlplane/kubeadm/api/v1beta1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 03b55b9

Please sign in to comment.