Documentation
July-2025
Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
Spot Go SDK
Copy Markdown
Open in ChatGPT
Open in Claude
Overview
The Rackspace Spot Go SDK is an idiomatic Go client library for programmatically managing Rackspace Spot resources. It provides a clean, type-safe interface for automating your cloud infrastructure management.
Installation
Add the SDK to your Go project:
Bash
go get github.com/rackspace-spot/spot-go-sdk/api/v1Then import it in your code:
Go
import v1 "github.com/rackspace-spot/spot-go-sdk/api/v1" Authentication
Obtaining a Refresh Token
- Navigate to Rackspace Spot API Access
- Generate or copy your Refresh Token
Creating a Client
Create a SpotClient with your refresh token:
Go
x
package mainimport ( "context" "fmt" "log" v1 "github.com/rackspace-spot/spot-go-sdk/api/v1")func main() { // Initialize the Spot client spotClient, err := v1.NewSpotClient(&v1.Config{ RefreshToken: "<YOUR_REFRESH_TOKEN>", // Replace with Refresh Token or set in ENV }) if err != nil { log.Fatalf("Failed to create client: %v", err) } // Authenticate and obtain access token _, err = spotClient.Authenticate(context.Background()) if err != nil { log.Fatalf("Failed to authenticate: %v", err) } fmt.Println("Successfully authenticated!")}Tip: Set SPOT_REFRESH_TOKEN as an environment variable instead of hardcoding it in your config.
Quick Start
List Available Regions
Go
ctx := context.Background()regions, err := spotClient.ListRegions(ctx)if err != nil { log.Fatalf("Failed to list regions: %v", err)}fmt.Println("Available Regions:")for _, region := range regions { fmt.Printf(" - %s: %s\n", region.Name, region.Description)}Create a Cloudspace (K8s Cluster)
Go
ctx := context.Background()// Define a spot node pool with 3 workersspotPool := v1.SpotNodePool{ Name: "my-spot-pool", Org: "my-org", Cloudspace: "my-cluster", ServerClass: "ch.vs1.large-dfw", Desired: 3, BidPrice: "$0.08", CustomLabels: map[string]string{ "environment": "production", "team": "platform", },}// Create the cloudspace with new nodepoolerr := spotClient.CreateCloudspace(ctx, v1.CloudSpace{ Name: "my-cluster", Org: "my-org", KubernetesVersion: "1.31.1", CNI: "calico", Region: "us-east-iad-1", SpotNodepools: []*v1.SpotNodePool{&spotPool},})if err != nil { log.Fatalf("Failed to create cloudspace: %v", err)}fmt.Println("Cloudspace created successfully!")Query Market Pricing
Go
ctx := context.Background()// Get pricing for a specific server classpricing, err := spotClient.GetPriceDetailsForServerClass(ctx, "ch.vs1.large-dfw")if err != nil { log.Fatalf("Failed to get pricing: %v", err)}fmt.Printf("Server Class: %s\n", pricing.ServerClassName)fmt.Printf("Current Market Price: %s/hour\n", pricing.MarketPrice)fmt.Printf("Region: %s\n", pricing.Region)fmt.Printf("CPU: %s | Memory: %s\n", pricing.CPU, pricing.Memory)Full Example: See examples/main.go for a complete cloudspace lifecycle example.
API Reference
Authentication
| Method | Description |
|---|---|
Authenticate(ctx) | Authenticate with refresh token and obtain access token |
Organizations
| Method | Description |
|---|---|
ListOrganizations(ctx) | List all organizations accessible to your account |
Cloudspaces
| Method | Description |
|---|---|
CreateCloudspace(ctx, cloudspace) | Create a new Kubernetes cluster with node pools |
ListCloudspaces(ctx, org) | List all cloudspaces in an organization |
GetCloudspace(ctx, org, name) | Retrieve details of a specific cloudspace |
GetCloudspaceConfig(ctx, org, name) | Download the kubeconfig for a cloudspace |
DeleteCloudspace(ctx, org, name) | Delete a cloudspace and all associated resources |
Spot Node Pools
| Method | Description |
|---|---|
CreateSpotNodePool(ctx, org, pool) | Add a new spot node pool to a cloudspace |
ListSpotNodePools(ctx, org, cloudspace) | List all spot node pools in a cloudspace |
GetSpotNodePool(ctx, org, name) | Get details of a specific spot node pool |
UpdateSpotNodePool(ctx, org, pool) | Update spot node pool configuration |
DeleteSpotNodePool(ctx, org, name) | Remove a spot node pool from a cloudspace |
On-Demand Node Pools
| Method | Description |
|---|---|
CreateOnDemandNodePool(ctx, org, pool) | Add an on-demand node pool to a cloudspace |
ListOnDemandNodePools(ctx, org, cloudspace) | List all on-demand node pools in a cloudspace |
GetOnDemandNodePool(ctx, org, name) | Get details of an on-demand node pool |
UpdateOnDemandNodePool(ctx, org, pool) | Update on-demand node pool configuration |
DeleteOnDemandNodePool(ctx, org, name) | Remove an on-demand node pool |
Regions
| Method | Description |
|---|---|
ListRegions(ctx) | List all available Rackspace Spot regions |
GetRegion(ctx, name) | Get details about a specific region |
Server Classes
| Method | Description |
|---|---|
ListServerClasses(ctx, region) | List all server classes available in a region |
GetServerClass(ctx, name) | Get specifications for a server class |
Pricing
| Method | Description |
|---|---|
GetPriceDetails(ctx) | Get pricing for all server classes |
GetPriceDetailsForServerClass(ctx, serverClass) | Get pricing for a specific server class |
GetPriceDetailsForRegion(ctx, region) | Get pricing for all server classes in a region |
GetMarketPriceForServerClass(ctx, status) | Get current market price for a server class |
GetMinimumBidPriceForServerClass(ctx, spec) | Get minimum acceptable bid price |
Data Types
CloudSpace
Go
type CloudSpace struct { Name string Org string KubernetesVersion string CNI string // "calico" or "cilium" Region string SpotNodepools []*SpotNodePool OnDemandNodePools []*OnDemandNodePool Status string APIServerEndpoint string PreemptionWebhookURL string}SpotNodePool
Go
type SpotNodePool struct { Name string Org string Cloudspace string ServerClass string Desired int BidPrice string // e.g., "$0.08" CustomAnnotations map[string]string CustomLabels map[string]string CustomTaints []interface{} Autoscaling struct { Enabled bool MinNodes int64 MaxNodes int64 } Status string WonCount int}OnDemandNodePool
Go
type OnDemandNodePool struct { Name string Org string Cloudspace string ServerClass string Desired int OnDemandPricePerHour string CustomAnnotations map[string]string CustomLabels map[string]string CustomTaints []interface{} Autoscaling struct { Enabled bool MinNodes int MaxNodes int } Status string WonCount int} Contributing
This is an open source project. Contributions are welcome!
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Submit a pull request
Resources
Support: For issues, open a GitHub issue. For security concerns, email product@rackspace.com.
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
Last updated on
Was this page helpful?
Next to read:
Data-center Locations© 2023 RACKSPACE TECHNOLOGY
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message
On This Page
Spot Go SDKOverview Installation AuthenticationObtaining a Refresh TokenCreating a Client Quick StartList Available RegionsCreate a Cloudspace (K8s Cluster)Query Market Pricing API Reference Authentication Organizations Cloudspaces Spot Node Pools On-Demand Node Pools Regions Server Classes Pricing Data TypesCloudSpaceSpotNodePoolOnDemandNodePool Contributing Resources