Skip to main content
Bare metal servers provide dedicated physical servers with direct hardware access, ideal for high-performance workloads and compliance requirements.

Service Structure

The Baremetal service includes sub-services for managing servers, images, and flavors:
client.Cloud.Baremetal.Servers  // Bare metal server management
client.Cloud.Baremetal.Images   // Bare metal-compatible images
client.Cloud.Baremetal.Flavors  // Available hardware configurations

Server Management

New

Create a new bare metal server.
func (r *BaremetalServerService) New(ctx context.Context, params BaremetalServerNewParams, opts ...option.RequestOption) (*TaskIDList, error)
project_id
int64
required
Project ID
region_id
int64
required
Region ID
flavor
string
required
Bare metal flavor ID (hardware configuration)
interfaces
[]InterfaceUnion
required
Network interface configurations
image_id
string
required
Bare metal-compatible image ID
name
string
Server name
ssh_key_name
string
SSH keypair name
password
string
Password for default user (Linux) or Admin (Windows)
username
string
Username to create (Linux only)
user_data
string
Base64-encoded cloud-init or cloudbase-init script
tags
map[string]string
Key-value tags
id
string
Server UUID
name
string
Server name
status
string
Server status: ACTIVE, BUILD, ERROR, SHUTOFF, etc.
flavor
BaremetalFlavor
Hardware configuration details
addresses
map[string][]Address
Network addresses by network name
Bare metal servers do not support certain features available for VMs:
  • Server groups / placement groups
  • Suspend/resume operations
  • Live migration

List

List all bare metal servers.
func (r *BaremetalServerService) List(ctx context.Context, params BaremetalServerListParams, opts ...option.RequestOption) (*pagination.OffsetPage[BaremetalServer], error)
func (r *BaremetalServerService) ListAutoPaging(ctx context.Context, params BaremetalServerListParams, opts ...option.RequestOption) *pagination.OffsetPageAutoPager[BaremetalServer]

Rebuild

Rebuild a server with a new image.
func (r *BaremetalServerService) Rebuild(ctx context.Context, serverID string, params BaremetalServerRebuildParams, opts ...option.RequestOption) (*TaskIDList, error)
image_id
string
required
New image ID to install
password
string
New password
username
string
New username (Linux only)

Flavors

List available bare metal hardware configurations.

List Flavors

func (r *BaremetalFlavorService) List(ctx context.Context, params BaremetalFlavorListParams, opts ...option.RequestOption) (*BaremetalFlavorList, error)
include_prices
bool
Include pricing information in response
flavor_id
string
Flavor identifier
flavor_name
string
Human-readable flavor name
vcpus
int64
Physical CPU core count
ram
int64
RAM size in MiB
architecture
string
CPU architecture
hardware_description
map[string]string
Detailed hardware specifications (CPU, disk, network, etc.)
capacity
int64
Number of available servers with this configuration

Images

Manage bare metal-compatible operating system images.

List Images

func (r *BaremetalImageService) List(ctx context.Context, params BaremetalImageListParams, opts ...option.RequestOption) (*GPUImageList, error)
id
string
Image UUID
name
string
Image name
os_distro
string
OS distribution (Ubuntu, Debian, CentOS, etc.)
os_version
string
OS version
architecture
string
Image architecture (x86_64, aarch64)

Examples

Create a Bare Metal Server

import (
    "context"
    "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/cloud"
    "github.com/G-Core/gcore-go/shared/constant"
    "github.com/G-Core/gcore-go/option"
)

client := gcore.NewClient(
    option.WithCloudProjectID(projectID),
    option.WithCloudRegionID(regionID),
)

// Configure network interface
interfaces := []cloud.BaremetalServerNewParamsInterfaceUnion{
    {OfExternal: &cloud.BaremetalServerNewParamsInterfaceExternal{
        Type: constant.ValueOf[constant.External](),
    }},
}

// Create bare metal server
tasks, err := client.Cloud.Baremetal.Servers.New(context.Background(), 
    cloud.BaremetalServerNewParams{
        Name:       gcore.String("database-server"),
        Flavor:     "bm-high-cpu-32-64",
        ImageID:    "baremetal-ubuntu-22.04",
        Interfaces: interfaces,
        SSHKeyName: gcore.String("my-ssh-key"),
        Tags:       map[string]string{"role": "database"},
    },
)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Creating bare metal server (task: %s)\n", tasks.Tasks[0])

List Available Bare Metal Flavors

flavors, err := client.Cloud.Baremetal.Flavors.List(context.Background(), 
    cloud.BaremetalFlavorListParams{
        IncludePrices: gcore.Bool(true),
    },
)
if err != nil {
    log.Fatal(err)
}

for _, flavor := range flavors.Results {
    fmt.Printf("Flavor: %s\n", flavor.FlavorName)
    fmt.Printf("  CPUs: %d, RAM: %d MiB\n", flavor.Vcpus, flavor.Ram)
    fmt.Printf("  Architecture: %s\n", flavor.Architecture)
    fmt.Printf("  Available: %d servers\n", flavor.Capacity)
    
    if flavor.HardwareDescription != nil {
        for key, value := range flavor.HardwareDescription {
            fmt.Printf("  %s: %s\n", key, value)
        }
    }
    
    if flavor.PricePerMonth > 0 {
        fmt.Printf("  Price: $%.2f/month\n", flavor.PricePerMonth)
    }
    fmt.Println()
}

List Bare Metal Images

images, err := client.Cloud.Baremetal.Images.List(context.Background(), 
    cloud.BaremetalImageListParams{},
)
if err != nil {
    log.Fatal(err)
}

for _, image := range images.Results {
    fmt.Printf("Image: %s\n", image.Name)
    fmt.Printf("  OS: %s %s\n", image.OsDistro, image.OsVersion)
    fmt.Printf("  Architecture: %s\n", image.Architecture)
}

List Bare Metal Servers

servers, err := client.Cloud.Baremetal.Servers.List(context.Background(), 
    cloud.BaremetalServerListParams{},
)
if err != nil {
    log.Fatal(err)
}

for _, server := range servers.Results {
    fmt.Printf("Server: %s, Status: %s\n", server.Name, server.Status)
    fmt.Printf("  Flavor: %s\n", server.Flavor.FlavorName)
    fmt.Printf("  CPUs: %d, RAM: %d GB\n", 
        server.Flavor.Vcpus, server.Flavor.Ram/1024)
}

Rebuild Bare Metal Server

tasks, err := client.Cloud.Baremetal.Servers.Rebuild(context.Background(), 
    serverID,
    cloud.BaremetalServerRebuildParams{
        ImageID:  "new-image-id",
        Password: gcore.String("new-secure-password"),
    },
)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Rebuilding server (task: %s)\n", tasks.Tasks[0])

Common Use Cases

High-Performance Database Server

import "encoding/base64"

// Prepare cloud-init script
cloudInit := `#cloud-config
packages:
  - postgresql-14
  - redis-server
runcmd:
  - systemctl start postgresql
  - systemctl enable postgresql
`

interfaces := []cloud.BaremetalServerNewParamsInterfaceUnion{
    {OfSubnet: &cloud.BaremetalServerNewParamsInterfaceSubnet{
        Type:      constant.ValueOf[constant.Subnet](),
        NetworkID: networkID,
        SubnetID:  subnetID,
    }},
}

server, err := client.Cloud.Baremetal.Servers.New(context.Background(), 
    cloud.BaremetalServerNewParams{
        Name:       gcore.String("postgres-baremetal"),
        Flavor:     "bm-high-memory-32-256",
        ImageID:    "ubuntu-22.04-baremetal",
        Interfaces: interfaces,
        SSHKeyName: gcore.String("db-admin-key"),
        UserData:   gcore.String(base64.StdEncoding.EncodeToString([]byte(cloudInit))),
        Tags:       map[string]string{
            "database": "postgresql",
            "tier": "storage",
        },
    },
)

Check Flavor Availability

flavors, err := client.Cloud.Baremetal.Flavors.List(context.Background(), 
    cloud.BaremetalFlavorListParams{},
)

for _, flavor := range flavors.Results {
    if flavor.Capacity > 0 {
        fmt.Printf("Available: %s (%d servers)\n", 
            flavor.FlavorName, flavor.Capacity)
    }
}

Create Server with Reserved Capacity

// Check for reserved capacity
flavors, _ := client.Cloud.Baremetal.Flavors.List(context.Background(), 
    cloud.BaremetalFlavorListParams{},
)

for _, flavor := range flavors.Results {
    if flavor.ReservedCapacity > 0 {
        fmt.Printf("Reserved capacity: %s (%d)\n", 
            flavor.FlavorName, flavor.ReservedCapacity)
        
        // Create server from reserved capacity
        server, _ := client.Cloud.Baremetal.Servers.New(context.Background(), 
            cloud.BaremetalServerNewParams{
                Flavor:     flavor.FlavorID,
                ImageID:    imageID,
                Interfaces: interfaces,
                // ... other params
            },
        )
    }
}

Differences from Virtual Instances

Bare metal servers differ from virtual instances in several ways:
Not Supported:
  • Server groups / placement groups
  • Suspend and resume operations
  • Live migration
  • Hot-add resources (CPU/RAM)
  • Flavor changes without rebuild
Advantages:
  • Dedicated physical hardware
  • No hypervisor overhead
  • Consistent performance
  • Full access to hardware features
  • Ideal for compliance requirements

Access Configuration

Linux Servers

// Option 1: SSH key only
server, _ := client.Cloud.Baremetal.Servers.New(context.Background(), 
    cloud.BaremetalServerNewParams{
        // ...
        SSHKeyName: gcore.String("my-key"),
    },
)

// Option 2: Create user with password
server, _ := client.Cloud.Baremetal.Servers.New(context.Background(), 
    cloud.BaremetalServerNewParams{
        // ...
        Username: gcore.String("admin"),
        Password: gcore.String("SecurePass123!"),
    },
)

// Option 3: Cloud-init script
cloudInit := `#cloud-config
users:
  - name: deploy
    ssh_authorized_keys:
      - ssh-rsa AAAA...
    sudo: ALL=(ALL) NOPASSWD:ALL
`
server, _ := client.Cloud.Baremetal.Servers.New(context.Background(), 
    cloud.BaremetalServerNewParams{
        // ...
        UserData: gcore.String(base64.StdEncoding.EncodeToString([]byte(cloudInit))),
    },
)

Windows Servers

// Set Admin password
server, _ := client.Cloud.Baremetal.Servers.New(context.Background(), 
    cloud.BaremetalServerNewParams{
        // ...
        ImageID:  "windows-server-2022-baremetal",
        Password: gcore.String("AdminPass123!"),
    },
)

Build docs developers (and LLMs) love