Skip to content

Instantly share code, notes, and snippets.

@mulbc
Last active May 18, 2022 10:46
Show Gist options
  • Save mulbc/57e40abaef48ff01d6e257a2c54848b4 to your computer and use it in GitHub Desktop.
Save mulbc/57e40abaef48ff01d6e257a2c54848b4 to your computer and use it in GitHub Desktop.
Creates a machineset for ODF based on an existing machineset (only for VMWARE IPI)
#!/bin/bash
MACHINESET=$(oc get -n openshift-machine-api machinesets -o name | grep -v ocs | head -n1)
oc get -n openshift-machine-api "$MACHINESET" -o json | jq '
del( .metadata.uid, .metadata.managedFields, .metadata.selfLink, .metadata.resourceVersion, .metadata.creationTimestamp, .metadata.generation, .status) |
(.metadata.name, .spec.selector.matchLabels["machine.openshift.io/cluster-api-machineset"], .spec.template.metadata.labels["machine.openshift.io/cluster-api-machineset"]) |= sub("worker";"ocs") |
(.spec.template.spec.providerSpec.value.numCPUs) |= 16 |
(.spec.template.spec.providerSpec.value.memoryMiB) |= 61036 |
(.spec.template.spec.metadata.labels["cluster.ocs.openshift.io/openshift-storage"]) |= ""' | oc apply -f -
OCS_MACHINESET=$(oc get -n openshift-machine-api machinesets -o name | grep ocs)
oc scale -n openshift-machine-api "$OCS_MACHINESET" --replicas=3
oc scale -n openshift-machine-api "$MACHINESET" --replicas=1
@likid0
Copy link

likid0 commented May 18, 2022

Hi @mulbc , there is an issue with the cluster.ocs.openshift.io/openshift-storage label not getting applied, to get it working the path I used was the following '(.spec.template.spec.metadata.labels["cluster.ocs.openshift.io/openshift-storage"])'. Thanks!

@mulbc
Copy link
Author

mulbc commented May 18, 2022

Fixed, thanks @likid0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment