Skip to content

Commit

Permalink
Add InstanceOptions with LocalDiskStrategy (awslabs#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermckinnon authored and atmosx committed Jun 18, 2024
1 parent 65b6ef4 commit f5b1312
Show file tree
Hide file tree
Showing 17 changed files with 364 additions and 34 deletions.
6 changes: 3 additions & 3 deletions nodeadm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ generate: generate-code generate-doc ## Generate code and documentation.
.PHONY: generate-code
generate-code: controller-gen conversion-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object paths="./..."
$(CONVERSION_GEN) --input-dirs="./internal/api/bridge" --output-file-base=zz_generated.conversion --go-header-file=/dev/null -v0
$(CONVERSION_GEN) --input-dirs="./internal/api/bridge" --output-file-base=zz_generated.conversion --output-base="./" --go-header-file=/dev/null -v0

.PHONY: generate-doc
generate-doc: crd-ref-docs
Expand Down Expand Up @@ -102,7 +102,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
KUSTOMIZE_VERSION ?= v5.0.1
CONTROLLER_TOOLS_VERSION ?= v0.12.0
CODE_GENERATOR_VERSION ?= v0.28.1
CRD_REF_DOCS_VERSION ?= v0.0.10
CRD_REF_DOCS_VERSION ?= cf959ab94ea543cb8efd25dc35081880b7ca6a81

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

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

.PHONY: crd-ref-docs
crd-ref-docs: $(CRD_REF_DOCS) ## Download conversion-gen locally if necessary.
crd-ref-docs: $(CRD_REF_DOCS) ## Download crd-ref-docs locally if necessary.
$(CRD_REF_DOCS): $(LOCALBIN)
test -s $(LOCALBIN)/crd-ref-docs || \
GOBIN=$(LOCALBIN) go install github.com/elastic/crd-ref-docs@$(CRD_REF_DOCS_VERSION)
Expand Down
1 change: 1 addition & 0 deletions nodeadm/api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// +kubebuilder:object:generate=true
// +groupName=node.eks.aws
// +kubebuilder:validation:Optional
package v1alpha1

import (
Expand Down
26 changes: 25 additions & 1 deletion nodeadm/api/v1alpha1/nodeconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ type NodeConfigList struct {

type NodeConfigSpec struct {
Cluster ClusterDetails `json:"cluster,omitempty"`
Kubelet KubeletOptions `json:"kubelet,omitempty"`
Containerd ContainerdOptions `json:"containerd,omitempty"`
Instance InstanceOptions `json:"instance,omitempty"`
Kubelet KubeletOptions `json:"kubelet,omitempty"`
}

// ClusterDetails contains the coordinates of your EKS cluster.
Expand Down Expand Up @@ -74,3 +75,26 @@ type ContainerdOptions struct {
// by the default configuration file.
Config string `json:"config,omitempty"`
}

// InstanceOptions determines how the node's operating system and devices are configured.
type InstanceOptions struct {
LocalStorage LocalStorageOptions `json:"localStorage,omitempty"`
}

// LocalStorageOptions control how [EC2 instance stores](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html)
// are used when available.
type LocalStorageOptions struct {
Strategy LocalStorageStrategy `json:"strategy,omitempty"`
}

// LocalStorageStrategy specifies how to handle an instance's local storage devices.
// +kubebuilder:validation:Enum={RAID0, Mount}
type LocalStorageStrategy string

const (
// LocalStorageRAID0 will create a single raid0 volume from any local disks
LocalStorageRAID0 LocalStorageStrategy = "RAID0"

// LocalStorageMount will mount each local disk individually
LocalStorageMount LocalStorageStrategy = "Mount"
)
34 changes: 33 additions & 1 deletion nodeadm/api/v1alpha1/zz_generated.deepcopy.go

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

18 changes: 16 additions & 2 deletions nodeadm/cmd/nodeadm/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/containerd"
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/daemon"
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/kubelet"
"github.com/awslabs/amazon-eks-ami/nodeadm/internal/system"
)

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

log.Info("Setting up daemons..")
aspects := []system.SystemAspect{
system.NewLocalDiskAspect(),
}

daemons := []daemon.Daemon{
containerd.NewContainerdDaemon(daemonManager),
kubelet.NewKubeletDaemon(daemonManager),
}

if !slices.Contains(c.skipPhases, configPhase) {
log.Info("Configuring daemons...")
for _, daemon := range daemons {
if len(c.daemons) > 0 && !slices.Contains(c.daemons, daemon.Name()) {
continue
}
nameField := zap.String("name", daemon.Name())

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

if !slices.Contains(c.skipPhases, runPhase) {
log.Info("Setting up system aspects...")
for _, aspect := range aspects {
nameField := zap.String("name", aspect.Name())
log.Info("Setting up system aspect..", nameField)
if err := aspect.Setup(nodeConfig); err != nil {
return err
}
log.Info("Set up system aspect", nameField)
}
for _, daemon := range daemons {
if len(c.daemons) > 0 && !slices.Contains(c.daemons, daemon.Name()) {
continue
Expand Down
50 changes: 41 additions & 9 deletions nodeadm/crds/node.eks.aws_nodeconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
- name: v1alpha1
schema:
openAPIV3Schema:
description: NodeConfig is the Schema for the nodeconfigs API
description: NodeConfig is the primary configuration object for `nodeadm`.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -34,42 +34,74 @@ spec:
spec:
properties:
cluster:
description: ClusterDetails contains the coordinates of your EKS cluster.
These details can be found using the [DescribeCluster API](https://docs.aws.amazon.com/eks/latest/APIReference/API_DescribeCluster.html).
properties:
apiServerEndpoint:
description: APIServerEndpoint is the URL of your EKS cluster's
kube-apiserver.
type: string
certificateAuthority:
description: CertificateAuthority is a base64-encoded string of
your cluster's certificate authority chain.
format: byte
type: string
cidr:
description: CIDR is your cluster's Pod IP CIDR. This value is
used to infer your cluster's DNS address.
type: string
enableOutpost:
description: EnableOutpost determines how your node is configured
when running on an AWS Outpost.
type: boolean
id:
description: ID is an identifier for your cluster; this is only
used when your node is running on an AWS Outpost.
type: string
name:
description: Name is the name of your EKS cluster
type: string
type: object
containerd:
description: ContainerdOptions are additional parameters passed to
`containerd`.
properties:
config:
description: Config is an inline containerd config toml document
that can be provided by the user to override default generated
configurations https://github.com/containerd/containerd/blob/main/docs/man/containerd-config.toml.5.md
description: 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.
type: string
type: object
instance:
description: InstanceOptions determines how the node's operating system
and devices are configured.
properties:
localStorage:
description: LocalStorageOptions control how [EC2 instance stores](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html)
are used when available.
properties:
strategy:
description: LocalStorageStrategy specifies how to handle
an instance's local storage devices.
enum:
- RAID0
- Mount
type: string
type: object
type: object
kubelet:
description: KubeletOptions are additional parameters passed to `kubelet`.
properties:
config:
additionalProperties:
type: object
x-kubernetes-preserve-unknown-fields: true
description: Config is a kubelet config that can be provided by
the user to override default generated configurations https://kubernetes.io/docs/reference/config-api/kubelet-config.v1/
description: Config is a [`KubeletConfiguration`](https://kubernetes.io/docs/reference/config-api/kubelet-config.v1/)
that will be merged with the defaults.
type: object
flags:
description: Flags is a list of command-line kubelet arguments.
These arguments are amended to the generated defaults, and therefore
will act as overrides https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
description: Flags are [command-line `kubelet`` arguments](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/).
that will be appended to the defaults.
items:
type: string
type: array
Expand Down
37 changes: 36 additions & 1 deletion nodeadm/doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ _Appears in:_
| --- | --- |
| `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. |

#### InstanceOptions

InstanceOptions determines how the node's operating system and devices are configured.

_Appears in:_
- [NodeConfigSpec](#nodeconfigspec)

| Field | Description |
| --- | --- |
| `localStorage` _[LocalStorageOptions](#localstorageoptions)_ | |

#### KubeletOptions

KubeletOptions are additional parameters passed to `kubelet`.
Expand All @@ -47,6 +58,29 @@ _Appears in:_
| `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. |
| `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. |

#### LocalStorageOptions

LocalStorageOptions control how [EC2 instance stores](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html) are used when available.

_Appears in:_
- [InstanceOptions](#instanceoptions)

| Field | Description |
| --- | --- |
| `strategy` _[LocalStorageStrategy](#localstoragestrategy)_ | |

#### LocalStorageStrategy

_Underlying type:_ _string_

LocalStorageStrategy specifies how to handle an instance's local storage devices.

_Appears in:_
- [LocalStorageOptions](#localstorageoptions)

.Validation:
- Enum: [RAID0 Mount]

#### NodeConfig

NodeConfig is the primary configuration object for `nodeadm`.
Expand All @@ -68,5 +102,6 @@ _Appears in:_
| Field | Description |
| --- | --- |
| `cluster` _[ClusterDetails](#clusterdetails)_ | |
| `kubelet` _[KubeletOptions](#kubeletoptions)_ | |
| `containerd` _[ContainerdOptions](#containerdoptions)_ | |
| `instance` _[InstanceOptions](#instanceoptions)_ | |
| `kubelet` _[KubeletOptions](#kubeletoptions)_ | |
7 changes: 7 additions & 0 deletions nodeadm/doc/templates/type.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ _Appears in:_
{{- end }}
{{- end }}

{{ if $type.Validation -}}
.Validation:
{{- range $type.Validation }}
- {{ . }}
{{- end }}
{{- end }}

{{ if $type.Members -}}
| Field | Description |
| --- | --- |
Expand Down
Loading

0 comments on commit f5b1312

Please sign in to comment.