Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Adds Spot Instance use in docs
Browse files Browse the repository at this point in the history
Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
  • Loading branch information
JoshVanL committed Sep 10, 2018
1 parent f4a4d3a commit f1c7485
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions docs/user-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,39 @@ policy permissions. `Information on how to correctly set these permissions can
be found here
<https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html#attach-bucket-policy>`_.

Spot Instances
~~~~~~~~~~~~~~
Tarmak gives the ability to attempt to request spot instances for use in
instance pools. Spot instances are very cheap, spare AWS instances that can be
revoked by AWS at any time, given a 2 minute notification. `More information
here <https://aws.amazon.com/ec2/spot/>`_.

Spot instances can be requested cluster-wide by giving the ``--spot-pricing``
flag to ``cluster apply``. Tarmak will then attempt a best effort spot price for
each instance pool in the cluster, calculated as the average spot price in the
last 3 days for that instance type in each zone plus 25%.

Manual spot prices can be applied to each instance pool within the
``tarmak.yaml`` which will override the Tarmak best effort for that instance
pool. This is done through the ``spotPrice`` attribute under the instance pool,
given as a number in USD. This can be added like so:

.. code-block:: yaml
- image: centos-puppet-agent
maxCount: 3
metadata:
creationTimestamp: "2018-07-27T09:33:15Z"
name: worker
minCount: 3
size: medium
spotPrice: 0.015
Note that Tarmak will only attempt to create spot instances for instance pools
with the ``spotPrice`` attribute or spot pricing flag during a cluster apply.


Cluster Services
----------------

Expand All @@ -721,3 +754,4 @@ Do the following steps to access Grafana:
.. code-block:: none
http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy/
2 changes: 1 addition & 1 deletion pkg/tarmak/instance_pool/instance_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (n *InstancePool) SpotPrice() string {
}

func (n *InstancePool) CalculateSpotPrice() error {
if n.spotPrice != "" {
if n.spotPrice == "" {
p, err := n.cluster.Environment().Provider().SpotPrice(n)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/tarmak/provider/amazon/spot_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (a *Amazon) SpotPrice(instancePool interfaces.InstancePool) (float64, error
total /= float64(len(prices))
}

total *= 1.10
total *= 1.25

return total, result.ErrorOrNil()
}

0 comments on commit f1c7485

Please sign in to comment.