Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Machineset for create bare metal nodes in AWS
#!/usr/bin/env bash
export REGION="eu-west-1"
export AZS="${REGION}a ${REGION}b ${REGION}c"
export FLAVOR="m5.metal"
MACHINESET_PREFIX=$(oc get machineset -n openshift-machine-api -o json| jq '.items[0].metadata.labels.""' | tr -d '""')
for AZ in ${AZS}; do
export NAME="${MACHINESET_PREFIX}-metal-${AZ}"
export AZ=$AZ
export SUBNET=${MACHINESET_PREFIX}-private-${AZ}
echo " ** Generating JSON for Infra node $NAME (AZ: ${AZ})"
oc get machineset -n openshift-machine-api -o json\
| jq '.items[0]' \
| jq '["NAME"]'\
| jq '.metadata.selfLink=""'\
| jq '.metadata.uid=""'\
| jq '.spec.selector.matchLabels.""=env["NAME"]'\
| jq '.spec.template.metadata.labels.""=env["NAME"]'\
| jq '.spec.template.spec.providerSpec.value.placement.availabilityZone=env["AZ"]'\
| jq '.spec.template.spec.providerSpec.value.placement.region=env["REGION"]'\
| jq '.spec.template.spec.metadata.labels.""=""'\
| jq '.spec.template.spec.providerSpec.value.subnet.filters[0].values[0]=env["SUBNET"]' \
| jq 'del (.metadata.annotations)' \
| jq '.spec.template.spec.providerSpec.value.instanceType=env["FLAVOR"]' \
> ./metal-machineset-$NAME.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment