Enabling Amazon Spot Instance support for node pools
Enable Amazon Spot Instances for your compute nodes in hosted cluster node pools to reduce cloud infrastructure costs for non-critical and fault-tolerant workloads.
-
You set up Amazon Simple Queue Service (SQS) and Amazon EventBridge to receive Amazon EC2 interruption events.
-
You have the URL of your Amazon SQS queue, which you created in "Configuring Amazon SQS and Amazon EventBridge to receive Amazon EC2 interruption events".
-
Set the Amazon SQS queue URL on your hosted cluster.
-
If you are setting the SQS queue URL on a new hosted cluster, take the following steps:
-
Configure the
HostedClusterresource as follows:apiVersion: hypershift.openshift.io/v1beta1 kind: HostedCluster metadata: name: <my_hosted_cluster> namespace: <my_hosted_cluster_namespace> spec: platform: type: AWS aws: region: us-east-1 terminationHandlerQueueURL: "https://sqs.us-east-1.amazonaws.com/123456789012/my-cluster-spot-interruption-queue" ...where:
spec.platform.aws.terminationHandlerQueueURL-
Specifies the SQS queue URL.
-
Apply the configuration by entering the following command:
$ oc apply -f <hosted_cluster_config>.yaml
-
-
If you are setting the SQS queue URL on an existing hosted cluster, patch the
HostedClusterresource as follows:$ oc patch hostedcluster my-cluster -n clusters --type merge -p '{ "spec": { "platform": { "aws": { "terminationHandlerQueueURL": "https://sqs.us-east-1.amazonaws.com/123456789012/my-cluster-spot-interruption-queue" } } } }'
-
-
Create a
NodePoolobject that has the Spot market type configured, as shown in the following example:apiVersion: hypershift.openshift.io/v1beta1 kind: NodePool metadata: name: spot-workers namespace: <my_hosted_cluster_namespace> spec: clusterName: <my_hosted_cluster> replicas: 3 release: image: quay.io/openshift-release-dev/ocp-release:4.22.0-x86_64 management: autoRepair: true upgradeType: Replace platform: type: AWS aws: instanceType: m5.xlarge instanceProfile: my-cluster-worker rootVolume: size: 120 type: gp3 placement: marketType: SpotmarketType: Spot-
Specifies that all
Machineobjects andNodeobjects have thehypershift.openshift.io/interruptible-instancelabel and that the EC2 instances have theaws-node-termination-handler/managedtag so they can be identified by the termination-handling components. You can specifyspotoptions only when themarketTypefield is set toSpot.
-
Apply the configuration by entering the following command:
$ oc apply -f <node_pool_config>.yaml