-
Notifications
You must be signed in to change notification settings - Fork 275
Dynamic AMI and instance type lookup from existing MachineSets with fallback to ConfigMap values #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic AMI and instance type lookup from existing MachineSets with fallback to ConfigMap values #536
Conversation
tanfengshuang
commented
Dec 16, 2025
- Dynamic AMI Lookup
- Queries existing MachineSets in openshift-machine-api namespace
- Extracts AMI ID from the first MachineSet's providerSpec.value.ami.id
- Falls back to region+version-based ConfigMap lookup if no MachineSets exist
- Ensures storage nodes use the same AMI as compute nodes (matching architecture)
- Dynamic Instance Type Lookup
- Extracts instance type from existing MachineSets
- Automatically handles bare metal by replacing .metal with .2xlarge
- Falls back to awsInstanceType ConfigMap value if no MachineSets found
- Ensures architecture compatibility between AMI and instance type
- Dynamically query AMI ID from existing MachineSets - Add dynamic instance type lookup with ARM64 support - Handle bare metal clusters by skipping MachineSet creation - Fixes AMI mismatch issue causing deployment failures in unsupported regions - Supports ARM64 (Graviton) and x86_64 architectures Signed-off-by: Fengshuang Tan <[email protected]>
6ff7110 to
30d6711
Compare
dhaiducek
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update @tanfengshuang! I'm not sure I'm familiar enough with this Policy to approve it, but I have a minor comment to consider!
| id: '{{- $dynamicAMI := "" -}} | ||
| {{- $machinesets := (lookup "machine.openshift.io/v1beta1" "MachineSet" "openshift-machine-api" "") -}} | ||
| {{- if $machinesets.items -}} | ||
| {{- if gt (len $machinesets.items) 0 -}} | ||
| {{- $dynamicAMI = (index $machinesets.items 0).spec.template.spec.providerSpec.value.ami.id -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- if $dynamicAMI -}} | ||
| {{ $dynamicAMI }} | ||
| {{- else -}} | ||
| {{ fromConfigMap "policies" "opp-settings" (printf "%s-%s" (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.platformStatus.aws.region (fromClusterClaim "openshiftversion-major-minor")) }} | ||
| {{- end -}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Optional) Leveraging range directly could be a bit cleaner (and I think would cover the conditionals that are in place?):
id: >-
{{ $dynamicAMI := "" -}}
{{ range $machineset := (lookup "machine.openshift.io/v1beta1" "MachineSet" "openshift-machine-api" "").items -}}
{{ $dynamicAMI = $machineset.spec.template.spec.providerSpec.value.ami.id -}}
{{ break -}}
{{ end -}}
{{ defaultAMI := fromConfigMap "policies" "opp-settings" (printf "%s-%s" (lookup "config.openshift.io/v1" "Infrastructure" "" "cluster").status.platformStatus.aws.region (fromClusterClaim "openshiftversion-major-minor")) }}
{{ default $defaultAMI $dynamicAMI -}}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can improve this as we move forward. A lot of testing has been completed with the current templates.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gparvin, tanfengshuang The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
572fe17
into
open-cluster-management-io:main