Last active
October 19, 2022 01:11
-
-
Save nastacio/7e66f871e395cdbec759d832416f7093 to your computer and use it in GitHub Desktop.
Clone and modify machine sets in OCP cluster
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
#!/bin/sh | |
infra_id=$(kubectl get Infrastructure cluster -o jsonpath='{.status.infrastructureName}') | |
instance_size=${1:-c5a.xlarge} | |
kubectl get MachineSet \ | |
-n openshift-machine-api \ | |
-l hive.openshift.io/machine-pool=worker \ | |
-l hive.openshift.io/managed=true \ | |
-o yaml \ | |
| yq 'del (.items[].status)' \ | |
| yq 'del (.items[].metadata.annotations)' \ | |
| yq 'del (.items[].metadata.uid)' \ | |
| yq 'del (.items[].metadata.resourceVersion)' \ | |
| yq 'del (.items[].metadata.generation)' \ | |
| yq 'del (.items[].metadata.creationTimestamp)' \ | |
| yq 'del (.items[].metadata.labels."hive.openshift.io/managed")' \ | |
| yq 'del (.items[].metadata.labels."hive.openshift.io/machine-pool")' \ | |
| yq '.items[].metadata.labels += { "machine.sourcepatch.com/interruptible": "true" }' \ | |
| yq '.items[].spec.template.metadata.labels += { "machine.sourcepatch.com/interruptible": "true" }' \ | |
| yq '.items[].spec.template.spec.providerSpec.value.spotMarketOptions={}' \ | |
| yq '.items[].spec.template.spec.taints += [{ "effect": "NoSchedule", "key": "workload.sourcepatch.com/interruptible", "value": "true" }]' \ | |
| yq '.items[].spec.template.spec.metadata.labels += { "sourcepatch.com/node.interruptible": "true"}' \ | |
| yq ".items[].spec.template.spec.providerSpec.value.instanceType= \"${instance_size:?}\"" \ | |
| sed "s/name: ${infra_id:?}-worker/name: ${infra_id:?}-worker-spot/" \ | |
| sed "s/machineset: ${infra_id:?}-worker/machineset: ${infra_id:?}-worker-spot/" \ | |
| kubectl apply -f - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment