Skip to content

Commit fb206c6

Browse files
committed
hiveutil create-cluster: cheaper AWS instances
For cost savings: - Change the default AWS instance type we use for `hiveutil create-cluster` and clusterpools from m6i.xlarge to m6a.xlarge. These have the same specs, but we're told `i`(ntel) is more expensive than `a`(md). - Plumb a new `--aws-worker-instance-type` flag into `hiveutil create-cluster` to allow customizing _just_ the worker instance type in the generated install-config and machine pool. If unset, the previous behavior will hold: we'll use `--aws-instance-type` for (masters and) workers. - Use the above to shrink the default worker instance type for e2e to m6a.large, which has half the CPU and memory of m6a.xlarge. HIVE-2426
1 parent 8c54fc9 commit fb206c6

File tree

5 files changed

+41
-19
lines changed

5 files changed

+41
-19
lines changed

contrib/pkg/createcluster/create.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ type Options struct {
169169
FeatureSet string
170170

171171
// AWS
172-
AWSUserTags []string
173-
AWSPrivateLink bool
174-
AWSInstanceType string
172+
AWSUserTags []string
173+
AWSPrivateLink bool
174+
AWSInstanceType string
175+
AWSWorkerInstanceType string
175176

176177
// Azure
177178
AzureBaseDomainResourceGroupName string
@@ -325,7 +326,8 @@ OpenShift Installer publishes all the services of the cluster like API server an
325326
// AWS flags
326327
flags.StringSliceVar(&opt.AWSUserTags, "aws-user-tags", nil, "Additional tags to add to resources. Must be in the form \"key=value\"")
327328
flags.BoolVar(&opt.AWSPrivateLink, "aws-private-link", false, "Enables access to cluster using AWS PrivateLink")
328-
flags.StringVar(&opt.AWSInstanceType, "aws-instance-type", clusterresource.AWSInstanceTypeDefault, "AWS cloud instance type")
329+
flags.StringVar(&opt.AWSInstanceType, "aws-instance-type", clusterresource.AWSInstanceTypeDefault, "AWS cloud instance type for masters and workers (unless the latter is overridden by --aws-worker-instance-type)")
330+
flags.StringVar(&opt.AWSWorkerInstanceType, "aws-worker-instance-type", "", "AWS cloud instance type for workers only. If unset, --aws-instance-type is used.")
329331

330332
// Azure flags
331333
flags.StringVar(&opt.AzureBaseDomainResourceGroupName, "azure-base-domain-resource-group-name", "os4-common", "Resource group where the azure DNS zone for the base domain is found")
@@ -641,7 +643,9 @@ func (o *Options) GenerateObjects() ([]runtime.Object, error) {
641643
UserTags: userTags,
642644
Region: o.Region,
643645
InstanceType: o.AWSInstanceType,
644-
PrivateLink: o.AWSPrivateLink,
646+
// Will default to above if unset
647+
WorkerInstanceType: o.AWSWorkerInstanceType,
648+
PrivateLink: o.AWSPrivateLink,
645649
}
646650
builder.CloudBuilder = awsProvider
647651
case cloudAzure:

hack/e2e-common.sh

+4
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ case "${CLOUD}" in
198198
# NOTE: Only observed by hiveutil create-cluster, not clusterpool at this time.
199199
INSTANCE_TYPE_ARG="--aws-instance-type $AWS_INSTANCE_TYPE"
200200
fi
201+
# Default workers to the smaller m6a.large
202+
AWS_WORKER_INSTANCE_TYPE=${AWS_WORKER_INSTANCE_TYPE:-m6a.large}
203+
# NOTE: Only observed by hiveutil create-cluster, not clusterpool at this time.
204+
WORKER_INSTANCE_TYPE_ARG="--aws-worker-instance-type $AWS_WORKER_INSTANCE_TYPE"
201205
;;
202206
"azure")
203207
CREDS_FILE_ARG="--creds-file=${CLUSTER_PROFILE_DIR}/osServicePrincipal.json"

hack/e2e-test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ go run "${SRC_ROOT}/contrib/cmd/hiveutil/main.go" create-cluster "${CLUSTER_NAME
106106
--workers=2 \
107107
${REGION_ARG} \
108108
${INSTANCE_TYPE_ARG} \
109+
${WORKER_INSTANCE_TYPE_ARG} \
109110
${MANAGED_DNS_ARG} \
110111
${EXTRA_CREATE_CLUSTER_ARGS} \
111112
-o json \

pkg/clusterresource/aws.go

+24-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
const (
19-
AWSInstanceTypeDefault = "m6i.xlarge"
19+
AWSInstanceTypeDefault = "m6a.xlarge"
2020
volumeSize = 120
2121
volumeType = "gp3"
2222
)
@@ -37,8 +37,12 @@ type AWSCloudBuilder struct {
3737
// Region is the AWS region to which to install the cluster
3838
Region string
3939

40+
// Instance type for masters and workers, unless the latter is overridden by WorkerInstanceType
4041
InstanceType string
4142

43+
// Instance type for workers only. If empty, InstanceType is used.
44+
WorkerInstanceType string
45+
4246
PrivateLink bool
4347
}
4448

@@ -96,9 +100,16 @@ func (p *AWSCloudBuilder) GenerateCloudObjects(o *Builder) []runtime.Object {
96100
return []runtime.Object{}
97101
}
98102

103+
func (p *AWSCloudBuilder) workerInstanceType() string {
104+
if p.WorkerInstanceType != "" {
105+
return p.WorkerInstanceType
106+
}
107+
return p.InstanceType
108+
}
109+
99110
func (p *AWSCloudBuilder) addMachinePoolPlatform(o *Builder, mp *hivev1.MachinePool) {
100111
mp.Spec.Platform.AWS = &hivev1aws.MachinePoolPlatform{
101-
InstanceType: p.InstanceType,
112+
InstanceType: p.workerInstanceType(),
102113
EC2RootVolume: hivev1aws.EC2RootVolume{
103114
Size: volumeSize,
104115
Type: volumeType,
@@ -115,16 +126,18 @@ func (p *AWSCloudBuilder) addInstallConfigPlatform(o *Builder, ic *installertype
115126
},
116127
}
117128

118-
// Used for both control plane and workers.
119-
mpp := &awsinstallertypes.MachinePool{
120-
InstanceType: p.InstanceType,
121-
EC2RootVolume: awsinstallertypes.EC2RootVolume{
122-
Size: volumeSize,
123-
Type: volumeType,
124-
},
129+
ec2 := awsinstallertypes.EC2RootVolume{
130+
Size: volumeSize,
131+
Type: volumeType,
132+
}
133+
ic.ControlPlane.Platform.AWS = &awsinstallertypes.MachinePool{
134+
InstanceType: p.InstanceType,
135+
EC2RootVolume: ec2,
136+
}
137+
ic.Compute[0].Platform.AWS = &awsinstallertypes.MachinePool{
138+
InstanceType: p.workerInstanceType(),
139+
EC2RootVolume: ec2,
125140
}
126-
ic.ControlPlane.Platform.AWS = mpp
127-
ic.Compute[0].Platform.AWS = mpp
128141

129142
if len(o.BoundServiceAccountSigningKey) > 0 {
130143
ic.CredentialsMode = installertypes.ManualCredentialsMode

test/e2e/postinstall/machinesets/infra_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ func TestAutoscalingMachinePool(t *testing.T) {
308308

309309
// busyboxDeployment creates a large number of pods to place CPU pressure
310310
// on the machine pool. With 100 replicas and a CPU request for each pod of
311-
// 1, the total CPU request from the deployment is 100. For AWS using m6i.xlarge,
312-
// each machine has a CPU limit of 6. For the max replicas of 12, the total
313-
// CPU limit is 72.
311+
// 1, the total CPU request from the deployment is 100. For AWS using m6a.xlarge,
312+
// each machine has a CPU limit of 4. For the max replicas of 12, the total
313+
// CPU limit is 48.
314314
busyboxDeployment := &appsv1.Deployment{
315315
ObjectMeta: metav1.ObjectMeta{
316316
Namespace: "default",

0 commit comments

Comments
 (0)