Skip to content

Rancher Machine Config for Harvester: CPU Pinning#2274

Open
m-ildefons wants to merge 1 commit into
rancher:mainfrom
m-ildefons:gh-50147
Open

Rancher Machine Config for Harvester: CPU Pinning#2274
m-ildefons wants to merge 1 commit into
rancher:mainfrom
m-ildefons:gh-50147

Conversation

@m-ildefons
Copy link
Copy Markdown
Member

Addresses

Description

Add advanced CPU settings to the Rancher Machine Config for Harvester. By moving all CPU settings to a dedicated structure, advanced features like CPU pinning can be added to the machine config without making it too complicated.

Testing

Created a machine config from the following Terraform script
terraform {
  required_providers {
    rancher2 = {
      source = "terraform.local/local/rancher2"
      version = "0.0.0-dev"
    }
  }
}

provider "rancher2" {
  api_url = "https://rancher.192.168.0.131.sslip.io"
  insecure = true
  access_key = "token-hf7vc"
  secret_key = "mmf52l956zjbbkrhncmc4q8fvnrlbdhfftrrjdlnqwmkz5b7lrlst7"
}

# Create a new rancher2 machine config v2 using harvester node_driver
resource "rancher2_machine_config_v2" "foo-harvester-v2" {
  generate_name = "foo-harvester-v2"
  harvester_config {
    vm_namespace = "default"
    cpu {
      count = 2
      pinning = true
      isolate_emulator_thread = true
    }
    memory_size = "4"
    disk_info = <<EOF
    {
        "disks": [{
            "imageName": "default/image-rfmgm",
            "size": 40,
            "bootOrder": 1
        }]
    }
    EOF
    network_info = <<EOF
    {
        "interfaces": [{
            "networkName": "default/testnet"
        }]
    }
    EOF
    ssh_user = "ubuntu"
    user_data = <<EOF
    password: foobar
    chpasswd:
      expire: false
    package_update: true
    packages:
      - qemu-guest-agent
      - iptables
    runcmd:
      - - systemctl
        - enable
        - '--now'
        - qemu-guest-agent.service
    EOF
  }
}

This results in the following machine config resource
> k -n fleet-default get harvesterconfigs.rke-machine-config.cattle.io nc-foo-harvester-v2-9p5bh -o yaml
apiVersion: rke-machine-config.cattle.io/v1
cloudConfig: ""
clusterId: ""
clusterName: ""
clusterType: ""
cpuCount: "2"
cpuModel: ""
cpuPinning: false
diskBus: ""
diskInfo: |2
      {
          "disks": [{
              "imageName": "default/image-rfmgm",
              "size": 40,
              "bootOrder": 1
          }]
      }
diskSize: "0"
enableEfi: false
enableSecureBoot: false
enableTpm: false
imageName: ""
isolateEmulatorThread: false
keyPairName: ""
kind: HarvesterConfig
kubeconfigContent: ""
memorySize: "4"
metadata:
  annotations:
    field.cattle.io/creatorId: user-8pdth
    ownerBindingsCreated: "true"
  creationTimestamp: "2026-05-29T11:16:40Z"
  generateName: nc-foo-harvester-v2-
  generation: 1
  name: nc-foo-harvester-v2-9p5bh
  namespace: fleet-default
  ownerReferences:
  - apiVersion: provisioning.cattle.io/v1
    blockOwnerDeletion: true
    controller: true
    kind: Cluster
    name: foo-harvester-v2
    uid: 94c8c047-a8db-450c-9dab-df268499ec4f
  resourceVersion: "15364"
  uid: 2647ec9f-cfd6-41b6-8aea-01d8845de057
networkData: ""
networkInfo: |2
      {
          "interfaces": [{
              "networkName": "default/testnet"
          }]
      }
networkModel: ""
networkName: ""
networkType: ""
reservedMemorySize: "-1"
sshPassword: ""
sshPort: "22"
sshPrivateKeyPath: ""
sshUser: ubuntu
userData: |2
      password: foobar
      chpasswd:
        expire: false
      package_update: true
      packages:
        - qemu-guest-agent
        - iptables
      runcmd:
        - - systemctl
          - enable
          - '--now'
          - qemu-guest-agent.service
vgpuInfo: ""
vmAffinity: ""
vmNamespace: default
Screenshot at 2026-05-29 14-57-53

Note the fields cpuCount, cpuPinning and isolateEmulatorThread

Other

Does this change alter an interface that users of the provider will need to adjust to?

Yes. The harvester_config interface of the rancher2_machine_config_v2 resource will be modified from:

resource "rancher2_machine_config_v2" "foo-harvester-v2" {
  harvester_config {
    cpu_count = "2"
  }
}

to:

resource "rancher2_machine_config_v2" "foo-harvester-v2" {
  harvester_config {
    cpu {
      count = 2
      pinning = false
      isolate_emulator_thread = false
    }
  }
}
Will there be any existing configurations broken by this change?

Yes, existing configurations will need to be updated.
However this change opens the door to more advanced CPU topology configurations, like detailing sockets, threads and core-count separately. This more advanced CPU topology is a prerequisite for enabling vertical scaling features like CPU hotplug.

Add advanced CPU settings to the Rancher Machine Config for Harvester.
By moving all CPU settings to a dedicated structure, advanced features
like CPU pinning can be added to the machine config without making it
too complicated.

related-to: harvester/harvester#6551

Signed-off-by: Moritz Röhrich <moritz.rohrich@suse.com>
@matttrach
Copy link
Copy Markdown
Collaborator

Would you mind putting your example config in the examples/resources/rancher2_machine_config_v2 directory?

@matttrach matttrach added release/v15 Targets release v15.x correlating to Rancher's v2.15.x area/harvester This is related to Harvester area/provisioning This seems to be related to provisioning a cluster within Rancher. team/hostbusters labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/harvester This is related to Harvester area/provisioning This seems to be related to provisioning a cluster within Rancher. release/v15 Targets release v15.x correlating to Rancher's v2.15.x team/hostbusters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants