github.com/openshift/installer@v1.4.17/pkg/types/aws/machinepool.go (about)

     1  package aws
     2  
     3  // MachinePool stores the configuration for a machine pool installed
     4  // on AWS.
     5  type MachinePool struct {
     6  	// Zones is list of availability zones that can be used.
     7  	//
     8  	// +optional
     9  	Zones []string `json:"zones,omitempty"`
    10  
    11  	// InstanceType defines the ec2 instance type.
    12  	// eg. m4-large
    13  	//
    14  	// +optional
    15  	InstanceType string `json:"type"`
    16  
    17  	// AMIID is the AMI that should be used to boot the ec2 instance.
    18  	// If set, the AMI should belong to the same region as the cluster.
    19  	//
    20  	// +optional
    21  	AMIID string `json:"amiID,omitempty"`
    22  
    23  	// EC2RootVolume defines the root volume for EC2 instances in the machine pool.
    24  	//
    25  	// +optional
    26  	EC2RootVolume `json:"rootVolume"`
    27  
    28  	// EC2MetadataOptions defines metadata service interaction options for EC2 instances in the machine pool.
    29  	//
    30  	// +optional
    31  	EC2Metadata EC2Metadata `json:"metadataService"`
    32  
    33  	// IAMRole is the name of the IAM Role to use for the instance profile of the machine.
    34  	// Leave unset to have the installer create the IAM Role on your behalf.
    35  	// Cannot be specified together with iamProfile.
    36  	// +optional
    37  	IAMRole string `json:"iamRole,omitempty"`
    38  
    39  	// IAMProfile is the name of the IAM instance profile to use for the machine.
    40  	// Leave unset to have the installer create the IAM Profile on your behalf.
    41  	// Cannot be specified together with iamRole.
    42  	// +optional
    43  	IAMProfile string `json:"iamProfile,omitempty"`
    44  
    45  	// AdditionalSecurityGroupIDs contains IDs of additional security groups for machines, where each ID
    46  	// is presented in the format sg-xxxx.
    47  	//
    48  	// +kubebuilder:validation:MaxItems=10
    49  	// +optional
    50  	AdditionalSecurityGroupIDs []string `json:"additionalSecurityGroupIDs,omitempty"`
    51  }
    52  
    53  // Set sets the values from `required` to `a`.
    54  func (a *MachinePool) Set(required *MachinePool) {
    55  	if required == nil || a == nil {
    56  		return
    57  	}
    58  
    59  	if len(required.Zones) > 0 {
    60  		a.Zones = required.Zones
    61  	}
    62  
    63  	if required.InstanceType != "" {
    64  		a.InstanceType = required.InstanceType
    65  	}
    66  
    67  	if required.AMIID != "" {
    68  		a.AMIID = required.AMIID
    69  	}
    70  
    71  	if required.EC2RootVolume.IOPS != 0 {
    72  		a.EC2RootVolume.IOPS = required.EC2RootVolume.IOPS
    73  	}
    74  	if required.EC2RootVolume.Size != 0 {
    75  		a.EC2RootVolume.Size = required.EC2RootVolume.Size
    76  	}
    77  	if required.EC2RootVolume.Type != "" {
    78  		a.EC2RootVolume.Type = required.EC2RootVolume.Type
    79  	}
    80  	if required.EC2RootVolume.KMSKeyARN != "" {
    81  		a.EC2RootVolume.KMSKeyARN = required.EC2RootVolume.KMSKeyARN
    82  	}
    83  
    84  	if required.EC2Metadata.Authentication != "" {
    85  		a.EC2Metadata.Authentication = required.EC2Metadata.Authentication
    86  	}
    87  
    88  	if required.IAMRole != "" {
    89  		a.IAMRole = required.IAMRole
    90  	}
    91  
    92  	if required.IAMProfile != "" {
    93  		a.IAMProfile = required.IAMProfile
    94  	}
    95  
    96  	if len(required.AdditionalSecurityGroupIDs) > 0 {
    97  		a.AdditionalSecurityGroupIDs = required.AdditionalSecurityGroupIDs
    98  	}
    99  }
   100  
   101  // EC2RootVolume defines the storage for an ec2 instance.
   102  type EC2RootVolume struct {
   103  	// IOPS defines the amount of provisioned IOPS. (KiB/s). IOPS may only be set for
   104  	// io1, io2, & gp3 volume types.
   105  	//
   106  	// +kubebuilder:validation:Minimum=0
   107  	// +optional
   108  	IOPS int `json:"iops"`
   109  
   110  	// Size defines the size of the volume in gibibytes (GiB).
   111  	//
   112  	// +kubebuilder:validation:Minimum=0
   113  	Size int `json:"size"`
   114  
   115  	// Type defines the type of the volume.
   116  	Type string `json:"type"`
   117  
   118  	// The KMS key that will be used to encrypt the EBS volume.
   119  	// If no key is provided the default KMS key for the account will be used.
   120  	// https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_GetEbsDefaultKmsKeyId.html
   121  	// +optional
   122  	KMSKeyARN string `json:"kmsKeyARN,omitempty"`
   123  }
   124  
   125  // EC2Metadata defines the metadata service interaction options for an ec2 instance.
   126  // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html
   127  type EC2Metadata struct {
   128  	// Authentication determines whether or not the host requires the use of authentication when interacting with the metadata service.
   129  	// When using authentication, this enforces v2 interaction method (IMDSv2) with the metadata service.
   130  	// When omitted, this means the user has no opinion and the value is left to the platform to choose a good
   131  	// default, which is subject to change over time. The current default is optional.
   132  	// At this point this field represents `HttpTokens` parameter from `InstanceMetadataOptionsRequest` structure in AWS EC2 API
   133  	// https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_InstanceMetadataOptionsRequest.html
   134  	// +kubebuilder:validation:Enum=Required;Optional
   135  	// +optional
   136  	Authentication string `json:"authentication,omitempty"`
   137  }