Skip to content
Closed

wip #6871

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions api/hypershift/v1beta1/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ type KubevirtNodePoolPlatform struct {
// +optional
// +kubebuilder:validation:MaxItems=10
KubevirtHostDevices []KubevirtHostDevice `json:"hostDevices,omitempty"`

// hosts specifies a list of hosts with their network configurations
// for the nodepool nodes
// +optional
// +kubebuilder:validation:MaxItems=100
Hosts []KubevirtHost `json:"hosts,omitempty"`
}

// KubevirtNetwork specifies the configuration for a virtual machine
Expand Down Expand Up @@ -221,6 +227,19 @@ type KubevirtHostDevice struct {
Count int `json:"count,omitempty"`
}

// KubevirtHost represents a host configuration with network settings
type KubevirtHost struct {
// name is the identifier for the host
// +kubebuilder:validation:MaxLength=255
// +required
Name string `json:"name"`

// networkConfig contains the network configuration for the host
// +kubebuilder:validation:MaxLength=4096
// +optional
NetworkConfig string `json:"networkConfig,omitempty"`
}

// KubeVirtNodePoolStatus contains the KubeVirt platform statuses
type KubeVirtNodePoolStatus struct {
// cacheName holds the name of the cache DataVolume, if exists
Expand Down
20 changes: 20 additions & 0 deletions api/hypershift/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,28 @@ spec:
type: object
maxItems: 10
type: array
hosts:
description: |-
hosts specifies a list of hosts with their network configurations
for the nodepool nodes
items:
description: KubevirtHost represents a host configuration
with network settings
properties:
name:
description: name is the identifier for the host
maxLength: 255
type: string
networkConfig:
description: networkConfig contains the network configuration
for the host
maxLength: 4096
type: string
required:
- name
type: object
maxItems: 100
type: array
networkInterfaceMultiqueue:
default: Enable
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,28 @@ spec:
type: object
maxItems: 10
type: array
hosts:
description: |-
hosts specifies a list of hosts with their network configurations
for the nodepool nodes
items:
description: KubevirtHost represents a host configuration
with network settings
properties:
name:
description: name is the identifier for the host
maxLength: 255
type: string
networkConfig:
description: networkConfig contains the network configuration
for the host
maxLength: 4096
type: string
required:
- name
type: object
maxItems: 100
type: array
networkInterfaceMultiqueue:
default: Enable
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ spec:
required:
- template
type: object
x-kubernetes-validations:
- message: KubevirtClusterTemplate Spec is immutable
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: KubevirtClusterTemplate is immutable
rule: self == oldSelf
served: true
storage: true
Original file line number Diff line number Diff line change
Expand Up @@ -4456,6 +4456,8 @@ spec:
default: false
description: Ready denotes that the machine is ready
type: boolean
virtualMachine:
type: string
required:
- ready
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4480,6 +4480,32 @@ spec:
required:
- spec
type: object
virtualMachinePool:
description: |-
VirtualMachinePool defines a pool of pre-configured virtual machines with specific names and cloud-init configs.
When specified, the controller will use VMs from this pool for scaling operations instead of generating new ones.
items:
description: VirtualMachinePoolEntry defines a single virtual machine
entry in the pool with a specific name and cloud-init configuration.
properties:
cloudInitNetworkData:
description: |-
CloudInitNetworkData contains the cloud-init network data configuration for this specific VM.
This data will be used to customize the network configuration of the VM during boot.
type: string
name:
description: |-
Name specifies the desired name for this virtual machine.
This name will be used as the VM name when creating the virtual machine.
maxLength: 253
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
required:
- name
type: object
maxItems: 100
type: array
required:
- template
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,28 @@ spec:
type: object
maxItems: 10
type: array
hosts:
description: |-
hosts specifies a list of hosts with their network configurations
for the nodepool nodes
items:
description: KubevirtHost represents a host configuration
with network settings
properties:
name:
description: name is the identifier for the host
maxLength: 255
type: string
networkConfig:
description: networkConfig contains the network configuration
for the host
maxLength: 4096
type: string
required:
- name
type: object
maxItems: 100
type: array
networkInterfaceMultiqueue:
default: Enable
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,28 @@ spec:
type: object
maxItems: 10
type: array
hosts:
description: |-
hosts specifies a list of hosts with their network configurations
for the nodepool nodes
items:
description: KubevirtHost represents a host configuration
with network settings
properties:
name:
description: name is the identifier for the host
maxLength: 255
type: string
networkConfig:
description: networkConfig contains the network configuration
for the host
maxLength: 4096
type: string
required:
- name
type: object
maxItems: 100
type: array
networkInterfaceMultiqueue:
default: Enable
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,28 @@ spec:
type: object
maxItems: 10
type: array
hosts:
description: |-
hosts specifies a list of hosts with their network configurations
for the nodepool nodes
items:
description: KubevirtHost represents a host configuration
with network settings
properties:
name:
description: name is the identifier for the host
maxLength: 255
type: string
networkConfig:
description: networkConfig contains the network configuration
for the host
maxLength: 4096
type: string
required:
- name
type: object
maxItems: 100
type: array
networkInterfaceMultiqueue:
default: Enable
description: |-
Expand Down
115 changes: 115 additions & 0 deletions cmd/nodepool/kubevirt/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,120 @@
if len(o.KubevirtHostDevices) > 0 {
platform.KubevirtHostDevices = o.KubevirtHostDevices
}

platform.NetworkDataTemplate =
Subnet: []string{"192.168.123.3/24-192.168.123.10/24"}

Check failure on line 333 in cmd/nodepool/kubevirt/create.go

View check run for this annotation

Red Hat Konflux / Red Hat Konflux / hypershift-operator-main-on-pull-request

cmd/nodepool/kubevirt/create.go#L333

syntax error: unexpected : at end of statement
ExcludedSubnet: []string{"192.168.123.5/24"}

Check failure on line 334 in cmd/nodepool/kubevirt/create.go

View check run for this annotation

Red Hat Konflux / Red Hat Konflux / hypershift-operator-main-on-pull-request

cmd/nodepool/kubevirt/create.go#L334

syntax error: non-declaration statement outside function body
Template := `
{
"version": 1,
"config": [
{
"type": "physical",
"name": "enp1s0",
"subnets": [
{
"type": "static",
"address": "{{ .Subnet }}",
"netmask": "255.255.255.0",
"gateway": "192.168.123.1"
}
]
},
{
"type": "nameserver",
"address": [
"192.168.123.1"
]
}
]
}
`
//TODO: Add a knob for this
platform.Hosts = []hyperv1.KubevirtHost{
{
Name: "worker1",
NetworkConfig: `
{
"version": 1,
"config": [
{
"type": "physical",
"name": "enp1s0",
"subnets": [
{
"type": "static",
"address": "192.168.123.101",
"netmask": "255.255.255.0",
"gateway": "192.168.123.1"
}
]
},
{
"type": "nameserver",
"address": [
"192.168.123.1"
]
}
]
}`,
},
{
Name: "worker2",
NetworkConfig: `
{
"version": 1,
"config": [
{
"type": "physical",
"name": "enp1s0",
"subnets": [
{
"type": "static",
"address": "192.168.123.102",
"netmask": "255.255.255.0",
"gateway": "192.168.123.1"
}
]
},
{
"type": "nameserver",
"address": [
"192.168.123.1"
]
}
]
}
`,
},
{
Name: "worker3",
NetworkConfig: `
{
"version": 1,
"config": [
{
"type": "physical",
"name": "enp1s0",
"subnets": [
{
"type": "static",
"address": "192.168.123.103",
"netmask": "255.255.255.0",
"gateway": "192.168.123.1"
}
]
},
{
"type": "nameserver",
"address": [
"192.168.123.1"
]
}
]
}
`,
},
}
return platform
}
Loading