Amazon EC2 Spot Instances let you take advantage of unused EC2 capacity in AWS. Spot Instances are available at up to a 90% discount compared to On-Demand prices. You can now use Spot Instances for Worker nodes in OpenShift 4.5. This feature is exclusively available on AWS and provides easy access to unused compute capacity at such massive scale at discounted rates up to 90%. 

Spot instances can be interrupted with a 2 minute warning. Spot termination notification: is 2 minute warning from AWS that the spot instance will be removed. This could manifest as part of the desired spot price exceeding the max desired cost, or if on demand capacity of EC2 increases. As a best practice define a Max Price: which should be lower or equal to the on demand price. 

Application workloads making use of spot need to cater for possible interruption. Application workloads already architected according to AWS best practices, designed for scaling, make use of disposable resources, and are loosely coupled make good possible candidates for spot.

Simply put what is the resulting impact on an application workload if the underlying host was removed. 

OpenShift and Spot support are a great compliment. Sport provides cost effective compute for workloads and OpenShift provides container orchestration across these Spot worker nodes. Should a Spot node be replaced or reclaimed, OpenShift can shift the application workload to another worker node and manage storage,  and routing of the application making this invisible to the customer. 

OpenShift MachineSets now support Spot instances. This lets you create a MachineSet that deploys machines as Spot instances so you can save costs compared to on-demand instance prices, for the OpenShift worker node. 

We will now walk you through adding Sport instances to your OpenShift cluster

First, check the existing MachineSet from your cluster:

Mayurs-MacBook-Pro:4.5 mshetty$ oc get machineset -n openshift-machine-api
NAME                         DESIRED   CURRENT   READY   AVAILABLE   AGE
mytest-rbn2l-worker-us-west-2a   1     1     1   1       173m
mytest-rbn2l-worker-us-west-2b   1     1     1   1       173m
mytest-rbn2l-worker-us-west-2c   1     1     1   1       173m
mytest-rbn2l-worker-us-west-2d   0     0                         173m

Next, you can configure Spot instances by adding the following line under the providerSpec field in the MachineSet YAML file:

Mayurs-MacBook-Pro:4.5 mshetty$ oc edit machineset mytest-rbn2l-worker-us-west-2a -n openshift-machine-api

   spec:
  metadata: {}
  providerSpec:
    value:
      spotMarketOptions: {}
      userDataSecret:
        name: worker-user-data
      placement:
        availabilityZone: us-west-2a
        region: us-west-2

Verify, the edit as follows:

Mayurs-MacBook-Pro:4.5 mshetty$ oc describe machineset mytest-rbn2l-worker-us-west-2a -n openshift-machine-api
        Filters:
          Name:  tag:Name
          Values:
            mytest-rbn2l-worker-sg
      Spot Market Options:
      Subnet:
        Filters:
          Name:  tag:Name
          Values:
            mytest-rbn2l-private-us-west-2a
      Tags:
        Name:   kubernetes.io/cluster/mytest-rbn2l
        Value:  owned
      User Data Secret:
        Name:  worker-user-data
Status:
 Available Replicas:  1
 Fully Labeled Replicas:  1
 Observed Generation: 2
 Ready Replicas:      1
 Replicas:            1
Events:                <none>

To scale particular machineset ie. get more machines allocated,  run the following

Mayurs-MacBook-Pro:4.5 mshetty$ oc scale machineset --replicas=3 mytest-rbn2l-worker-us-west-2a  -n openshift-machine-api

We can see that the machineset has scaled to 3:

Mayurs-MacBook-Pro:4.5 mshetty$ oc get machineset -n openshift-machine-api
NAME                         DESIRED   CURRENT   READY   AVAILABLE   AGE
mytest-rbn2l-worker-us-west-2a   3     3     3   3       3h45m
mytest-rbn2l-worker-us-west-2b   1     1     1   1       3h45m
mytest-rbn2l-worker-us-west-2c   1     1     1   1       3h45m
mytest-rbn2l-worker-us-west-2d   0     0                         3h45m

As we see in the OpenShift Console 

Also, on the AWS console we can see that 2 additional Spot instance have been allocated for our OpenShift worker node.

 

Finally, we can see that all our OpenShift nodes, including the new Spot instance nodes, are part of the cluster.

 Mayurs-MacBook-Pro:4.5 mshetty$ oc get nodes
NAME                                     STATUS   ROLES AGE VERSION
ip-10-0-138-208.us-west-2.compute.internal   Ready worker   57m v1.18.3+002a51f
ip-10-0-145-156.us-west-2.compute.internal   Ready master   3h57m   v1.18.3+002a51f
ip-10-0-145-77.us-west-2.compute.internal Ready worker   53m v1.18.3+002a51f
ip-10-0-154-211.us-west-2.compute.internal   Ready worker   3h48m   v1.18.3+002a51f
ip-10-0-160-115.us-west-2.compute.internal   Ready worker   3h48m   v1.18.3+002a51f
ip-10-0-176-254.us-west-2.compute.internal   Ready master   3h57m   v1.18.3+002a51f
ip-10-0-201-73.us-west-2.compute.internal Ready worker   3h48m   v1.18.3+002a51f
ip-10-0-218-57.us-west-2.compute.internal Ready master   3h57m   v1.18.3+002a51f

Conclusion

I suggest trying Spot Instances with your OpenShift 4.5 deployment on AWS. Using Spot instances will allow you to cut costs of running OpenShift clusters on cloud providers by moving interruptible workloads onto non-guaranteed instances.


Categories

How-tos, Cost Management, OpenShift 4.5, AWS

< Back to the blog