Skip to content

Commit 476eb43

Browse files
committed
feat: adds nodeadm type
1 parent 4eade90 commit 476eb43

25 files changed

+3182
-239
lines changed

bootstrap/eks/PROJECT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ resources:
1515
- group: bootstrap
1616
kind: EKSConfigTemplate
1717
version: v1beta2
18-
version: "2"
18+
version: "3"

bootstrap/eks/api/v1beta2/eksconfig_types.go

Lines changed: 0 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -110,203 +110,6 @@ type EKSConfigStatus struct {
110110
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
111111
}
112112

113-
// Encoding specifies the cloud-init file encoding.
114-
// +kubebuilder:validation:Enum=base64;gzip;gzip+base64
115-
type Encoding string
116-
117-
const (
118-
// Base64 implies the contents of the file are encoded as base64.
119-
Base64 Encoding = "base64"
120-
// Gzip implies the contents of the file are encoded with gzip.
121-
Gzip Encoding = "gzip"
122-
// GzipBase64 implies the contents of the file are first base64 encoded and then gzip encoded.
123-
GzipBase64 Encoding = "gzip+base64"
124-
)
125-
126-
// File defines the input for generating write_files in cloud-init.
127-
type File struct {
128-
// Path specifies the full path on disk where to store the file.
129-
Path string `json:"path"`
130-
131-
// Owner specifies the ownership of the file, e.g. "root:root".
132-
// +optional
133-
Owner string `json:"owner,omitempty"`
134-
135-
// Permissions specifies the permissions to assign to the file, e.g. "0640".
136-
// +optional
137-
Permissions string `json:"permissions,omitempty"`
138-
139-
// Encoding specifies the encoding of the file contents.
140-
// +optional
141-
Encoding Encoding `json:"encoding,omitempty"`
142-
143-
// Append specifies whether to append Content to existing file if Path exists.
144-
// +optional
145-
Append bool `json:"append,omitempty"`
146-
147-
// Content is the actual content of the file.
148-
// +optional
149-
Content string `json:"content,omitempty"`
150-
151-
// ContentFrom is a referenced source of content to populate the file.
152-
// +optional
153-
ContentFrom *FileSource `json:"contentFrom,omitempty"`
154-
}
155-
156-
// FileSource is a union of all possible external source types for file data.
157-
// Only one field may be populated in any given instance. Developers adding new
158-
// sources of data for target systems should add them here.
159-
type FileSource struct {
160-
// Secret represents a secret that should populate this file.
161-
Secret SecretFileSource `json:"secret"`
162-
}
163-
164-
// SecretFileSource adapts a Secret into a FileSource.
165-
//
166-
// The contents of the target Secret's Data field will be presented
167-
// as files using the keys in the Data field as the file names.
168-
type SecretFileSource struct {
169-
// Name of the secret in the KubeadmBootstrapConfig's namespace to use.
170-
Name string `json:"name"`
171-
172-
// Key is the key in the secret's data map for this value.
173-
Key string `json:"key"`
174-
}
175-
176-
// PasswdSource is a union of all possible external source types for passwd data.
177-
// Only one field may be populated in any given instance. Developers adding new
178-
// sources of data for target systems should add them here.
179-
type PasswdSource struct {
180-
// Secret represents a secret that should populate this password.
181-
Secret SecretPasswdSource `json:"secret"`
182-
}
183-
184-
// SecretPasswdSource adapts a Secret into a PasswdSource.
185-
//
186-
// The contents of the target Secret's Data field will be presented
187-
// as passwd using the keys in the Data field as the file names.
188-
type SecretPasswdSource struct {
189-
// Name of the secret in the KubeadmBootstrapConfig's namespace to use.
190-
Name string `json:"name"`
191-
192-
// Key is the key in the secret's data map for this value.
193-
Key string `json:"key"`
194-
}
195-
196-
// User defines the input for a generated user in cloud-init.
197-
type User struct {
198-
// Name specifies the username
199-
Name string `json:"name"`
200-
201-
// Gecos specifies the gecos to use for the user
202-
// +optional
203-
Gecos *string `json:"gecos,omitempty"`
204-
205-
// Groups specifies the additional groups for the user
206-
// +optional
207-
Groups *string `json:"groups,omitempty"`
208-
209-
// HomeDir specifies the home directory to use for the user
210-
// +optional
211-
HomeDir *string `json:"homeDir,omitempty"`
212-
213-
// Inactive specifies whether to mark the user as inactive
214-
// +optional
215-
Inactive *bool `json:"inactive,omitempty"`
216-
217-
// Shell specifies the user's shell
218-
// +optional
219-
Shell *string `json:"shell,omitempty"`
220-
221-
// Passwd specifies a hashed password for the user
222-
// +optional
223-
Passwd *string `json:"passwd,omitempty"`
224-
225-
// PasswdFrom is a referenced source of passwd to populate the passwd.
226-
// +optional
227-
PasswdFrom *PasswdSource `json:"passwdFrom,omitempty"`
228-
229-
// PrimaryGroup specifies the primary group for the user
230-
// +optional
231-
PrimaryGroup *string `json:"primaryGroup,omitempty"`
232-
233-
// LockPassword specifies if password login should be disabled
234-
// +optional
235-
LockPassword *bool `json:"lockPassword,omitempty"`
236-
237-
// Sudo specifies a sudo role for the user
238-
// +optional
239-
Sudo *string `json:"sudo,omitempty"`
240-
241-
// SSHAuthorizedKeys specifies a list of ssh authorized keys for the user
242-
// +optional
243-
SSHAuthorizedKeys []string `json:"sshAuthorizedKeys,omitempty"`
244-
}
245-
246-
// NTP defines input for generated ntp in cloud-init.
247-
type NTP struct {
248-
// Servers specifies which NTP servers to use
249-
// +optional
250-
Servers []string `json:"servers,omitempty"`
251-
252-
// Enabled specifies whether NTP should be enabled
253-
// +optional
254-
Enabled *bool `json:"enabled,omitempty"`
255-
}
256-
257-
// DiskSetup defines input for generated disk_setup and fs_setup in cloud-init.
258-
type DiskSetup struct {
259-
// Partitions specifies the list of the partitions to setup.
260-
// +optional
261-
Partitions []Partition `json:"partitions,omitempty"`
262-
263-
// Filesystems specifies the list of file systems to setup.
264-
// +optional
265-
Filesystems []Filesystem `json:"filesystems,omitempty"`
266-
}
267-
268-
// Partition defines how to create and layout a partition.
269-
type Partition struct {
270-
// Device is the name of the device.
271-
Device string `json:"device"`
272-
// Layout specifies the device layout.
273-
// If it is true, a single partition will be created for the entire device.
274-
// When layout is false, it means don't partition or ignore existing partitioning.
275-
Layout bool `json:"layout"`
276-
// Overwrite describes whether to skip checks and create the partition if a partition or filesystem is found on the device.
277-
// Use with caution. Default is 'false'.
278-
// +optional
279-
Overwrite *bool `json:"overwrite,omitempty"`
280-
// TableType specifies the tupe of partition table. The following are supported:
281-
// 'mbr': default and setups a MS-DOS partition table
282-
// 'gpt': setups a GPT partition table
283-
// +optional
284-
TableType *string `json:"tableType,omitempty"`
285-
}
286-
287-
// Filesystem defines the file systems to be created.
288-
type Filesystem struct {
289-
// Device specifies the device name
290-
Device string `json:"device"`
291-
// Filesystem specifies the file system type.
292-
Filesystem string `json:"filesystem"`
293-
// Label specifies the file system label to be used. If set to None, no label is used.
294-
Label string `json:"label"`
295-
// Partition specifies the partition to use. The valid options are: "auto|any", "auto", "any", "none", and <NUM>, where NUM is the actual partition number.
296-
// +optional
297-
Partition *string `json:"partition,omitempty"`
298-
// Overwrite defines whether or not to overwrite any existing filesystem.
299-
// If true, any pre-existing file system will be destroyed. Use with Caution.
300-
// +optional
301-
Overwrite *bool `json:"overwrite,omitempty"`
302-
// ExtraOpts defined extra options to add to the command for creating the file system.
303-
// +optional
304-
ExtraOpts []string `json:"extraOpts,omitempty"`
305-
}
306-
307-
// MountPoints defines input for generated mounts in cloud-init.
308-
type MountPoints []string
309-
310113
// +kubebuilder:object:root=true
311114
// +kubebuilder:resource:path=eksconfigs,scope=Namespaced,categories=cluster-api,shortName=eksc
312115
// +kubebuilder:storageversion
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
package v1beta2
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/apimachinery/pkg/runtime"
6+
7+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
8+
)
9+
10+
// NodeadmConfigSpec defines the desired state of NodeadmConfig.
11+
type NodeadmConfigSpec struct {
12+
// Kubelet contains options for kubelet.
13+
// +optional
14+
Kubelet *KubeletOptions `json:"kubelet,omitempty"`
15+
16+
// Containerd contains options for containerd.
17+
// +optional
18+
Containerd *ContainerdOptions `json:"containerd,omitempty"`
19+
20+
// FeatureGates holds key-value pairs to enable or disable application features.
21+
// +optional
22+
FeatureGates map[Feature]bool `json:"featureGates,omitempty"`
23+
24+
// PreNodeadmCommands specifies extra commands to run before bootstrapping nodes.
25+
// +optional
26+
PreNodeadmCommands []string `json:"preNodeadmCommands,omitempty"`
27+
28+
// Files specifies extra files to be passed to user_data upon creation.
29+
// +optional
30+
Files []File `json:"files,omitempty"`
31+
32+
// Users specifies extra users to add.
33+
// +optional
34+
Users []User `json:"users,omitempty"`
35+
36+
// NTP specifies NTP configuration.
37+
// +optional
38+
NTP *NTP `json:"ntp,omitempty"`
39+
40+
// DiskSetup specifies options for the creation of partition tables and file systems on devices.
41+
// +optional
42+
DiskSetup *DiskSetup `json:"diskSetup,omitempty"`
43+
44+
// Mounts specifies a list of mount points to be setup.
45+
// +optional
46+
Mounts []MountPoints `json:"mounts,omitempty"`
47+
}
48+
49+
// KubeletOptions are additional parameters passed to kubelet.
50+
type KubeletOptions struct {
51+
// Config is a KubeletConfiguration that will be merged with the defaults.
52+
// +optional
53+
// +kubebuilder:pruning:PreserveUnknownFields
54+
Config *runtime.RawExtension `json:"config,omitempty"`
55+
56+
// Flags are command-line kubelet arguments that will be appended to the defaults.
57+
// +optional
58+
Flags []string `json:"flags,omitempty"`
59+
}
60+
61+
// ContainerdOptions are additional parameters passed to containerd.
62+
type ContainerdOptions struct {
63+
// Config is an inline containerd configuration TOML that will be merged with the defaults.
64+
// +optional
65+
Config string `json:"config,omitempty"`
66+
67+
// BaseRuntimeSpec is the OCI runtime specification upon which all containers will be based.
68+
// +optional
69+
// +kubebuilder:pruning:PreserveUnknownFields
70+
BaseRuntimeSpec *runtime.RawExtension `json:"baseRuntimeSpec,omitempty"`
71+
}
72+
73+
// Feature specifies which feature gate should be toggled.
74+
// +kubebuilder:validation:Enum=InstanceIdNodeName;FastImagePull
75+
type Feature string
76+
77+
const (
78+
// FeatureInstanceIDNodeName will use EC2 instance ID as node name.
79+
FeatureInstanceIDNodeName Feature = "InstanceIdNodeName"
80+
// FeatureFastImagePull enables a parallel image pull for container images.
81+
FeatureFastImagePull Feature = "FastImagePull"
82+
)
83+
84+
// GetConditions returns the observations of the operational state of the NodeadmConfig resource.
85+
func (r *NodeadmConfig) GetConditions() clusterv1.Conditions {
86+
return r.Status.Conditions
87+
}
88+
89+
// SetConditions sets the underlying service state of the NodeadmConfig to the predescribed clusterv1.Conditions.
90+
func (r *NodeadmConfig) SetConditions(conditions clusterv1.Conditions) {
91+
r.Status.Conditions = conditions
92+
}
93+
94+
// NodeadmConfigStatus defines the observed state of NodeadmConfig.
95+
type NodeadmConfigStatus struct {
96+
// Ready indicates the BootstrapData secret is ready to be consumed.
97+
// +optional
98+
Ready bool `json:"ready,omitempty"`
99+
100+
// DataSecretName is the name of the secret that stores the bootstrap data script.
101+
// +optional
102+
DataSecretName *string `json:"dataSecretName,omitempty"`
103+
104+
// FailureReason will be set on non-retryable errors.
105+
// +optional
106+
FailureReason string `json:"failureReason,omitempty"`
107+
108+
// FailureMessage will be set on non-retryable errors.
109+
// +optional
110+
FailureMessage string `json:"failureMessage,omitempty"`
111+
112+
// ObservedGeneration is the latest generation observed by the controller.
113+
// +optional
114+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
115+
116+
// Conditions defines current service state of the NodeadmConfig.
117+
// +optional
118+
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
119+
}
120+
121+
// +kubebuilder:object:root=true
122+
// +kubebuilder:subresource:status
123+
124+
// NodeadmConfig is the Schema for the nodeadmconfigs API.
125+
type NodeadmConfig struct {
126+
metav1.TypeMeta `json:",inline"`
127+
metav1.ObjectMeta `json:"metadata,omitempty"`
128+
129+
Spec NodeadmConfigSpec `json:"spec,omitempty"`
130+
Status NodeadmConfigStatus `json:"status,omitempty"`
131+
}
132+
133+
// +kubebuilder:object:root=true
134+
135+
// NodeadmConfigList contains a list of NodeadmConfig.
136+
type NodeadmConfigList struct {
137+
metav1.TypeMeta `json:",inline"`
138+
metav1.ListMeta `json:"metadata,omitempty"`
139+
Items []NodeadmConfig `json:"items"`
140+
}
141+
142+
func init() {
143+
SchemeBuilder.Register(&NodeadmConfig{}, &NodeadmConfigList{})
144+
}

0 commit comments

Comments
 (0)