BLOG

Provisioning clusters: Spinning up cost-effective clusters for training sessions

January 16, 2023
Mohan Atreya

We have been running a number of internal and external enablement sessions with partnersand customers over the last few weeks to provide "hands-on, labs-based training" on some recently introduced capabilities in the Rafay KubernetesOperations Platform. Here's what we set up for those enablement sessions:

  • Each attendee was provided with their own Kubernetes cluster
  • We spun up ~25 "ephemeral" Kubernetes clusters on Digital Ocean (for life of the session)
  • We needed the clusters to be provisioned in just a few minutes for the training exercise
  • Each attendee had their own dedicated "Project" in the Rafay Org

A question that we frequently got asked after those enablement sessions was "I would love to run similar sessions with my extended team, how much did it cost to run those clusters?". Our total spend for ~25 ephemeral clusters on Digital Ocean for these enablement sessions was less than $15. It was no wonderthere has been so much interest in this. We decided that it would help everyone if we shared the automation scripts and the methodology we have beenusing to provision Digital Ocean clusters and to import them to Rafay's platform here.

Install Digital Ocean's CLI

Install and configure (doctl) by following the instructions outlined here.

Install Rafay CLI

Install and configure the Rafay Platform's CLI (RCTL) by following the instructions outlined here.

Provision Clusters

  • Create a cluster_list file and add entries for each cluster that needs to be created (e.g. john-test, dave-test)
  • Use the sample script below

# Create clusters through DO CTL

while read -r line

do

doctl kubernetes cluster create $line --node-pool "name=$line;size=s-4vcpu-8gb;count=1"

echo "$line"

done < cluster_list.txt # Create folders to copy cluster spec and bootstrap files mkdir clusterspec mkdir clusterbootstrap # Creating cluster spec files while read -r line do echo "kind: Cluster\nmetadata:\n name: $line\n project: $line\nspec:\n type: imported\n blueprint: minimal\n location: newyorkcity-us" >> clusterspec/clusterspec_$line.yaml

done < cluster_list.txt



# Reference your RCTL config here

./rctl config init



# Create a project and add the DO clusters as an imported cluster within that project

while read -r line

do

# Create a Project in the Org for the User

./rctl create project $line

# Set context to the newly created project

./rctl config set project $line

./rctl create cluster -f clusterspec/clusterspec_$line.yaml

./rctl get clusterbootstrap $line -o yaml > clusterbootstrap/$line-bootstrap.yaml

kubectl config use-context do-nyc1-$line

kubectl apply -f clusterbootstrap/$line-bootstrap.yaml

done < cluster_list.txt
In the first step, the script creates clusters in Digital Ocean's NYC1 region with a node each of the type s-4vcpu-8gb under thedefault Digital Ocean project. You can change these parameters as required. In the next step, the script creates two folders, clusterspec andclusterbootstrap. The cluster spec and bootstrap files that are required to import these clusters to Rafay's Kubernetes Operations Platform will becopied to these folders A project is then created (with the same names as the cluster, you can change this if needed) and thecorresponding cluster is imported to this project (with a minimal cluster blueprint). Here's an example of what an imported Kubernetes cluster onDigital Ocean looks like in the Rafay Platform.Clean UpOnce the session is complete, we deleted all the clusters using a single command using the following script. # Delete the cluster using DO CTL

while read -r line

do

kubectl config use-context do-nyc1-$line

yes | doctl kubernetes cluster delete $line

echo "$line"

done < cluster_list.txt
Learn More?Sign up here for a free trial and try it out yourself.Get Started includes a number of hands-on exercises that will help you get familiar withcapabilities of Rafay's Kubernetes Operations Platform.Blog IdeasSincere thanks to those who spend time reading our product blogs and provide us with feedback and ideas. Please [Contact](mailto:product@rafay.co) theRafay Product Team if you would like us to write about specific topics.

Tags:
No items found.
Recent Posts
GPU/Neocloud Billing using Rafay’s Usage Metering APIs
What is Agentic AI?
Deep Dive into nvidia-smi: Monitoring Your NVIDIA GPU with Real Examples
Introduction to Dynamic Resource Allocation (DRA) in Kubernetes
Rethinking GPU Allocation in Kubernetes