k8s_cluster_api/v1beta1/infrastructure/aws/machine.rs
1use super::*;
2
3mod impls;
4
5/// AWSMachineTemplateSpec defines the desired state of AWSMachineTemplate.
6#[skip_serializing_none]
7#[derive(Clone, Debug, Default, Serialize, Deserialize, CustomResource)]
8#[serde(rename_all = "camelCase")]
9#[kube(
10 group = "infrastructure.cluster.x-k8s.io",
11 version = "v1beta1",
12 kind = "AWSMachineTemplate",
13 plural = "awsmachinetemplates"
14)]
15#[kube(namespaced)]
16#[kube(schema = "disabled")]
17pub struct AWSMachineTemplateSpec {
18 pub template: AWSMachineTemplateResource, // `json:"template"`
19}
20
21/// AWSMachineTemplateResource describes the data needed to create am AWSMachine from a template.
22#[skip_serializing_none]
23#[derive(Clone, Debug, Default, Serialize, Deserialize)]
24#[serde(rename_all = "camelCase")]
25pub struct AWSMachineTemplateResource {
26 /// Standard object's metadata.
27 /// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
28 // +optional
29 pub metadata: Option<clusterv1::ObjectMeta>, // `json:"metadata,omitempty"`
30
31 // Spec is the specification of the desired behavior of the machine.
32 pub spec: AWSMachineSpec, // `json:"spec"`
33}
34
35/// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
36#[skip_serializing_none]
37#[derive(Clone, Debug, Default, Serialize, Deserialize, CustomResource)]
38#[serde(rename_all = "camelCase")]
39#[kube(
40 group = "infrastructure.cluster.x-k8s.io",
41 version = "v1beta1",
42 kind = "AWSMachine",
43 plural = "awsmachines",
44 status = "AWSMachineStatus"
45)]
46#[kube(namespaced)]
47#[kube(schema = "disabled")]
48pub struct AWSMachineSpec {
49 /// ProviderID is the unique identifier as specified by the cloud provider.
50 #[serde(rename = "providerID")]
51 pub provider_id: Option<String>, // `json:"providerID,omitempty"`
52
53 /// InstanceID is the EC2 instance ID for this machine.
54 #[serde(rename = "instanceID")]
55 pub instance_id: Option<String>, // `json:"instanceID,omitempty"`
56
57 /// AMI is the reference to the AMI from which to create the machine instance.
58 pub ami: Option<AMIReference>, // `json:"ami,omitempty"`
59
60 /// ImageLookupFormat is the AMI naming format to look up the image for this
61 /// machine It will be ignored if an explicit AMI is set. Supports
62 /// substitutions for {{.BaseOS}} and {{.K8sVersion}} with the base OS and
63 /// kubernetes version, respectively. The BaseOS will be the value in
64 /// ImageLookupBaseOS or ubuntu (the default), and the kubernetes version as
65 /// defined by the packages produced by kubernetes/release without v as a
66 /// prefix: 1.13.0, 1.12.5-mybuild.1, or 1.17.3. For example, the default
67 /// image format of capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-* will end up
68 /// searching for AMIs that match the pattern capa-ami-ubuntu-?1.18.0-* for a
69 /// Machine that is targeting kubernetes v1.18.0 and the ubuntu base OS. See
70 /// also: https://golang.org/pkg/text/template/
71 // +optional
72 pub image_lookup_format: Option<String>, // `json:"imageLookupFormat,omitempty"`
73
74 /// ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set.
75 pub image_lookup_org: Option<String>, // `json:"imageLookupOrg,omitempty"`
76
77 /// ImageLookupBaseOS is the name of the base operating system to use for
78 /// image lookup the AMI is not set.
79 #[serde(rename = "imageLookupBaseOS")]
80 pub image_lookup_base_os: Option<String>, // `json:"imageLookupBaseOS,omitempty"`
81
82 /// InstanceType is the type of instance to create. Example: m4.xlarge
83 // +kubebuilder:validation:Required
84 // +kubebuilder:validation:MinLength:=2
85 pub instance_type: String, // `json:"instanceType"`
86
87 /// AdditionalTags is an optional set of tags to add to an instance, in addition to the ones added by default by the
88 /// AWS provider. If both the AWSCluster and the AWSMachine specify the same tag name with different values, the
89 /// AWSMachine's value takes precedence.
90 // +optional
91 pub additional_tags: Option<Tags>, // `json:"additionalTags,omitempty"`
92
93 /// IAMInstanceProfile is a name of an IAM instance profile to assign to the instance
94 // +optional
95 pub iam_instance_profile: Option<String>, // `json:"iamInstanceProfile,omitempty"`
96
97 /// PublicIP specifies whether the instance should get a public IP.
98 /// Precedence for this setting is as follows:
99 /// 1. This field if set
100 /// 2. Cluster/flavor setting
101 /// 3. Subnet default
102 // +optional
103 #[serde(rename = "publicIP")]
104 pub public_ip: Option<bool>, // `json:"publicIP,omitempty"`
105
106 /// AdditionalSecurityGroups is an array of references to security groups that should be applied to the
107 /// instance. These security groups would be set in addition to any security groups defined
108 /// at the cluster level or in the actuator. It is possible to specify either IDs of Filters. Using Filters
109 /// will cause additional requests to AWS API and if tags change the attached security groups might change too.
110 // +optional
111 #[serde(default, skip_serializing_if = "Vec::is_empty")]
112 pub additional_security_groups: Vec<types::AWSResourceReference>, //`json:"additionalSecurityGroups,omitempty"`
113
114 // FailureDomain is the failure domain unique identifier this Machine should be attached to, as defined in Cluster API.
115 // For this infrastructure provider, the ID is equivalent to an AWS Availability Zone.
116 // If multiple subnets are matched for the availability zone, the first one returned is picked.
117 pub failure_domain: Option<String>, //`json:"failureDomain,omitempty"`
118
119 /// Subnet is a reference to the subnet to use for this instance. If not specified,
120 /// the cluster subnet will be used.
121 // +optional
122 pub subnet: Option<types::AWSResourceReference>, //`json:"subnet,omitempty"`
123
124 /// SSHKeyName is the name of the ssh key to attach to the instance. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name)
125 // +optional
126 pub ssh_key_name: Option<String>, //`json:"sshKeyName,omitempty"`
127
128 /// RootVolume encapsulates the configuration options for the root volume
129 // +optional
130 pub root_volume: Option<Volume>, //`json:"rootVolume,omitempty"`
131
132 /// Configuration options for the non root storage volumes.
133 // +optional
134 #[serde(default, skip_serializing_if = "Vec::is_empty")]
135 pub non_root_volumes: Vec<Volume>, //`json:"nonRootVolumes,omitempty"`
136
137 /// NetworkInterfaces is a list of ENIs to associate with the instance.
138 /// A maximum of 2 may be specified.
139 // +optional
140 // +kubebuilder:validation:MaxItems=2
141 #[serde(default, skip_serializing_if = "Vec::is_empty")]
142 pub network_interfaces: Vec<String>, //`json:"networkInterfaces,omitempty"`
143
144 /// UncompressedUserData specify whether the user data is gzip-compressed before it is sent to ec2 instance.
145 /// cloud-init has built-in support for gzip-compressed user data
146 /// user data stored in aws secret manager is always gzip-compressed.
147 // +optional
148 pub uncompressed_user_data: Option<bool>, //`json:"uncompressedUserData,omitempty"`
149
150 /// CloudInit defines options related to the bootstrapping systems where
151 /// CloudInit is used.
152 // +optional
153 // pub cloud_init: Option<CloudInit>, //`json:"cloudInit,omitempty"`
154
155 // /// SpotMarketOptions allows users to configure instances to be run using AWS Spot instances.
156 // // +optional
157 // pub spot_market_options: Option<SpotMarketOptions> , //`json:"spotMarketOptions,omitempty"`
158 /// Tenancy indicates if instance should run on shared or single-tenant hardware.
159 // +optional
160 // +kubebuilder:validation:Enum:=default;dedicated;host
161 pub tenancy: Option<String>, //`json:"tenancy,omitempty"`
162}
163
164/// AWSMachineStatus defines the observed state of AWSMachine.
165#[skip_serializing_none]
166#[derive(Clone, Debug, Default, Serialize, Deserialize)]
167#[serde(rename_all = "camelCase")]
168pub struct AWSMachineStatus {
169 /// Ready is true when the provider resource is ready.
170 // +optional
171 pub ready: Option<bool>, // `json:"ready"`
172
173 /// Interruptible reports that this machine is using spot instances and can therefore be interrupted by CAPI when it receives a notice that the spot instance is to be terminated by AWS.
174 /// This will be set to true when SpotMarketOptions is not nil (i.e. this machine is using a spot instance).
175 // +optional
176 pub interruptible: Option<bool>, // `json:"interruptible,omitempty"`
177
178 /// Addresses contains the AWS instance associated addresses.
179 #[serde(default, skip_serializing_if = "Vec::is_empty")]
180 pub addresses: Vec<clusterv1::MachineAddress>, // `json:"addresses,omitempty"`
181
182 /// InstanceState is the state of the AWS instance for this machine.
183 // +optional
184 pub instance_state: Option<InstanceState>, // `json:"instanceState,omitempty"`
185
186 /// FailureReason will be set in the event that there is a terminal problem
187 /// reconciling the Machine and will contain a succinct value suitable
188 /// for machine interpretation.
189 ///
190 /// This field should not be set for transitive errors that a controller
191 /// faces that are expected to be fixed automatically over
192 /// time (like service outages), but instead indicate that something is
193 /// fundamentally wrong with the Machine's spec or the configuration of
194 /// the controller, and that manual intervention is required. Examples
195 /// of terminal errors would be invalid combinations of settings in the
196 /// spec, values that are unsupported by the controller, or the
197 /// responsible controller itself being critically misconfigured.
198 ///
199 /// Any transient errors that occur during the reconciliation of Machines
200 /// can be added as events to the Machine object and/or logged in the
201 /// controller's output.
202 // +optional
203 pub failure_reason: Option<errors::MachineStatusError>, // `json:"failureReason,omitempty"`
204
205 /// FailureMessage will be set in the event that there is a terminal problem
206 /// reconciling the Machine and will contain a more verbose string suitable
207 /// for logging and human consumption.
208 ///
209 /// This field should not be set for transitive errors that a controller
210 /// faces that are expected to be fixed automatically over
211 /// time (like service outages), but instead indicate that something is
212 /// fundamentally wrong with the Machine's spec or the configuration of
213 /// the controller, and that manual intervention is required. Examples
214 /// of terminal errors would be invalid combinations of settings in the
215 /// spec, values that are unsupported by the controller, or the
216 /// responsible controller itself being critically misconfigured.
217 ///
218 /// Any transient errors that occur during the reconciliation of Machines
219 /// can be added as events to the Machine object and/or logged in the
220 /// controller's output.
221 // +optional
222 pub failure_message: Option<String>, // `json:"failureMessage,omitempty"`
223
224 /// Conditions defines current service state of the AWSMachine.
225 // +optional
226 pub conditions: Option<clusterv1::Conditions>, // `json:"conditions,omitempty"`
227}
228
229// package v1beta1
230
231// import (
232// metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
233// clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
234// "sigs.k8s.io/cluster-api/errors"
235// )
236
237// const (
238// // MachineFinalizer allows ReconcileAWSMachine to clean up AWS resources associated with AWSMachine before
239// // removing it from the apiserver.
240// MachineFinalizer = "awsmachine.infrastructure.cluster.x-k8s.io"
241// )
242
243// // SecretBackend defines variants for backend secret storage.
244// type SecretBackend string
245
246// var (
247// // SecretBackendSSMParameterStore defines AWS Systems Manager Parameter Store as the secret backend.
248// SecretBackendSSMParameterStore = SecretBackend("ssm-parameter-store")
249
250// // SecretBackendSecretsManager defines AWS Secrets Manager as the secret backend.
251// SecretBackendSecretsManager = SecretBackend("secrets-manager")
252// )
253
254// // CloudInit defines options related to the bootstrapping systems where
255// // CloudInit is used.
256// type CloudInit struct {
257// // InsecureSkipSecretsManager, when set to true will not use AWS Secrets Manager
258// // or AWS Systems Manager Parameter Store to ensure privacy of userdata.
259// // By default, a cloud-init boothook shell script is prepended to download
260// // the userdata from Secrets Manager and additionally delete the secret.
261// InsecureSkipSecretsManager bool `json:"insecureSkipSecretsManager,omitempty"`
262
263// // SecretCount is the number of secrets used to form the complete secret
264// // +optional
265// SecretCount int32 `json:"secretCount,omitempty"`
266
267// // SecretPrefix is the prefix for the secret name. This is stored
268// // temporarily, and deleted when the machine registers as a node against
269// // the workload cluster.
270// // +optional
271// SecretPrefix string `json:"secretPrefix,omitempty"`
272
273// // SecureSecretsBackend, when set to parameter-store will utilize the AWS Systems Manager
274// // Parameter Storage to distribute secrets. By default or with the value of secrets-manager,
275// // will use AWS Secrets Manager instead.
276// // +optional
277// // +kubebuilder:validation:Enum=secrets-manager;ssm-parameter-store
278// SecureSecretsBackend SecretBackend `json:"secureSecretsBackend,omitempty"`
279// }
280
281// // +kubebuilder:object:root=true
282// // +kubebuilder:resource:path=awsmachines,scope=Namespaced,categories=cluster-api,shortName=awsm
283// // +kubebuilder:storageversion
284// // +kubebuilder:subresource:status
285// // +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this AWSMachine belongs"
286// // +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.instanceState",description="EC2 instance state"
287// // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Machine ready status"
288// // +kubebuilder:printcolumn:name="InstanceID",type="string",JSONPath=".spec.providerID",description="EC2 instance ID"
289// // +kubebuilder:printcolumn:name="Machine",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Machine\")].name",description="Machine object which owns with this AWSMachine"
290// // +k8s:defaulter-gen=true
291
292// // AWSMachine is the schema for Amazon EC2 machines.
293// type AWSMachine struct {
294// metav1.TypeMeta `json:",inline"`
295// metav1.ObjectMeta `json:"metadata,omitempty"`
296
297// Spec AWSMachineSpec `json:"spec,omitempty"`
298// Status AWSMachineStatus `json:"status,omitempty"`
299// }
300
301// // GetConditions returns the observations of the operational state of the AWSMachine resource.
302// func (r *AWSMachine) GetConditions() clusterv1.Conditions {
303// return r.Status.Conditions
304// }
305
306// // SetConditions sets the underlying service state of the AWSMachine to the predescribed clusterv1.Conditions.
307// func (r *AWSMachine) SetConditions(conditions clusterv1.Conditions) {
308// r.Status.Conditions = conditions
309// }
310
311// // +kubebuilder:object:root=true
312
313// // AWSMachineList contains a list of Amazon EC2 machines.
314// type AWSMachineList struct {
315// metav1.TypeMeta `json:",inline"`
316// metav1.ListMeta `json:"metadata,omitempty"`
317// Items []AWSMachine `json:"items"`
318// }
319
320// func init() {
321// SchemeBuilder.Register(&AWSMachine{}, &AWSMachineList{})
322// }
323
324/*
325package v1beta1
326
327import (
328 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
329 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
330)
331
332// +kubebuilder:object:root=true
333// +kubebuilder:resource:path=awsmachinetemplates,scope=Namespaced,categories=cluster-api,shortName=awsmt
334// +kubebuilder:storageversion
335// +k8s:defaulter-gen=true
336
337// AWSMachineTemplate is the schema for the Amazon EC2 Machine Templates API.
338type AWSMachineTemplate struct {
339 metav1.TypeMeta `json:",inline"`
340 metav1.ObjectMeta `json:"metadata,omitempty"`
341
342 Spec AWSMachineTemplateSpec `json:"spec,omitempty"`
343}
344
345// +kubebuilder:object:root=true
346
347// AWSMachineTemplateList contains a list of AWSMachineTemplate.
348type AWSMachineTemplateList struct {
349 metav1.TypeMeta `json:",inline"`
350 metav1.ListMeta `json:"metadata,omitempty"`
351 Items []AWSMachineTemplate `json:"items"`
352}
353
354func init() {
355 SchemeBuilder.Register(&AWSMachineTemplate{}, &AWSMachineTemplateList{})
356}
357*/