Skip to content

Commit bf4c549

Browse files
Add InstanceOptions with LocalDiskStrategy (#1688)
1 parent 02bc7c2 commit bf4c549

File tree

17 files changed

+364
-34
lines changed

17 files changed

+364
-34
lines changed

nodeadm/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ generate: generate-code generate-doc ## Generate code and documentation.
4949
.PHONY: generate-code
5050
generate-code: controller-gen conversion-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
5151
$(CONTROLLER_GEN) object paths="./..."
52-
$(CONVERSION_GEN) --input-dirs="./internal/api/bridge" --output-file-base=zz_generated.conversion --go-header-file=/dev/null -v0
52+
$(CONVERSION_GEN) --input-dirs="./internal/api/bridge" --output-file-base=zz_generated.conversion --output-base="./" --go-header-file=/dev/null -v0
5353

5454
.PHONY: generate-doc
5555
generate-doc: crd-ref-docs
@@ -102,7 +102,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
102102
KUSTOMIZE_VERSION ?= v5.0.1
103103
CONTROLLER_TOOLS_VERSION ?= v0.12.0
104104
CODE_GENERATOR_VERSION ?= v0.28.1
105-
CRD_REF_DOCS_VERSION ?= v0.0.10
105+
CRD_REF_DOCS_VERSION ?= cf959ab94ea543cb8efd25dc35081880b7ca6a81
106106

107107
tools: kustomize controller-gen conversion-gen crd-ref-docs ## Install the toolchain.
108108

@@ -129,7 +129,7 @@ $(CONVERSION_GEN): $(LOCALBIN)
129129
GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/conversion-gen@$(CODE_GENERATOR_VERSION)
130130

131131
.PHONY: crd-ref-docs
132-
crd-ref-docs: $(CRD_REF_DOCS) ## Download conversion-gen locally if necessary.
132+
crd-ref-docs: $(CRD_REF_DOCS) ## Download crd-ref-docs locally if necessary.
133133
$(CRD_REF_DOCS): $(LOCALBIN)
134134
test -s $(LOCALBIN)/crd-ref-docs || \
135135
GOBIN=$(LOCALBIN) go install github.com/elastic/crd-ref-docs@$(CRD_REF_DOCS_VERSION)

nodeadm/api/v1alpha1/groupversion_info.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// +kubebuilder:object:generate=true
22
// +groupName=node.eks.aws
3+
// +kubebuilder:validation:Optional
34
package v1alpha1
45

56
import (

nodeadm/api/v1alpha1/nodeconfig_types.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ type NodeConfigList struct {
3030

3131
type NodeConfigSpec struct {
3232
Cluster ClusterDetails `json:"cluster,omitempty"`
33-
Kubelet KubeletOptions `json:"kubelet,omitempty"`
3433
Containerd ContainerdOptions `json:"containerd,omitempty"`
34+
Instance InstanceOptions `json:"instance,omitempty"`
35+
Kubelet KubeletOptions `json:"kubelet,omitempty"`
3536
}
3637

3738
// ClusterDetails contains the coordinates of your EKS cluster.
@@ -74,3 +75,26 @@ type ContainerdOptions struct {
7475
// by the default configuration file.
7576
Config string `json:"config,omitempty"`
7677
}
78+
79+
// InstanceOptions determines how the node's operating system and devices are configured.
80+
type InstanceOptions struct {
81+
LocalStorage LocalStorageOptions `json:"localStorage,omitempty"`
82+
}
83+
84+
// LocalStorageOptions control how [EC2 instance stores](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html)
85+
// are used when available.
86+
type LocalStorageOptions struct {
87+
Strategy LocalStorageStrategy `json:"strategy,omitempty"`
88+
}
89+
90+
// LocalStorageStrategy specifies how to handle an instance's local storage devices.
91+
// +kubebuilder:validation:Enum={RAID0, Mount}
92+
type LocalStorageStrategy string
93+
94+
const (
95+
// LocalStorageRAID0 will create a single raid0 volume from any local disks
96+
LocalStorageRAID0 LocalStorageStrategy = "RAID0"
97+
98+
// LocalStorageMount will mount each local disk individually
99+
LocalStorageMount LocalStorageStrategy = "Mount"
100+
)

nodeadm/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodeadm/cmd/nodeadm/init/init.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/containerd"
1919
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/daemon"
2020
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/kubelet"
21+
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/system"
2122
)
2223

2324
const (
@@ -81,20 +82,24 @@ func (c *initCmd) Run(log *zap.Logger, opts *cli.GlobalOptions) error {
8182
}
8283
defer daemonManager.Close()
8384

84-
log.Info("Setting up daemons..")
85+
aspects := []system.SystemAspect{
86+
system.NewLocalDiskAspect(),
87+
}
88+
8589
daemons := []daemon.Daemon{
8690
containerd.NewContainerdDaemon(daemonManager),
8791
kubelet.NewKubeletDaemon(daemonManager),
8892
}
8993

9094
if !slices.Contains(c.skipPhases, configPhase) {
95+
log.Info("Configuring daemons...")
9196
for _, daemon := range daemons {
9297
if len(c.daemons) > 0 && !slices.Contains(c.daemons, daemon.Name()) {
9398
continue
9499
}
95100
nameField := zap.String("name", daemon.Name())
96101

97-
log.Info("Configuring daemon..", nameField)
102+
log.Info("Configuring daemon...", nameField)
98103
if err := daemon.Configure(nodeConfig); err != nil {
99104
return err
100105
}
@@ -103,6 +108,15 @@ func (c *initCmd) Run(log *zap.Logger, opts *cli.GlobalOptions) error {
103108
}
104109

105110
if !slices.Contains(c.skipPhases, runPhase) {
111+
log.Info("Setting up system aspects...")
112+
for _, aspect := range aspects {
113+
nameField := zap.String("name", aspect.Name())
114+
log.Info("Setting up system aspect..", nameField)
115+
if err := aspect.Setup(nodeConfig); err != nil {
116+
return err
117+
}
118+
log.Info("Set up system aspect", nameField)
119+
}
106120
for _, daemon := range daemons {
107121
if len(c.daemons) > 0 && !slices.Contains(c.daemons, daemon.Name()) {
108122
continue

nodeadm/crds/node.eks.aws_nodeconfigs.yaml

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
- name: v1alpha1
1818
schema:
1919
openAPIV3Schema:
20-
description: NodeConfig is the Schema for the nodeconfigs API
20+
description: NodeConfig is the primary configuration object for `nodeadm`.
2121
properties:
2222
apiVersion:
2323
description: 'APIVersion defines the versioned schema of this representation
@@ -34,42 +34,74 @@ spec:
3434
spec:
3535
properties:
3636
cluster:
37+
description: ClusterDetails contains the coordinates of your EKS cluster.
38+
These details can be found using the [DescribeCluster API](https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeCluster.html).
3739
properties:
3840
apiServerEndpoint:
41+
description: APIServerEndpoint is the URL of your EKS cluster's
42+
kube-apiserver.
3943
type: string
4044
certificateAuthority:
45+
description: CertificateAuthority is a base64-encoded string of
46+
your cluster's certificate authority chain.
4147
format: byte
4248
type: string
4349
cidr:
50+
description: CIDR is your cluster's Pod IP CIDR. This value is
51+
used to infer your cluster's DNS address.
4452
type: string
4553
enableOutpost:
54+
description: EnableOutpost determines how your node is configured
55+
when running on an AWS Outpost.
4656
type: boolean
4757
id:
58+
description: ID is an identifier for your cluster; this is only
59+
used when your node is running on an AWS Outpost.
4860
type: string
4961
name:
62+
description: Name is the name of your EKS cluster
5063
type: string
5164
type: object
5265
containerd:
66+
description: ContainerdOptions are additional parameters passed to
67+
`containerd`.
5368
properties:
5469
config:
55-
description: Config is an inline containerd config toml document
56-
that can be provided by the user to override default generated
57-
configurations https://github.com/containerd/containerd/blob/main/docs/man/containerd-config.toml.5.md
70+
description: Config is inline [`containerd` configuration TOML](https://github.com/containerd/containerd/blob/main/docs/man/containerd-config.toml.5.md)
71+
that will be [imported](https://github.com/containerd/containerd/blob/32169d591dbc6133ef7411329b29d0c0433f8c4d/docs/man/containerd-config.toml.5.md?plain=1#L146-L154)
72+
by the default configuration file.
5873
type: string
5974
type: object
75+
instance:
76+
description: InstanceOptions determines how the node's operating system
77+
and devices are configured.
78+
properties:
79+
localStorage:
80+
description: LocalStorageOptions control how [EC2 instance stores](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html)
81+
are used when available.
82+
properties:
83+
strategy:
84+
description: LocalStorageStrategy specifies how to handle
85+
an instance's local storage devices.
86+
enum:
87+
- RAID0
88+
- Mount
89+
type: string
90+
type: object
91+
type: object
6092
kubelet:
93+
description: KubeletOptions are additional parameters passed to `kubelet`.
6194
properties:
6295
config:
6396
additionalProperties:
6497
type: object
6598
x-kubernetes-preserve-unknown-fields: true
66-
description: Config is a kubelet config that can be provided by
67-
the user to override default generated configurations https://kubernetes.io/docs/reference/config-api/kubelet-config.v1/
99+
description: Config is a [`KubeletConfiguration`](https://kubernetes.io/docs/reference/config-api/kubelet-config.v1/)
100+
that will be merged with the defaults.
68101
type: object
69102
flags:
70-
description: Flags is a list of command-line kubelet arguments.
71-
These arguments are amended to the generated defaults, and therefore
72-
will act as overrides https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
103+
description: Flags are [command-line `kubelet`` arguments](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/).
104+
that will be appended to the defaults.
73105
items:
74106
type: string
75107
type: array

nodeadm/doc/api.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ _Appears in:_
3535
| --- | --- |
3636
| `config` _string_ | Config is inline [`containerd` configuration TOML](https://github.com/containerd/containerd/blob/main/docs/man/containerd-config.toml.5.md) that will be [imported](https://github.com/containerd/containerd/blob/32169d591dbc6133ef7411329b29d0c0433f8c4d/docs/man/containerd-config.toml.5.md?plain=1#L146-L154) by the default configuration file. |
3737

38+
#### InstanceOptions
39+
40+
InstanceOptions determines how the node's operating system and devices are configured.
41+
42+
_Appears in:_
43+
- [NodeConfigSpec](#nodeconfigspec)
44+
45+
| Field | Description |
46+
| --- | --- |
47+
| `localStorage` _[LocalStorageOptions](#localstorageoptions)_ | |
48+
3849
#### KubeletOptions
3950

4051
KubeletOptions are additional parameters passed to `kubelet`.
@@ -47,6 +58,29 @@ _Appears in:_
4758
| `config` _object (keys:string, values:RawExtension)_ | Config is a [`KubeletConfiguration`](https://kubernetes.io/docs/reference/config-api/kubelet-config.v1/) that will be merged with the defaults. |
4859
| `flags` _string array_ | Flags are [command-line `kubelet`` arguments](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/). that will be appended to the defaults. |
4960

61+
#### LocalStorageOptions
62+
63+
LocalStorageOptions control how [EC2 instance stores](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html) are used when available.
64+
65+
_Appears in:_
66+
- [InstanceOptions](#instanceoptions)
67+
68+
| Field | Description |
69+
| --- | --- |
70+
| `strategy` _[LocalStorageStrategy](#localstoragestrategy)_ | |
71+
72+
#### LocalStorageStrategy
73+
74+
_Underlying type:_ _string_
75+
76+
LocalStorageStrategy specifies how to handle an instance's local storage devices.
77+
78+
_Appears in:_
79+
- [LocalStorageOptions](#localstorageoptions)
80+
81+
.Validation:
82+
- Enum: [RAID0 Mount]
83+
5084
#### NodeConfig
5185

5286
NodeConfig is the primary configuration object for `nodeadm`.
@@ -68,5 +102,6 @@ _Appears in:_
68102
| Field | Description |
69103
| --- | --- |
70104
| `cluster` _[ClusterDetails](#clusterdetails)_ | |
71-
| `kubelet` _[KubeletOptions](#kubeletoptions)_ | |
72105
| `containerd` _[ContainerdOptions](#containerdoptions)_ | |
106+
| `instance` _[InstanceOptions](#instanceoptions)_ | |
107+
| `kubelet` _[KubeletOptions](#kubeletoptions)_ | |

nodeadm/doc/templates/type.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ _Appears in:_
1515
{{- end }}
1616
{{- end }}
1717

18+
{{ if $type.Validation -}}
19+
.Validation:
20+
{{- range $type.Validation }}
21+
- {{ . }}
22+
{{- end }}
23+
{{- end }}
24+
1825
{{ if $type.Members -}}
1926
| Field | Description |
2027
| --- | --- |

0 commit comments

Comments
 (0)