Skip to content

Commit d207a72

Browse files
vigh-mrschalo
authored andcommitted
Add support for Bottlerocket on Neuron instance types (aws#7722)
1 parent b7cf115 commit d207a72

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

pkg/controllers/nodeclass/ami_test.go

+18-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ var _ = Describe("NodeClass AMI Status Controller", func() {
311311
ExpectObjectReconciled(ctx, env.Client, controller, nodeClass)
312312
nodeClass = ExpectExists(ctx, env.Client, nodeClass)
313313

314-
Expect(len(nodeClass.Status.AMIs)).To(Equal(4))
314+
Expect(len(nodeClass.Status.AMIs)).To(Equal(5))
315315
Expect(nodeClass.Status.AMIs).To(ContainElements([]v1.AMI{
316316
{
317317
Name: "amd64-standard",
@@ -351,6 +351,22 @@ var _ = Describe("NodeClass AMI Status Controller", func() {
351351
},
352352
},
353353
},
354+
// Note: Bottlerocket uses the same AMI for standard and neuron
355+
{
356+
Name: "amd64-standard",
357+
ID: "ami-amd64-standard",
358+
Requirements: []corev1.NodeSelectorRequirement{
359+
{
360+
Key: corev1.LabelArchStable,
361+
Operator: corev1.NodeSelectorOpIn,
362+
Values: []string{karpv1.ArchitectureAmd64},
363+
},
364+
{
365+
Key: v1.LabelInstanceAcceleratorCount,
366+
Operator: corev1.NodeSelectorOpExists,
367+
},
368+
},
369+
},
354370
{
355371
Name: "amd64-nvidia",
356372
ID: "ami-amd64-nvidia",
@@ -468,7 +484,7 @@ var _ = Describe("NodeClass AMI Status Controller", func() {
468484
ExpectObjectReconciled(ctx, env.Client, controller, nodeClass)
469485
nodeClass = ExpectExists(ctx, env.Client, nodeClass)
470486

471-
Expect(len(nodeClass.Status.AMIs)).To(Equal(2))
487+
Expect(len(nodeClass.Status.AMIs)).To(Equal(3))
472488
Expect(nodeClass.Status.AMIs).To(ContainElements([]v1.AMI{
473489
{
474490
Name: "arm64-standard",

pkg/providers/amifamily/bootstrap/bottlerocketsettings.go

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ type BottlerocketKubernetes struct {
7979
ClusterDomain *string `toml:"cluster-domain,omitempty"`
8080
SeccompDefault *bool `toml:"seccomp-default,omitempty"`
8181
PodPidsLimit *int `toml:"pod-pids-limit,omitempty"`
82+
DeviceOwnershipFromSecurityContext *bool `toml:"device-ownership-from-security-context,omitempty"`
8283
}
8384

8485
type BottlerocketStaticPod struct {

pkg/providers/amifamily/bottlerocket.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (b Bottlerocket) DescribeImageQuery(ctx context.Context, ssmProvider ssm.Pr
4444
trimmedAMIVersion := strings.TrimLeft(amiVersion, "v")
4545
ids := map[string][]Variant{}
4646
for path, variants := range map[string][]Variant{
47-
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s/x86_64/%s/image_id", k8sVersion, trimmedAMIVersion): {VariantStandard},
47+
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s/x86_64/%s/image_id", k8sVersion, trimmedAMIVersion): {VariantStandard, VariantNeuron},
4848
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s/arm64/%s/image_id", k8sVersion, trimmedAMIVersion): {VariantStandard},
4949
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s-nvidia/x86_64/%s/image_id", k8sVersion, trimmedAMIVersion): {VariantNvidia},
5050
fmt.Sprintf("/aws/service/bottlerocket/aws-k8s-%s-nvidia/arm64/%s/image_id", k8sVersion, trimmedAMIVersion): {VariantNvidia},

pkg/providers/amifamily/suite_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ var _ = Describe("AMIProvider", func() {
169169
}
170170
amis, err := awsEnv.AMIProvider.List(ctx, nodeClass)
171171
Expect(err).ToNot(HaveOccurred())
172-
Expect(amis).To(HaveLen(4))
172+
Expect(amis).To(HaveLen(5))
173173
})
174174
It("should succeed to resolve AMIs (Windows2019)", func() {
175175
nodeClass.Spec.AMISelectorTerms = []v1.AMISelectorTerm{{Alias: "windows2019@latest"}}
@@ -304,7 +304,7 @@ var _ = Describe("AMIProvider", func() {
304304
// Only 4 of the requirements sets for the SSM aliases will resolve
305305
amis, err := awsEnv.AMIProvider.List(ctx, nodeClass)
306306
Expect(err).ToNot(HaveOccurred())
307-
Expect(amis).To(HaveLen(3))
307+
Expect(amis).To(HaveLen(4))
308308
})
309309
})
310310
Context("AMI Tag Requirements", func() {

website/content/en/preview/concepts/nodeclasses.md

+14
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,20 @@ cluster-name = 'cluster'
13531353
'memory.available' = '12%%'
13541354
```
13551355

1356+
#### Device ownership in Bottlerocket
1357+
1358+
Bottlerocket `v1.30.0+` supports device ownership using the [security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) provided in the Kubernetes specfile. To enable this, you will need the following user-data configurations:
1359+
1360+
```toml
1361+
[settings]
1362+
[settings.kubernetes]
1363+
device-ownership-from-security-context = true
1364+
```
1365+
1366+
This allows the container to take ownership of devices allocated to the pod via device-plugins based on the `runAsUser` and `runAsGroup` values provided in the spec. For more details on this, see the [Kubernetes documentation](https://kubernetes.io/blog/2021/11/09/non-root-containers-and-devices/)
1367+
1368+
This setting helps you enable Neuron workloads on Bottlerocket instances. See [Accelerators/GPU Resources]({{< ref "./scheduling#acceleratorsgpu-resources" >}}) for more details.
1369+
13561370
### Windows2019/Windows2022
13571371

13581372
* Your UserData must be specified as PowerShell commands.

0 commit comments

Comments
 (0)