-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PUC-598: create or set baremetal flavours
- Loading branch information
1 parent
2503119
commit 2c1121f
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
workflows/argo-events/workflowtemplates/baremetal-flavor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
apiVersion: argoproj.io/v1alpha1 | ||
metadata: | ||
name: baremetal-flavor | ||
annotations: | ||
workflows.argoproj.io/title: Set or Create flavors for use with the Bare Metal service | ||
workflows.argoproj.io/description: | | ||
Defined in `workflows/argo-events/workflowtemplates/baremetal-flavor.yaml` | ||
Set or create a flavor with specified properties if it does not already exist. | ||
kind: WorkflowTemplate | ||
spec: | ||
serviceAccountName: workflow | ||
entrypoint: main | ||
arguments: | ||
parameters: | ||
- name: flavors | ||
value: | ||
'[{"name": "gp2.small", "properties": "--property resources:CUSTOM_BAREMETAL_GP2SMALL=1 --property resources:VCPU=0 --property resources:MEMORY_MB=0 --property resources:DISK_GB=0"}, | ||
{"name": "gp3.medium", "properties": "--property resources:CUSTOM_BAREMETAL_GP3MEDIUM=1 --property resources:VCPU=2 --property resources:MEMORY_MB=4096 --property resources:DISK_GB=40"}]' | ||
|
||
templates: | ||
- name: main | ||
inputs: | ||
parameters: | ||
- name: flavors | ||
steps: | ||
- - name: create-flavor | ||
template: create-flavor | ||
arguments: | ||
parameters: | ||
- name: flavor_name | ||
value: "{{item.name}}" | ||
- name: flavor_properties | ||
value: "{{item.properties}}" | ||
withParam: "{{inputs.parameters.flavors}}" | ||
|
||
- name: create-flavor | ||
inputs: | ||
parameters: | ||
- name: flavor_name | ||
- name: flavor_properties | ||
script: | ||
image: ghcr.io/rackerlabs/understack/openstack-client:2024.2-ubuntu_jammy | ||
command: [sh] | ||
source: | | ||
echo "Checking if flavor '{{inputs.parameters.flavor_name}}' exists..." | ||
flavor_name=$(openstack --os-cloud understack flavor show '{{inputs.parameters.flavor_name}}' -f value -c name 2>/dev/null) | ||
echo "$flavor_name" | ||
if [ "$flavor_name" = "{{inputs.parameters.flavor_name}}" ]; then | ||
echo "Setting flavor '{{inputs.parameters.flavor_name}}' with properties {{inputs.parameters.flavor_properties}}" | ||
result=$(openstack flavor set '{{inputs.parameters.flavor_name}}' {{inputs.parameters.flavor_properties}}) | ||
else | ||
echo "Creating flavor '{{inputs.parameters.flavor_name}}' with properties {{inputs.parameters.flavor_properties}}" | ||
result=$(openstack flavor create '{{inputs.parameters.flavor_name}}' {{inputs.parameters.flavor_properties}}) | ||
fi | ||
echo "$result" | ||
env: | ||
- name: OS_CLOUD | ||
value: understack | ||
volumeMounts: | ||
- mountPath: /etc/openstack | ||
name: openstack-svc-acct | ||
readOnly: true | ||
|
||
volumes: | ||
- name: openstack-svc-acct | ||
secret: | ||
secretName: openstack-svc-acct |