Goglides Dev 🌱

Balkrishna Pandey
Balkrishna Pandey

Posted on • Updated on

Openshift MachineSet clone and update machinetype

INSTANCE_TYPE="g4dn.4xlarge"
#INSTANCE_TYPE="g6e.2xlarge"

BASE_MS=$(oc -n openshift-machine-api get machinesets -o name | grep worker | head -n1)
[ -z "$BASE_MS" ] && echo "No worker MachineSet found" && exit 1

CLUSTER_ID=$(oc get "$BASE_MS" -n openshift-machine-api -o jsonpath='{.metadata.labels.machine\.openshift\.io/cluster-api-cluster}')
ZONE=$(oc get "$BASE_MS" -n openshift-machine-api -o jsonpath='{.spec.template.spec.providerSpec.value.placement.availabilityZone}')
REGION="${ZONE%-*}"

oc get "$BASE_MS" -n openshift-machine-api -o yaml | \
  sed \
    -e "s/instanceType: .*/instanceType: ${INSTANCE_TYPE}/" \
    -e "s/name: ${CLUSTER_ID}-worker-${ZONE}/name: ${CLUSTER_ID}-gpu-${ZONE}/" \
    -e "s/cluster-api-machineset: ${CLUSTER_ID}-worker-${ZONE}/cluster-api-machineset: ${CLUSTER_ID}-gpu-${ZONE}/g" \
    -e "s/replicas: [0-9]*/replicas: 0/" \
    -e "/iamInstanceProfile/!s/-worker/-gpu/g" \
  | oc apply -f -

Enter fullscreen mode Exit fullscreen mode
  • Verify whether the specified instance type is available in your chosen region.
  • g5g.* instance types provide Arm-based CPUs with NVIDIA GPUs, but they are not available in us-east-2:
aws ec2 describe-instance-type-offerings \
   --location-type availability-zone \
   --filters Name=instance-type,Values=g5g.* \
   --region us-east-2

# Output
{
    "InstanceTypeOfferings": []
}
Enter fullscreen mode Exit fullscreen mode

This indicates that g5g.* instances are not supported in the us-east-2 region.

Top comments (0)