Create an Environment API Key
- Follow the instructions here: https://rancher.com/docs/rancher/v2.x/en/user-settings/api-keys/
- Save the access and secret keys for use in the Elastigroup configuration
Add Custom Hosts
- Spotinst integrates with Rancher 2.0 through the custom cluster configuration.
- Once Custom is selected copy and save the registration command used to add new workers to the cluster. This will be used later to build the instance userData.
Create an Elastigroup
From the registration command that was saved when creating a custom cluster, fill in the
<> below with the rancher url, token and checksum.
This will create an instance running Rancher OS with a Rancher Labs supported version of docker. For AWS, it will also add a label identifying the instance ID of the worker.
#cloud-config rancher: docker: engine: docker-17.03.2-ce write_files: - path: /etc/rc.local permissions: "0755" owner: root content: | #!/bin/bash wait-for-docker docker pull rancher/curl docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.0.6 --server <RANCHER_URL> --token <TOKEN> --ca-checksum <CHECKSUM> --worker --label spotinst.instanceId=$(docker run rancher/curl http://169.254.169.254/latest/meta-data/instance-id)
Once the userData is set, the next step is to configure the Rancher 2.0 Elastigroup integration. For Rancher 2.0+ Elastigroup needs to integrate with both the Rancher master server as well as the underlying Kubernetes cluster.
For Rancher enter:
- Host: URL to the host of the Rancher 2.0 master. Remove any path or trailing forward slash. Ex: https://myrancherhost.com
- Access Key: copied from key creation above
- Secret Key: copied from key creation above
For k8s enter:
- Integration Mode: IN-CLUSTER
- Cluster Identifier: A unique name that can be the same as the Elastigroup name. This will be used in the final step.
- Autoscaling: We highly recommend Automatic Autoscaling.
Deploy the Spotinst Controller
Last, follow these steps to deploy Spotinst’s Controller in the Kubernetes cluster. Once this is deployed Spotinst scales and manages Kubernetes nodes, and interacts with Rancher to ensure that available and cordoned instances are rolled and cleaned correctly.
Installing the Spotinst Controller requires the following:
- Spotinst Token: Generated from the Spotinst Console
- Spotinst Account ID: Can be retrieved from the Console
- Cluster Identifier: Created in the previous step
Complete the Spotinst Controller Installation Tutorial.
That’s it! Elastigroup can now manage the underlying nodes of your Kubernetes cluster and communicate with Rancher.