Skip to content

Commit

Permalink
Allow to specify master/worker vm size in e2e and hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Tof1973 committed Jan 30, 2025
1 parent 6d43cf9 commit b886acb
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 16 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ services:
E2E_DELETE_CLUSTER:
E2E_LABEL:
OS_CLUSTER_VERSION:
MASTER_VM_SIZE:
WORKER_VM_SIZE:
PORTAL_HOSTNAME: "https://localhost:8444"
RP_BASE_URL: "https://localhost:8443"
entrypoint: "/usr/local/bin/e2e.test"
Expand Down
15 changes: 10 additions & 5 deletions docs/adding-new-instance-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,21 @@ az aro create --resource-group $RESOURCEGROUP --name $CLUSTER --vnet aro-l

4) Once an install with an alternate size is successful, a basic check of cluster health can be conducted, as well as local e2e tests to confirm supportability.

### Hack scripts method
### Hack scripts method (To be updated)

1) Comment out `FeatureRequireD2sV3Workers` from the range of features in `pkg/env/dev.go`, and modify the worker and master profiles defined in `createCluster()` at `pkg/util/cluster/cluster.go` to contain your desired instance size. For example:
1) Comment out `FeatureRequireD2sV3Workers` from the range of features in `pkg/env/dev.go`, and if you want to use worker StandardD4sV3 (which is default version.DefaultInstallStream.WorkerVmSize), only for that specific worker size, comment out also in `createCluster()` at `pkg/util/cluster/cluster.go` the following block:
~~~
oc.Properties.WorkerProfiles[0].VMSize = api.VMSizeStandardL4s
// In LocalDev mode, if workerVmSize is not default one, then it means user requested a specific one we need to keep.
if workerVmSize == version.DefaultInstallStream.WorkerVmSize {
oc.Properties.WorkerProfiles[0].VMSize = api.VMSizeStandardD2sV3
}
~~~

2) Use the [hack script to create a cluster.](https://github.com/cadenmarchese/ARO-RP/blob/master/docs/deploy-development-rp.md#run-the-rp-and-create-a-cluster)
2) Start your local RP. If it was already running, restart it to take into account commented lines.

3) Once an install with an alternate size is successful, a basic check of cluster health can be conducted, as well as local e2e tests to confirm supportability.
3) Use the [hack script to create a cluster.](https://github.com/cadenmarchese/ARO-RP/blob/master/docs/deploy-development-rp.md#run-the-rp-and-create-a-cluster), with MASTER_VM_SIZE and WORKER_VM_SIZE variables set to desired instance size.

4) Once an install with an alternate size is successful, a basic check of cluster health can be conducted, as well as local e2e tests to confirm supportability.

### Post-install method

Expand Down
18 changes: 17 additions & 1 deletion hack/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,30 @@ func run(ctx context.Context, log *logrus.Entry) error {
log.Infof("using specified cluster version %s", osClusterVersion)
}

masterVmSize := os.Getenv("MASTER_VM_SIZE")
if masterVmSize == "" {
masterVmSize = version.DefaultInstallStream.MasterVmSize.String()
log.Infof("using default master VM size %s", masterVmSize)
} else {
log.Infof("using specified master VM size %s", masterVmSize)
}

workerVmSize := os.Getenv("WORKER_VM_SIZE")
if workerVmSize == "" {
workerVmSize = version.DefaultInstallStream.WorkerVmSize.String()
log.Infof("using default worker VM size %s", workerVmSize)
} else {
log.Infof("using specified worker VM size %s", workerVmSize)
}

c, err := cluster.New(log, env, os.Getenv("CI") != "")
if err != nil {
return err
}

switch strings.ToLower(os.Args[1]) {
case "create":
return c.Create(ctx, vnetResourceGroup, clusterName, osClusterVersion)
return c.Create(ctx, vnetResourceGroup, clusterName, osClusterVersion, masterVmSize, workerVmSize)
case "delete":
return c.Delete(ctx, vnetResourceGroup, clusterName)
default:
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ type MasterProfile struct {
// VMSize represents a VM size
type VMSize string

func (vmSize *VMSize) String() (string) {

Check failure on line 448 in pkg/api/openshiftcluster.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)
return string(*vmSize)
}

// VMSize constants
// add required resources in pkg/validate/dynamic/quota.go when adding a new VMSize
const (
Expand Down
19 changes: 12 additions & 7 deletions pkg/util/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (c *Cluster) createApp(ctx context.Context, clusterName string) (applicatio
return appDetails{appID, appSecret, spID}, nil
}

func (c *Cluster) Create(ctx context.Context, vnetResourceGroup, clusterName string, osClusterVersion string) error {
func (c *Cluster) Create(ctx context.Context, vnetResourceGroup, clusterName string, osClusterVersion string, masterVmSize string, workerVmSize string) error {
clusterGet, err := c.openshiftclusters.Get(ctx, vnetResourceGroup, clusterName)
if err == nil {
if clusterGet.Properties.ProvisioningState == api.ProvisioningStateFailed {
Expand Down Expand Up @@ -363,8 +363,11 @@ func (c *Cluster) Create(ctx context.Context, vnetResourceGroup, clusterName str
}
}

apiMasterVmSize := api.VMSize(masterVmSize)
apiWorkerVmSize := api.VMSize(workerVmSize)

c.log.Info("creating cluster")
err = c.createCluster(ctx, vnetResourceGroup, clusterName, appDetails.applicationId, appDetails.applicationSecret, diskEncryptionSetID, visibility, osClusterVersion)
err = c.createCluster(ctx, vnetResourceGroup, clusterName, appDetails.applicationId, appDetails.applicationSecret, diskEncryptionSetID, visibility, osClusterVersion, apiMasterVmSize, apiWorkerVmSize)

if err != nil {
return err
Expand Down Expand Up @@ -516,7 +519,7 @@ func (c *Cluster) Delete(ctx context.Context, vnetResourceGroup, clusterName str
// createCluster created new clusters, based on where it is running.
// development - using preview api
// production - using stable GA api
func (c *Cluster) createCluster(ctx context.Context, vnetResourceGroup, clusterName, clientID, clientSecret, diskEncryptionSetID string, visibility api.Visibility, osClusterVersion string) error {
func (c *Cluster) createCluster(ctx context.Context, vnetResourceGroup, clusterName, clientID, clientSecret, diskEncryptionSetID string, visibility api.Visibility, osClusterVersion string, masterVmSize api.VMSize, workerVmSize api.VMSize) error {
// using internal representation for "singe source" of options
oc := api.OpenShiftCluster{
Properties: api.OpenShiftClusterProperties{
Expand All @@ -533,15 +536,15 @@ func (c *Cluster) createCluster(ctx context.Context, vnetResourceGroup, clusterN
SoftwareDefinedNetwork: api.SoftwareDefinedNetworkOpenShiftSDN,
},
MasterProfile: api.MasterProfile{
VMSize: api.VMSizeStandardD8sV3,
VMSize: masterVmSize,
SubnetID: fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/dev-vnet/subnets/%s-master", c.env.SubscriptionID(), vnetResourceGroup, clusterName),
EncryptionAtHost: api.EncryptionAtHostEnabled,
DiskEncryptionSetID: diskEncryptionSetID,
},
WorkerProfiles: []api.WorkerProfile{
{
Name: "worker",
VMSize: api.VMSizeStandardD4sV3,
VMSize: workerVmSize,
DiskSizeGB: 128,
SubnetID: fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/dev-vnet/subnets/%s-worker", c.env.SubscriptionID(), vnetResourceGroup, clusterName),
Count: 3,
Expand Down Expand Up @@ -579,8 +582,10 @@ func (c *Cluster) createCluster(ctx context.Context, vnetResourceGroup, clusterN
if err != nil {
return err
}

oc.Properties.WorkerProfiles[0].VMSize = api.VMSizeStandardD2sV3
// In LocalDev mode, if workerVmSize is not default one, then it means user requested a specific one we need to keep.
if workerVmSize == version.DefaultInstallStream.WorkerVmSize {
oc.Properties.WorkerProfiles[0].VMSize = api.VMSizeStandardD2sV3
}
}

return c.openshiftclusters.CreateOrUpdateAndWait(ctx, vnetResourceGroup, clusterName, &oc)
Expand Down
8 changes: 6 additions & 2 deletions pkg/util/version/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ const (
var GitCommit = "unknown"

type Stream struct {
Version *Version `json:"version"`
PullSpec string `json:"-"`
Version *Version `json:"version"`
PullSpec string `json:"-"`
MasterVmSize api.VMSize `json:"masterVmSize"`
WorkerVmSize api.VMSize `json:"workervMSize"`
}

// Install stream data for production and INT has moved to RP-Config.
Expand All @@ -36,6 +38,8 @@ type Stream struct {
var DefaultInstallStream = Stream{
Version: NewVersion(4, 15, 35),

Check failure on line 39 in pkg/util/version/const.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)
PullSpec: "quay.io/openshift-release-dev/ocp-release@sha256:8c8433f95d09b051e156ff638f4ccc95543918c3aed92b8c09552a8977a2a1a2",
MasterVmSize: api.VMSizeStandardD8sV3,
WorkerVmSize: api.VMSizeStandardD4sV3,
}

// FluentbitImage contains the location of the Fluentbit container image
Expand Down
16 changes: 15 additions & 1 deletion test/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ var (
vnetResourceGroup string
clusterName string
osClusterVersion string
masterVmSize string

Check failure on line 118 in test/e2e/setup.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)
workerVmSize string
clusterResourceID string
clients *clientSet
)
Expand Down Expand Up @@ -493,6 +495,10 @@ func setup(ctx context.Context) error {

osClusterVersion = os.Getenv("OS_CLUSTER_VERSION")

masterVmSize = os.Getenv("MASTER_VM_SIZE")

workerVmSize = os.Getenv("WORKER_VM_SIZE")

if os.Getenv("CI") != "" { // always create cluster in CI
cluster, err := cluster.New(log, _env, os.Getenv("CI") != "")
if err != nil {
Expand All @@ -503,7 +509,15 @@ func setup(ctx context.Context) error {
osClusterVersion = version.DefaultInstallStream.Version.String()
}

err = cluster.Create(ctx, vnetResourceGroup, clusterName, osClusterVersion)
if masterVmSize == "" {
masterVmSize = version.DefaultInstallStream.MasterVmSize.String()
}

if workerVmSize == "" {
workerVmSize = version.DefaultInstallStream.WorkerVmSize.String()
}

err = cluster.Create(ctx, vnetResourceGroup, clusterName, osClusterVersion, masterVmSize, workerVmSize)
if err != nil {
return err
}
Expand Down

0 comments on commit b886acb

Please sign in to comment.