Skip to content

Commit

Permalink
More cleanup after removing ConfigMap
Browse files Browse the repository at this point in the history
  • Loading branch information
suket22 committed May 20, 2022
1 parent 20def55 commit 3a8342f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 102 deletions.
19 changes: 0 additions & 19 deletions pkg/cloudprovider/aws/apis/v1alpha1/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions pkg/cloudprovider/aws/apis/v1alpha1/provider_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const (
metadataOptionsPath = "metadataOptions"
instanceProfilePath = "instanceProfile"
blockDeviceMappingsPath = "blockDeviceMappings"
userDataPath = "userData"
)

var (
Expand All @@ -57,7 +56,6 @@ func (a *AWS) validate() (errs *apis.FieldError) {
a.validateMetadataOptions(),
a.validateAMIFamily(),
a.validateBlockDeviceMappings(),
a.validateUserData(),
)
}

Expand All @@ -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))
}
Expand Down Expand Up @@ -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
}
50 changes: 0 additions & 50 deletions pkg/cloudprovider/aws/apis/v1alpha1/zz_generated.deepcopy.go

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

40 changes: 23 additions & 17 deletions website/content/en/preview/AWS/provisioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3a8342f

Please sign in to comment.