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)
Bare metal flavor ID (hardware configuration)
Network interface configurations
Bare metal-compatible image ID
Password for default user (Linux) or Admin (Windows)
Username to create (Linux only)
Base64-encoded cloud-init or cloudbase-init script
Server status: ACTIVE, BUILD, ERROR, SHUTOFF, etc.
Hardware configuration details
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)
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 pricing information in response
Human-readable flavor name
Detailed hardware specifications (CPU, disk, network, etc.)
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)
OS distribution (Ubuntu, Debian, CentOS, etc.)
Image architecture (x86_64, aarch64)
Examples
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])
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()
}
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)
}
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)
}
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
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!"),
},
)