Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InstanceOptions with LocalDiskStrategy #1688

Merged
merged 10 commits into from
Feb 27, 2024
4 changes: 2 additions & 2 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 @@ -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
25 changes: 24 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,25 @@ 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.
type LocalStorageStrategy string

const (
// LocalStorageRAID0 will create a single raid0 volume from any local disks
LocalStorageRAID0 LocalStorageStrategy = "RAID0"
cartermckinnon marked this conversation as resolved.
Show resolved Hide resolved

// 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.

14 changes: 14 additions & 0 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 @@ -74,6 +75,19 @@ func (c *initCmd) Run(log *zap.Logger, opts *cli.GlobalOptions) error {
return err
}

log.Info("Configuring system aspects...")
cartermckinnon marked this conversation as resolved.
Show resolved Hide resolved
aspects := []system.SystemAspect{
system.NewLocalDiskAspect(),
}
for _, aspect := range aspects {
nameField := zap.String("name", aspect.Name())
log.Info("Configuring system aspect..", nameField)
if err := aspect.Configure(nodeConfig); err != nil {
return err
}
log.Info("Configured system aspect", nameField)
}

log.Info("Creating daemon manager..")
daemonManager, err := daemon.NewDaemonManager()
if err != nil {
Expand Down
51 changes: 42 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,75 @@ 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.
type: string
required:
- strategy
type: object
required:
- localStorage
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
34 changes: 33 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,26 @@ _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)

#### NodeConfig

NodeConfig is the primary configuration object for `nodeadm`.
Expand All @@ -68,5 +99,6 @@ _Appears in:_
| Field | Description |
| --- | --- |
| `cluster` _[ClusterDetails](#clusterdetails)_ | |
| `kubelet` _[KubeletOptions](#kubeletoptions)_ | |
| `containerd` _[ContainerdOptions](#containerdoptions)_ | |
| `instance` _[InstanceOptions](#instanceoptions)_ | |
| `kubelet` _[KubeletOptions](#kubeletoptions)_ | |
Loading
Loading