Usage examples

How to Use Spawner CLI

How to use Spawner for different Cloud providers

AWS

Create Cluster

To create a cluster. Make sure that you have completed the below steps

  1. Added Access Key and Secrets in your config.env file in spawner folder

  2. To easily manage configurations, you can use JSON files to provide cluster configuration and node configuration needed. You can refer to examples folder in the repo to find a sample cluster creation JSON files.

  3. Here is a sample request.json for creating a cluster

// Some code
{
    "provider": "aws",
    "region": "us-west-2",
    "labels": {
        "fugiat8f": "laboris magna Duis amet"
    },
    "node": {
        "name": "proident",
        "diskSize": 10,
        "labels": {
            "created_by": "alex"
        },
        "instance": "m5.xlarge",
        "gpuEnabled": false
    }
}

Once you have the request.json ready, run the below command to create the cluster

./spawner create-cluster "clustername" -r request.json

Do keep a note of the cluster name. This will be used for the following steps to create nodes

Once you have a cluster created, you can add any type of node to the cluster based on the availability of node types in the region.

Add Node pools to the cluster

Similar to cluster, to create node pool, you can use sample JSON to add different types of nodes that are needed to be added to your cluster

// Some code
{
    "nodeSpec": {
        "diskSize": 31,
        "name": "prosint",
        "count": 3,
        "instance": "m5.xlarge",
        //instead of instance name,
        //can also provide machine type as
        //machineType: "m",
        "labels": {
            "created_by": "cli"
        }
    },
    "region": "us-west-2",
    "clusterName": "my-cluster",
    "provider": "aws"
}

NOTE: you can provide nodepool name in nodespec and the labels can be used to track costs

To add node pools, execute the below command

./spawner nodepool add "clustername" --request request.json

Get cluster status

To get the cluster status, run the below command

./spawner cluster-status "clustername" --provider "aws" -r=us-west-2

Delete Cluster

Delete the existing cluster

./spawner delete-cluster "clustername" --provider "aws" -r=us-west-2

If the cluster has the nodes attached to it, this operation will fail, you can force delete the cluster which deletes attached node and then deletes the cluster.

To force delete set the --force or -f

./spawner delete-cluster "clustername" --provider "aws" -r=us-west-2 --force

Delete nodepool from existing cluster

./spawner nodepool delete "clustername" --provider "aws" -r=region --nodepool nodepoolname

Finally, once you have the cluster created, to use the cluster from normal Kubectl command,, you need to add cluster configuration to kubeconfig file. With spawner, you need not do it manually, you can just follow the below steps to do it automatically.

Get kubeconfg for the cluster

./spawner kubeconfig "clustername" --provider "aws" -r=us-west-2

This will read the existing kube-config from ~/.kube/config and merges new cluster config to it, sets the current context as the requested cluster.

Last updated