sigs.k8s.io/cluster-api-provider-aws@v1.5.5/api/v1alpha3/awsmachine_types.go (about) 1 /* 2 Copyright 2019 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha3 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 22 clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3" 23 "sigs.k8s.io/cluster-api/errors" 24 ) 25 26 const ( 27 // MachineFinalizer allows ReconcileAWSMachine to clean up AWS resources associated with AWSMachine before 28 // removing it from the apiserver. 29 MachineFinalizer = "awsmachine.infrastructure.cluster.x-k8s.io" 30 ) 31 32 // SecretBackend defines variants for backend secret storage. 33 type SecretBackend string 34 35 var ( 36 // SecretBackendSSMParameterStore defines AWS Systems Manager Parameter Store as the secret backend. 37 SecretBackendSSMParameterStore = SecretBackend("ssm-parameter-store") 38 39 // SecretBackendSecretsManager defines AWS Secrets Manager as the secret backend. 40 SecretBackendSecretsManager = SecretBackend("secrets-manager") 41 ) 42 43 // AWSMachineSpec defines the desired state of AWSMachine 44 type AWSMachineSpec struct { 45 // ProviderID is the unique identifier as specified by the cloud provider. 46 ProviderID *string `json:"providerID,omitempty"` 47 48 // InstanceID is the EC2 instance ID for this machine. 49 InstanceID *string `json:"instanceID,omitempty"` 50 51 // AMI is the reference to the AMI from which to create the machine instance. 52 AMI AWSResourceReference `json:"ami,omitempty"` 53 54 // ImageLookupFormat is the AMI naming format to look up the image for this 55 // machine It will be ignored if an explicit AMI is set. Supports 56 // substitutions for {{.BaseOS}} and {{.K8sVersion}} with the base OS and 57 // kubernetes version, respectively. The BaseOS will be the value in 58 // ImageLookupBaseOS or ubuntu (the default), and the kubernetes version as 59 // defined by the packages produced by kubernetes/release without v as a 60 // prefix: 1.13.0, 1.12.5-mybuild.1, or 1.17.3. For example, the default 61 // image format of capa-ami-{{.BaseOS}}-?{{.K8sVersion}}-* will end up 62 // searching for AMIs that match the pattern capa-ami-ubuntu-?1.18.0-* for a 63 // Machine that is targeting kubernetes v1.18.0 and the ubuntu base OS. See 64 // also: https://golang.org/pkg/text/template/ 65 // +optional 66 ImageLookupFormat string `json:"imageLookupFormat,omitempty"` 67 68 // ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set. 69 ImageLookupOrg string `json:"imageLookupOrg,omitempty"` 70 71 // ImageLookupBaseOS is the name of the base operating system to use for 72 // image lookup the AMI is not set. 73 ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"` 74 75 // InstanceType is the type of instance to create. Example: m4.xlarge 76 InstanceType string `json:"instanceType,omitempty"` 77 78 // AdditionalTags is an optional set of tags to add to an instance, in addition to the ones added by default by the 79 // AWS provider. If both the AWSCluster and the AWSMachine specify the same tag name with different values, the 80 // AWSMachine's value takes precedence. 81 // +optional 82 AdditionalTags Tags `json:"additionalTags,omitempty"` 83 84 // IAMInstanceProfile is a name of an IAM instance profile to assign to the instance 85 // +optional 86 IAMInstanceProfile string `json:"iamInstanceProfile,omitempty"` 87 88 // PublicIP specifies whether the instance should get a public IP. 89 // Precedence for this setting is as follows: 90 // 1. This field if set 91 // 2. Cluster/flavor setting 92 // 3. Subnet default 93 // +optional 94 PublicIP *bool `json:"publicIP,omitempty"` 95 96 // AdditionalSecurityGroups is an array of references to security groups that should be applied to the 97 // instance. These security groups would be set in addition to any security groups defined 98 // at the cluster level or in the actuator. It is possible to specify either IDs of Filters. Using Filters 99 // will cause additional requests to AWS API and if tags change the attached security groups might change too. 100 // +optional 101 AdditionalSecurityGroups []AWSResourceReference `json:"additionalSecurityGroups,omitempty"` 102 103 // FailureDomain is the failure domain unique identifier this Machine should be attached to, as defined in Cluster API. 104 // For this infrastructure provider, the ID is equivalent to an AWS Availability Zone. 105 // If multiple subnets are matched for the availability zone, the first one returned is picked. 106 FailureDomain *string `json:"failureDomain,omitempty"` 107 108 // Subnet is a reference to the subnet to use for this instance. If not specified, 109 // the cluster subnet will be used. 110 // +optional 111 Subnet *AWSResourceReference `json:"subnet,omitempty"` 112 113 // 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) 114 // +optional 115 SSHKeyName *string `json:"sshKeyName,omitempty"` 116 117 // RootVolume encapsulates the configuration options for the root volume 118 // +optional 119 RootVolume *Volume `json:"rootVolume,omitempty"` 120 121 // Configuration options for the non root storage volumes. 122 // +optional 123 NonRootVolumes []Volume `json:"nonRootVolumes,omitempty"` 124 125 // NetworkInterfaces is a list of ENIs to associate with the instance. 126 // A maximum of 2 may be specified. 127 // +optional 128 // +kubebuilder:validation:MaxItems=2 129 NetworkInterfaces []string `json:"networkInterfaces,omitempty"` 130 131 // UncompressedUserData specify whether the user data is gzip-compressed before it is sent to ec2 instance. 132 // cloud-init has built-in support for gzip-compressed user data 133 // user data stored in aws secret manager is always gzip-compressed. 134 // 135 // +optional 136 UncompressedUserData *bool `json:"uncompressedUserData,omitempty"` 137 138 // CloudInit defines options related to the bootstrapping systems where 139 // CloudInit is used. 140 // +optional 141 CloudInit CloudInit `json:"cloudInit,omitempty"` 142 143 // SpotMarketOptions allows users to configure instances to be run using AWS Spot instances. 144 // +optional 145 SpotMarketOptions *SpotMarketOptions `json:"spotMarketOptions,omitempty"` 146 147 // Tenancy indicates if instance should run on shared or single-tenant hardware. 148 // +optional 149 // +kubebuilder:validation:Enum:=default;dedicated;host 150 Tenancy string `json:"tenancy,omitempty"` 151 } 152 153 // CloudInit defines options related to the bootstrapping systems where 154 // CloudInit is used. 155 type CloudInit struct { 156 // InsecureSkipSecretsManager, when set to true will not use AWS Secrets Manager 157 // or AWS Systems Manager Parameter Store to ensure privacy of userdata. 158 // By default, a cloud-init boothook shell script is prepended to download 159 // the userdata from Secrets Manager and additionally delete the secret. 160 InsecureSkipSecretsManager bool `json:"insecureSkipSecretsManager,omitempty"` 161 162 // SecretCount is the number of secrets used to form the complete secret 163 // +optional 164 SecretCount int32 `json:"secretCount,omitempty"` 165 166 // SecretPrefix is the prefix for the secret name. This is stored 167 // temporarily, and deleted when the machine registers as a node against 168 // the workload cluster. 169 // +optional 170 SecretPrefix string `json:"secretPrefix,omitempty"` 171 172 // SecureSecretsBackend, when set to parameter-store will utilize the AWS Systems Manager 173 // Parameter Storage to distribute secrets. By default or with the value of secrets-manager, 174 // will use AWS Secrets Manager instead. 175 // +optional 176 // +kubebuilder:validation:Enum=secrets-manager;ssm-parameter-store 177 SecureSecretsBackend SecretBackend `json:"secureSecretsBackend,omitempty"` 178 } 179 180 // AWSMachineStatus defines the observed state of AWSMachine 181 type AWSMachineStatus struct { 182 // Ready is true when the provider resource is ready. 183 // +optional 184 Ready bool `json:"ready"` 185 186 // 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. 187 // This will be set to true when SpotMarketOptions is not nil (i.e. this machine is using a spot instance). 188 // +optional 189 Interruptible bool `json:"interruptible,omitempty"` 190 191 // Addresses contains the AWS instance associated addresses. 192 Addresses []clusterv1alpha3.MachineAddress `json:"addresses,omitempty"` 193 194 // InstanceState is the state of the AWS instance for this machine. 195 // +optional 196 InstanceState *InstanceState `json:"instanceState,omitempty"` 197 198 // FailureReason will be set in the event that there is a terminal problem 199 // reconciling the Machine and will contain a succinct value suitable 200 // for machine interpretation. 201 // 202 // This field should not be set for transitive errors that a controller 203 // faces that are expected to be fixed automatically over 204 // time (like service outages), but instead indicate that something is 205 // fundamentally wrong with the Machine's spec or the configuration of 206 // the controller, and that manual intervention is required. Examples 207 // of terminal errors would be invalid combinations of settings in the 208 // spec, values that are unsupported by the controller, or the 209 // responsible controller itself being critically misconfigured. 210 // 211 // Any transient errors that occur during the reconciliation of Machines 212 // can be added as events to the Machine object and/or logged in the 213 // controller's output. 214 // +optional 215 FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"` 216 217 // FailureMessage will be set in the event that there is a terminal problem 218 // reconciling the Machine and will contain a more verbose string suitable 219 // for logging and human consumption. 220 // 221 // This field should not be set for transitive errors that a controller 222 // faces that are expected to be fixed automatically over 223 // time (like service outages), but instead indicate that something is 224 // fundamentally wrong with the Machine's spec or the configuration of 225 // the controller, and that manual intervention is required. Examples 226 // of terminal errors would be invalid combinations of settings in the 227 // spec, values that are unsupported by the controller, or the 228 // responsible controller itself being critically misconfigured. 229 // 230 // Any transient errors that occur during the reconciliation of Machines 231 // can be added as events to the Machine object and/or logged in the 232 // controller's output. 233 // +optional 234 FailureMessage *string `json:"failureMessage,omitempty"` 235 236 // Conditions defines current service state of the AWSMachine. 237 // +optional 238 Conditions clusterv1alpha3.Conditions `json:"conditions,omitempty"` 239 } 240 241 // +kubebuilder:object:root=true 242 // +kubebuilder:resource:path=awsmachines,scope=Namespaced,categories=cluster-api,shortName=awsm 243 // +kubebuilder:subresource:status 244 // +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this AWSMachine belongs" 245 // +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.instanceState",description="EC2 instance state" 246 // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Machine ready status" 247 // +kubebuilder:printcolumn:name="InstanceID",type="string",JSONPath=".spec.providerID",description="EC2 instance ID" 248 // +kubebuilder:printcolumn:name="Machine",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Machine\")].name",description="Machine object which owns with this AWSMachine" 249 // +k8s:defaulter-gen=true 250 251 // AWSMachine is the Schema for the awsmachines API 252 type AWSMachine struct { 253 metav1.TypeMeta `json:",inline"` 254 metav1.ObjectMeta `json:"metadata,omitempty"` 255 256 Spec AWSMachineSpec `json:"spec,omitempty"` 257 Status AWSMachineStatus `json:"status,omitempty"` 258 } 259 260 // GetConditions returns the observations of the operational state of the AWSMachine resource. 261 func (r *AWSMachine) GetConditions() clusterv1alpha3.Conditions { 262 return r.Status.Conditions 263 } 264 265 // SetConditions sets the underlying service state of the AWSMachine to the predescribed clusterv1alpha3.Conditions. 266 func (r *AWSMachine) SetConditions(conditions clusterv1alpha3.Conditions) { 267 r.Status.Conditions = conditions 268 } 269 270 // +kubebuilder:object:root=true 271 272 // AWSMachineList contains a list of AWSMachine. 273 type AWSMachineList struct { 274 metav1.TypeMeta `json:",inline"` 275 metav1.ListMeta `json:"metadata,omitempty"` 276 Items []AWSMachine `json:"items"` 277 } 278 279 func init() { 280 SchemeBuilder.Register(&AWSMachine{}, &AWSMachineList{}) 281 }