Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ linters:
alias: clusterv1beta1
- pkg: sigs.k8s.io/cluster-api/api/core/v1beta2
alias: clusterv1
# CAPI contract
- pkg: sigs.k8s.io/cluster-api/api/contract/v1beta1
alias: contractv1beta1
- pkg: sigs.k8s.io/cluster-api/api/contract/v1beta2
alias: contractv1
# CAPI exp addons
- pkg: sigs.k8s.io/cluster-api/api/addons/v1beta1
alias: addonsv1beta1
Expand Down
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER))
SETUP_ENVTEST_PKG := sigs.k8s.io/controller-runtime/tools/setup-envtest

CONTROLLER_GEN_VER := v0.20.0
CONTROLLER_GEN_VER := v0.20.1-0.20260223155536-6e1b49198dff
#CONTROLLER_GEN_VER := v0.20.0
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER))
CONTROLLER_GEN_PKG := sigs.k8s.io/controller-tools/cmd/controller-gen
Expand Down Expand Up @@ -281,8 +282,8 @@ help: # Display this help
ALL_GENERATE_MODULES = core kubeadm-bootstrap kubeadm-control-plane docker-infrastructure test-extension

.PHONY: generate
generate: ## Run all generate-manifests-*, generate-go-deepcopy-*, generate-go-conversions-* and generate-go-openapi targets
$(MAKE) generate-modules generate-manifests generate-go-deepcopy generate-go-conversions generate-go-openapi
generate: ## Run all generate-manifests-*, generate-go-deepcopy-*, generate-go-conversions-*, generate-go-applyconfigurations and generate-go-openapi targets
$(MAKE) generate-modules generate-manifests generate-go-deepcopy generate-go-conversions generate-go-applyconfigurations generate-go-openapi

.PHONY: generate-manifests
generate-manifests: $(addprefix generate-manifests-,$(ALL_GENERATE_MODULES)) ## Run all generate-manifests-* targets
Expand Down Expand Up @@ -402,6 +403,7 @@ generate-go-deepcopy-core: $(CONTROLLER_GEN) ## Generate deepcopy go code for co
$(CONTROLLER_GEN) \
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
paths=./api/addons/... \
paths=./api/contract/... \
paths=./api/core/... \
paths=./api/ipam/... \
paths=./api/runtime/... \
Expand Down Expand Up @@ -528,6 +530,15 @@ generate-go-conversions-docker-infrastructure: $(CONVERSION_GEN) ## Generate con
.PHONY: generate-go-conversions-test-extension
generate-go-conversions-test-extension: $(CONVERSION_GEN) ## Generate conversions go code for test runtime extension provider

.PHONY: generate-go-applyconfigurations
generate-go-applyconfigurations: $(CONTROLLER_GEN) ## Generate applyconfigurations go code for core
rm -rf ./util/applyconfigurations
$(CONTROLLER_GEN) \
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
paths=./api/core/... \
paths=./api/contract/... \
applyconfiguration

# The tmp/sigs.k8s.io/cluster-api symlink is a workaround to make this target run outside of GOPATH
.PHONY: generate-go-openapi
generate-go-openapi: $(OPENAPI_GEN) ## Generate openapi go code for runtime SDK
Expand Down
1 change: 1 addition & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ providers = {
"../../go.mod",
"../../go.sum",
"../container",
"../inmemory",
"api",
"controllers",
"docker",
Expand Down
175 changes: 175 additions & 0 deletions api/contract/v1beta2/bootstrapconfig_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
/*
Copyright 2026 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta2

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

clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
"sigs.k8s.io/cluster-api/errors"
)

// BootstrapConfigSpec defines the desired state of BootstrapConfig.
type BootstrapConfigSpec struct {
}

// BootstrapConfigStatus defines the observed state of BootstrapConfig.
// +kubebuilder:validation:MinProperties=1
type BootstrapConfigStatus struct {
// conditions represents the observations of a BootstrapConfig's current state.
// +optional
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=32
Conditions []metav1.Condition `json:"conditions,omitempty"`

// initialization provides observations of the BootstrapConfig initialization process.
// NOTE: Fields in this struct are part of the Cluster API contract and are used to orchestrate initial Machine provisioning.
// +optional
Initialization BootstrapConfigInitializationStatus `json:"initialization,omitempty,omitzero"`

// dataSecretName is the name of the secret that stores the bootstrap data script.
// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=253
DataSecretName string `json:"dataSecretName,omitempty"`

// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.
// +optional
Deprecated *BootstrapConfigDeprecatedStatus `json:"deprecated,omitempty"`
}

// BootstrapConfigInitializationStatus provides observations of the BootstrapConfig initialization process.
// +kubebuilder:validation:MinProperties=1
type BootstrapConfigInitializationStatus struct {
// dataSecretCreated is true when the Machine's boostrap secret is created.
// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate initial Machine provisioning.
// +optional
DataSecretCreated *bool `json:"dataSecretCreated,omitempty"`
}

// BootstrapConfigDeprecatedStatus groups all the status fields that are deprecated and will be removed in a future version.
// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.
type BootstrapConfigDeprecatedStatus struct {
// v1beta1 groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
// +optional
V1Beta1 *BootstrapConfigV1Beta1DeprecatedStatus `json:"v1beta1,omitempty"`
}

// BootstrapConfigV1Beta1DeprecatedStatus groups all the status fields that are deprecated and will be removed when support for v1beta1 will be dropped.
// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.
type BootstrapConfigV1Beta1DeprecatedStatus struct {
// conditions defines current service state of the BootstrapConfig.
//
// Deprecated: This field is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
//
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`

// failureReason will be set in the event that there is a terminal problem
// reconciling the Machine and will contain a succinct value suitable
// for machine interpretation.
//
// This field should not be set for transitive errors that a controller
// faces that are expected to be fixed automatically over
// time (like service outages), but instead indicate that something is
// fundamentally wrong with the Machine's spec or the configuration of
// the controller, and that manual intervention is required. Examples
// of terminal errors would be invalid combinations of settings in the
// spec, values that are unsupported by the controller, or the
// responsible controller itself being critically misconfigured.
//
// Any transient errors that occur during the reconciliation of Machines
// can be added as events to the Machine object and/or logged in the
// controller's output.
//
// Deprecated: This field is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
//
// +optional
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`

// failureMessage will be set in the event that there is a terminal problem
// reconciling the Machine and will contain a more verbose string suitable
// for logging and human consumption.
//
// This field should not be set for transitive errors that a controller
// faces that are expected to be fixed automatically over
// time (like service outages), but instead indicate that something is
// fundamentally wrong with the Machine's spec or the configuration of
// the controller, and that manual intervention is required. Examples
// of terminal errors would be invalid combinations of settings in the
// spec, values that are unsupported by the controller, or the
// responsible controller itself being critically misconfigured.
//
// Any transient errors that occur during the reconciliation of Machines
// can be added as events to the Machine object and/or logged in the
// controller's output.
//
// Deprecated: This field is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
//
// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=10240
FailureMessage *string `json:"failureMessage,omitempty"` //nolint:kubeapilinter // field will be removed when v1beta1 is removed
}

// +kubebuilder:resource:path=BootstrapConfigs,scope=Namespaced,categories=cluster-api
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

// BootstrapConfig is the Schema for the BootstrapConfigs API.
type BootstrapConfig struct {
metav1.TypeMeta `json:",inline"`
// metadata is the standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec is the desired state of BootstrapConfig.
// +optional
Spec BootstrapConfigSpec `json:"spec,omitempty,omitzero"`
// status is the observed state of BootstrapConfig.
// +optional
Status BootstrapConfigStatus `json:"status,omitempty,omitzero"`
}

// GetV1Beta1Conditions returns the set of conditions for this object.
func (c *BootstrapConfig) GetV1Beta1Conditions() clusterv1.Conditions {
if c.Status.Deprecated == nil || c.Status.Deprecated.V1Beta1 == nil {
return nil
}
return c.Status.Deprecated.V1Beta1.Conditions
}

// GetConditions returns the set of conditions for this object.
func (c *BootstrapConfig) GetConditions() []metav1.Condition {
return c.Status.Conditions
}

// +kubebuilder:object:root=true

// BootstrapConfigList contains a list of BootstrapConfig.
type BootstrapConfigList struct {
metav1.TypeMeta `json:",inline"`
// metadata is the standard list's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#lists-and-simple-kinds
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// items is the list of BootstrapConfigs.
Items []BootstrapConfig `json:"items"`
}
23 changes: 23 additions & 0 deletions api/contract/v1beta2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1beta2 contains API Schema definitions for the v1beta2 contract.
// +kubebuilder:object:generate=true
// +groupName=cluster.x-k8s.io
// +disabled-kubebuilder:ac:generate=true
// +disabled-kubebuilder:ac:output:package="./../../../util/applyconfigurations"
// FIXME: looks like if applyconfiguration gen is enabled util/applyconfigurations/utils.go overwrites the one from the core group => report to CT repo
package v1beta2
49 changes: 49 additions & 0 deletions api/contract/v1beta2/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright 2025 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta2

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

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "contract.cluster.x-k8s.io", Version: "v1beta2"}

// SchemeGroupVersion is an alias to GroupVersion, e.g. needed for applyconfigurations.
SchemeGroupVersion = GroupVersion

// schemeBuilder is used to add go types to the GroupVersionKind scheme.
schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = schemeBuilder.AddToScheme
)

func addKnownTypes(scheme *runtime.Scheme) error {
metav1.AddToGroupVersion(scheme, schema.GroupVersion{Group: "vmware.infrastructure.cluster.x-k8s.io", Version: "v1beta2"})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "vmware.infrastructure.cluster.x-k8s.io", Version: "v1beta2", Kind: "VSphereMachine"}, &InfraMachine{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "vmware.infrastructure.cluster.x-k8s.io", Version: "v1beta2", Kind: "VSphereMachineList"}, &InfraMachineList{})

metav1.AddToGroupVersion(scheme, schema.GroupVersion{Group: "bootstrap.cluster.x-k8s.io", Version: "v1beta2"})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "bootstrap.cluster.x-k8s.io", Version: "v1beta2", Kind: "KubeadmConfig"}, &BootstrapConfig{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "bootstrap.cluster.x-k8s.io", Version: "v1beta2", Kind: "KubeadmConfigList"}, &BootstrapConfigList{})

return nil
}
Loading
Loading