fbpx

We are now ready to create our cluster!

Here’s how to get started:

Option 1: Create A New Cluster

  1. Download the Spotinst’s KOPS binary.
  2. Verify the required scripts from prerequisites are available. if not, Download the updated scripts and open the archive file.
  3. Set your required cluster variables in the downloaded 00-env.sh.
  4. Execute 01-create.sh.

 

Option 2: Migrate an existing cluster managed by AWS Auto Scaling Groups to Spotinst Ocean

Migration of existing deployment will consist of two separate layers: master nodes and worker nodes’ Instance Group(s). Begin with the master nodes then import the workers

NOTE: Ensure that you are in the correct cluster context for kubectl.

    1. Master nodes: to perform the migration with no downtime, migrate the masters one-by-one. Choose the scenario below that matches the current deployment
      1. Scenario 1: For deployments of master nodes in individual Auto Scaling Groups
        1. For each master ASG:
          1. Drain the node 
            1. kubectl drain <node>
          2. Scale down the Auto Scaling Group by one instance 
            1. Set target, min, max to 0,0,0
          3. Import the Auto Scaling Group into Spotinst Elastigroup. Make sure to specify the following during Elastigroup creation:
            1. The Elastigroup’s name equals by default to the Auto Scaling Group name, don’t change its name. 
            2. Masters are recommended to run as On-Demand instances. 
              • Switch to the General tab, and under Advanced set the Spot Percentage to 0.
        2. Repeat the steps with the remaining master nodes, until all nodes are running in Spotinst, and all masters Auto Scaling Groups were downscaled to zero. 
      2. Scenario 2: If all masters are running in the same Auto Scaling Group 
        1. Drain one master node in the ASG 
          1. kubectl drain <node>
        2. Scale down the Auto Scaling Group by one instance 
          1. Set target, min, max to 1 less than before.
        3. Import the Auto Scaling Group into Spotinst Elastigroup. Make sure to specify the following during Elastigroup creation:
          1. The Elastigroup’s name equals by default to the Auto Scaling Group name, don’t change its name. 
          2. Masters are recommended to run as On-Demand instances. 
            1. Switch to the General tab, and under Advanced set the Spot Percentage to 0.
          3. Initially set target, min, max to 1,1,1.
          4. Verify new node in Elastigroup has joined the K8s cluster
        4. Repeat steps ii 1-2 for the next master node.
        5. Increase the capacity of your master Elastigroup by 1.
        6. Repeat steps 4-5 for remaining master(s).
    2. Enable Spotinst support by toggling the feature flag. On the management station where KOPS commands are run:
      1. export KOPS_FEATURE_FLAGS="+Spotinst,SpotinstOcean"
    3. Make sure that Spotinst environment variables are defined on the KOPS management server:
      1. SPOTINST_TOKEN and SPOTINST_ACCOUNT
    4. Worker Nodes
      1. In the case of multiple worker nodes Instance Groups:
        1. Set the Ocean default launch specification label on your primary Instance Group. Example:
          1. apiVersion: kops/v1alpha2
            kind: InstanceGroup
            metadata:
             labels:
               kops.k8s.io/cluster: kops.ek8s.com
               spotinst.io/fallback-to-ondemand: "false"          # defaults to true
               spotinst.io/utilize-reserved-instances: "false"   # defaults to true
               spotinst.io/autoscaler-disabled: "true"                # defaults to false
               spotinst.io/autoscaler-default-node-labels: "true" # defaults to false
               spotinst.io/ocean-default-launchspec: "true" # defaults to false
             name: nodes
            spec:
            
        2. Using Ocean, import the primary instance Group associated Auto Scaling Group to Spotinst
          1. This can be done via the Console or via API.
        3. Run KOPS Update
          1. Kops will now identify and create the missing launch specifications on your Ocean Cluster.
        4. Gradually scale down your Auto Scaling Groups
          1. Ocean will automatically provision the required instances to ensure your pods are scheduled.
      2. In a case of a single Instance Group:
        1. Using Ocean, import your Auto Scaling Group to Spotinst
          1. This can be done via the Console or via API.
        2. Gradually scale down your Auto Scaling Groups
          1. Ocean will automatically provision the required instances to ensure your pods are scheduled.
      3. Clean up (optional):
        1. Delete all Auto Scaling Groups.
        2. Delete all Launch Configurations.