diff --git a/api/v1beta2/awsmachine_types.go b/api/v1beta2/awsmachine_types.go index 415457485f..64c06e23e7 100644 --- a/api/v1beta2/awsmachine_types.go +++ b/api/v1beta2/awsmachine_types.go @@ -286,9 +286,10 @@ type CloudInit struct { // For more information on Ignition configuration, see https://coreos.github.io/butane/specs/ type Ignition struct { // Version defines which version of Ignition will be used to generate bootstrap data. + // Defaults to `2.3` if storageType is set to `ClusterObjectStore`. + // It will be ignored if storageType is set to `UnencryptedUserData`, as the userdata defines its own version. // // +optional - // +kubebuilder:default="2.3" // +kubebuilder:validation:Enum="2.3";"3.0";"3.1";"3.2";"3.3";"3.4" Version string `json:"version,omitempty"` diff --git a/api/v1beta2/awsmachine_webhook.go b/api/v1beta2/awsmachine_webhook.go index b5ad5010e9..f63e2707ff 100644 --- a/api/v1beta2/awsmachine_webhook.go +++ b/api/v1beta2/awsmachine_webhook.go @@ -451,7 +451,9 @@ func (*awsMachineWebhook) Default(_ context.Context, obj runtime.Object) error { r.Spec.CloudInit.SecureSecretsBackend = SecretBackendSecretsManager } - if r.ignitionEnabled() && r.Spec.Ignition.Version == "" { + // Defaults the version field if StorageType is not set to `UnencryptedUserData`. + // When using `UnencryptedUserData` the version field is ignored because the userdata defines its version itself. + if r.ignitionEnabled() && r.Spec.Ignition.Version == "" && r.Spec.Ignition.StorageType != IgnitionStorageTypeOptionUnencryptedUserData { r.Spec.Ignition.Version = DefaultIgnitionVersion } if r.ignitionEnabled() && r.Spec.Ignition.StorageType == "" { diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml index 893efb3e32..e83d812155 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml @@ -1001,9 +1001,10 @@ spec: type: array type: object version: - default: "2.3" - description: Version defines which version of Ignition will be - used to generate bootstrap data. + description: |- + Version defines which version of Ignition will be used to generate bootstrap data. + Defaults to `2.3` if storageType is set to `ClusterObjectStore`. + It will be ignored if storageType is set to `UnencryptedUserData`, as the userdata defines its own version. enum: - "2.3" - "3.0" diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml index 7541a2ee82..6867ac592d 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml @@ -822,9 +822,10 @@ spec: type: array type: object version: - default: "2.3" - description: Version defines which version of Ignition will be - used to generate bootstrap data. + description: |- + Version defines which version of Ignition will be used to generate bootstrap data. + Defaults to `2.3` if storageType is set to `ClusterObjectStore`. + It will be ignored if storageType is set to `UnencryptedUserData`, as the userdata defines its own version. enum: - "2.3" - "3.0" diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml index 6329967619..7796a708b9 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml @@ -741,9 +741,10 @@ spec: type: array type: object version: - default: "2.3" - description: Version defines which version of Ignition - will be used to generate bootstrap data. + description: |- + Version defines which version of Ignition will be used to generate bootstrap data. + Defaults to `2.3` if storageType is set to `ClusterObjectStore`. + It will be ignored if storageType is set to `UnencryptedUserData`, as the userdata defines its own version. enum: - "2.3" - "3.0" diff --git a/exp/api/v1beta2/awsmachinepool_webhook.go b/exp/api/v1beta2/awsmachinepool_webhook.go index 3b8cf9fdac..eac0f675fa 100644 --- a/exp/api/v1beta2/awsmachinepool_webhook.go +++ b/exp/api/v1beta2/awsmachinepool_webhook.go @@ -314,7 +314,9 @@ func (*AWSMachinePoolWebhook) Default(ctx context.Context, obj runtime.Object) e r.Spec.DefaultInstanceWarmup.Duration = 300 * time.Second } - if r.ignitionEnabled() && r.Spec.Ignition.Version == "" { + // Defaults the version field if StorageType is not set to `UnencryptedUserData`. + // When using `UnencryptedUserData` the version field is ignored because the userdata defines its version itself. + if r.ignitionEnabled() && r.Spec.Ignition.Version == "" && r.Spec.Ignition.StorageType != infrav1.IgnitionStorageTypeOptionUnencryptedUserData { r.Spec.Ignition.Version = infrav1.DefaultIgnitionVersion } if r.ignitionEnabled() && r.Spec.Ignition.StorageType == "" { diff --git a/pkg/cloud/services/ec2/launchtemplate.go b/pkg/cloud/services/ec2/launchtemplate.go index 3eefb51ed0..c805a00e7a 100644 --- a/pkg/cloud/services/ec2/launchtemplate.go +++ b/pkg/cloud/services/ec2/launchtemplate.go @@ -92,14 +92,17 @@ func (s *Service) ReconcileLaunchTemplate( } var ignitionStorageType = infrav1.DefaultMachinePoolIgnitionStorageType - var ignitionVersion = infrav1.DefaultIgnitionVersion if ignition := ignitionScope.Ignition(); ignition != nil { ignitionStorageType = ignition.StorageType - ignitionVersion = ignition.Version } var userDataForLaunchTemplate []byte if bootstrapDataFormat == "ignition" && ignitionStorageType == infrav1.IgnitionStorageTypeOptionClusterObjectStore { + var ignitionVersion = infrav1.DefaultIgnitionVersion + if ignition := ignitionScope.Ignition(); ignition != nil { + ignitionVersion = ignition.Version + } + if s3Scope.Bucket() == nil { return errors.New("using Ignition with `AWSMachinePool.spec.ignition.storageType=ClusterObjectStore` " + "requires a cluster wide object storage configured at `AWSCluster.spec.s3Bucket`")