When using AWS EKS, is it possible to set up the worker nodes on spot instances? how? Anything I special I should pay attention to, in such a setup?
1 Answer
It can be done by modifying the Cloudformation Template (which is mentioned in this document) in the LaunchConfiguration
section to specify a spot price.
NodeLaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
SpotPrice: "20" # <=== Here
AssociatePublicIpAddress: 'true'
IamInstanceProfile: !Ref NodeInstanceProfile
ImageId: !Ref NodeImageId
InstanceType: !Ref NodeInstanceType
KeyName: !Ref KeyName
SecurityGroups:
- !Ref NodeSecurityGroup
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
VolumeSize: !Ref NodeVolumeSize
VolumeType: gp2
DeleteOnTermination: true
UserData:
Fn::Base64:
!Sub |
#!/bin/bash
set -o xtrace
/etc/eks/bootstrap.sh ${ClusterName} ${BootstrapArguments}
/opt/aws/bin/cfn-signal --exit-code $? \
--stack ${AWS::StackName} \
--resource NodeGroup \
--region ${AWS::Region}