diff --git a/pkg/cloudprovider/aws/apis/v1alpha1/provider.go b/pkg/cloudprovider/aws/apis/v1alpha1/provider.go index 125143a26586..b25c9e764415 100644 --- a/pkg/cloudprovider/aws/apis/v1alpha1/provider.go +++ b/pkg/cloudprovider/aws/apis/v1alpha1/provider.go @@ -74,25 +74,6 @@ type LaunchTemplate struct { // BlockDeviceMappings to be applied to provisioned nodes. // +optionals BlockDeviceMappings []*BlockDeviceMapping `json:"blockDeviceMappings,omitempty"` - // UserData to be applied to the provisioned nodes. - // It must be in the appropriate format based on the specified AMIFamily. Karpenter will merge certain fields into - // this UserData to ensure nodes are being provisioned with the correct configuration. - // +optional - UserData *UserData `json:"userData,omitempty"` -} - -type UserData struct { - // ConfigMap defines the configuration map to retrieve the UserData from. - ConfigMap *ConfigMapUserDataSource `json:"configMap,omitempty"` -} - -// ConfigMapSource defines the configMap where you can retrieve the UserData content. -// Only a single key is expected in the entire map. BinaryData is not supported. -type ConfigMapUserDataSource struct { - // Name of the ConfigMap. - Name *string `json:"name,omitempty"` - // Namespace of the ConfigMap. - Namespace *string `json:"namespace,omitempty"` } // MetadataOptions contains parameters for specifying the exposure of the diff --git a/pkg/cloudprovider/aws/apis/v1alpha1/provider_validation.go b/pkg/cloudprovider/aws/apis/v1alpha1/provider_validation.go index 42699f81c5dc..00a9f72f4927 100644 --- a/pkg/cloudprovider/aws/apis/v1alpha1/provider_validation.go +++ b/pkg/cloudprovider/aws/apis/v1alpha1/provider_validation.go @@ -34,7 +34,6 @@ const ( metadataOptionsPath = "metadataOptions" instanceProfilePath = "instanceProfile" blockDeviceMappingsPath = "blockDeviceMappings" - userDataPath = "userData" ) var ( @@ -57,7 +56,6 @@ func (a *AWS) validate() (errs *apis.FieldError) { a.validateMetadataOptions(), a.validateAMIFamily(), a.validateBlockDeviceMappings(), - a.validateUserData(), ) } @@ -77,9 +75,6 @@ func (a *AWS) validateLaunchTemplate() (errs *apis.FieldError) { if a.InstanceProfile != nil { errs = errs.Also(apis.ErrMultipleOneOf(launchTemplatePath, instanceProfilePath)) } - if a.UserData != nil { - errs = errs.Also(apis.ErrMultipleOneOf(launchTemplatePath, userDataPath)) - } if len(a.BlockDeviceMappings) != 0 { errs = errs.Also(apis.ErrMultipleOneOf(launchTemplatePath, blockDeviceMappingsPath)) } @@ -256,14 +251,3 @@ func (a *AWS) validateVolumeSize(blockDeviceMapping *BlockDeviceMapping) *apis.F } return nil } - -func (a *AWS) validateUserData() *apis.FieldError { - if a.UserData == nil { - return nil - } - // Only support UserData with Bottlerocket for now. - if *a.AMIFamily != AMIFamilyBottlerocket { - return apis.ErrInvalidValue(fmt.Sprintf("not supported with %v", *a.AMIFamily), userDataPath) - } - return nil -} diff --git a/pkg/cloudprovider/aws/apis/v1alpha1/zz_generated.deepcopy.go b/pkg/cloudprovider/aws/apis/v1alpha1/zz_generated.deepcopy.go index 41a8a0d0576e..f657e6abecb7 100644 --- a/pkg/cloudprovider/aws/apis/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/cloudprovider/aws/apis/v1alpha1/zz_generated.deepcopy.go @@ -159,31 +159,6 @@ func (in *BlockDeviceMapping) DeepCopy() *BlockDeviceMapping { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ConfigMapUserDataSource) DeepCopyInto(out *ConfigMapUserDataSource) { - *out = *in - if in.Name != nil { - in, out := &in.Name, &out.Name - *out = new(string) - **out = **in - } - if in.Namespace != nil { - in, out := &in.Namespace, &out.Namespace - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapUserDataSource. -func (in *ConfigMapUserDataSource) DeepCopy() *ConfigMapUserDataSource { - if in == nil { - return nil - } - out := new(ConfigMapUserDataSource) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LaunchTemplate) DeepCopyInto(out *LaunchTemplate) { *out = *in @@ -208,11 +183,6 @@ func (in *LaunchTemplate) DeepCopyInto(out *LaunchTemplate) { } } } - if in.UserData != nil { - in, out := &in.UserData, &out.UserData - *out = new(UserData) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LaunchTemplate. @@ -259,23 +229,3 @@ func (in *MetadataOptions) DeepCopy() *MetadataOptions { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *UserData) DeepCopyInto(out *UserData) { - *out = *in - if in.ConfigMap != nil { - in, out := &in.ConfigMap, &out.ConfigMap - *out = new(ConfigMapUserDataSource) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UserData. -func (in *UserData) DeepCopy() *UserData { - if in == nil { - return nil - } - out := new(UserData) - in.DeepCopyInto(out) - return out -} diff --git a/website/content/en/preview/AWS/provisioning.md b/website/content/en/preview/AWS/provisioning.md index e9a967dbb8f7..43d88b00f60e 100644 --- a/website/content/en/preview/AWS/provisioning.md +++ b/website/content/en/preview/AWS/provisioning.md @@ -207,33 +207,39 @@ spec: ### UserData -The `userData` field in a Provisioner can be used to control the UserData that Karpenter will use when provisioning nodes. -Your UserData must be specified via a ConfigMap, and it will be processed differently based on the AMIFamily selected. +In order to specify custom user data, you must include it within the AWSNodeTemplate resource. You can then reference the AWSNodeTemplate resource through `spec.providerRef` in your provisioner. **Examples** -You can specify which ConfigMap to retrieve your userData from - +Your UserData can be added to `spec.userData` in the `AWSNodeTemplate` resource like this - ``` - provider: - amiFamily: Bottlerocket - userData: - configMap: - name: my-userdata - namespace: karpenter -``` - -The UserData can be specified within your ConfigMap under a single arbitrarily named key. Binary contents are not supported. -``` -data: - userData.toml: | +apiVersion: karpenter.k8s.aws/v1alpha1 +kind: AWSNodeTemplate +metadata: + name: mynodetemplate +spec: + userData: | [settings.kubernetes] kube-api-qps = 30 [settings.kubernetes.eviction-hard] "memory.available" = "20%" -kind: ConfigMap ``` -*This field is currently only supported for the Bottlerocket AMIFamily*. +The AWSNodeTemplate CRD can then be referenced within the provisioner through `providerRef` - +``` +spec: + provider: + amiFamily: Bottlerocket + instanceProfile: MyInstanceProfile + subnetSelector: + karpenter.sh/discovery: my-cluster + securityGroupSelector: + karpenter.sh/discovery: my-cluster + providerRef: + name: mynodetemplate +``` + +*Supporting UserData via the providerRef is currently only supported for the Bottlerocket AMIFamily*. **Semantics for Bottlerocket** * Your UserData must be valid TOML.